* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --success: #059669;
    --success-light: #D1FAE5;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --bg-main: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-input: #F1F5F9;
    --bg-hover: #E2E8F0;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-focus: #4F46E5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #EEF2FF 0%, #F8FAFC 50%, #F0FDF4 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header - compact for 1366x768 */
header {
    text-align: center;
    padding: 16px 0;
}

.logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: var(--shadow-md);
}

.logo svg {
    color: white;
    width: 28px;
    height: 28px;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Main Layout - two columns for 1366x768 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 10px;
}

.tab {
    flex: 1;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Forms */
.form-container {
    display: none;
}

.form-container.active {
    display: block;
}

.form-container h2 {
    font-size: 17px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.description {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--success), #10B981);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar svg {
    color: white;
    width: 24px;
    height: 24px;
}

.user-info h2 {
    font-size: 16px;
    margin-bottom: 2px;
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

/* Security Badge */
.security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--success-light);
    border: 1px solid rgba(5, 150, 105, 0.2);
    border-radius: 10px;
    color: var(--success);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
}

.security-badge svg {
    width: 18px;
    height: 18px;
}

/* Info Cards Grid */
.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.info-card {
    background: var(--bg-input);
    padding: 14px;
    border-radius: 10px;
    text-align: center;
}

.info-card h3 {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.info-card p {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Side Panel - Stats & History */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.panel-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.panel-card h3 svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: var(--bg-input);
    padding: 14px;
    border-radius: 10px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}

/* Login History */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 8px;
    font-size: 12px;
}

.history-icon {
    width: 32px;
    height: 32px;
    background: var(--success-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-icon svg {
    width: 16px;
    height: 16px;
    color: var(--success);
}

.history-info {
    flex: 1;
}

.history-action {
    font-weight: 500;
    color: var(--text-primary);
}

.history-time {
    color: var(--text-muted);
    font-size: 11px;
}

/* Device Info */
.device-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--primary-light);
    border-radius: 10px;
}

.device-icon {
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.device-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.device-details h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.device-details p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Status Messages */
.status-container {
    margin-top: 14px;
}

.status-message {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-message.success {
    background: var(--success-light);
    color: var(--success);
}

.status-message.error {
    background: var(--danger-light);
    color: var(--danger);
}

.status-message.info {
    background: var(--primary-light);
    color: var(--primary);
}

.status-message.warning {
    background: var(--warning-light);
    color: var(--warning);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 340px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.yubikey-animation {
    margin-bottom: 20px;
}

.yubikey-animation svg {
    color: var(--primary);
    animation: float 3s ease-in-out infinite;
    width: 64px;
    height: 64px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.loader {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Touch indicator */
.touch-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--warning-light);
    border-radius: 8px;
    color: var(--warning);
    font-size: 13px;
    font-weight: 500;
    margin-top: 12px;
}

.touch-indicator svg {
    width: 20px;
    height: 20px;
    animation: pulse 1.5s infinite;
}

.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Responsive for 1366x768 and below */
@media (max-width: 1400px) {
    .container {
        max-width: 100%;
        padding: 16px;
    }

    .main-content {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .side-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .card, .panel-card {
        padding: 18px;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .side-panel {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Success animation */
@keyframes successPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.success-animation {
    animation: successPop 0.5s ease-out;
}

/* Shimmer effect for loading */
.shimmer {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Technical Info Section */
.tech-info-section {
    margin-top: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.tech-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-input);
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.tech-header:hover {
    background: var(--bg-hover);
}

.tech-header svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.tech-header span {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.tech-header .chevron {
    color: var(--text-muted);
    transition: transform 0.3s;
}

.tech-info-section.expanded .tech-header .chevron {
    transform: rotate(180deg);
}

.tech-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.tech-info-section.expanded .tech-content {
    max-height: 600px;
}

.tech-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    padding: 1px;
}

.tech-item {
    background: var(--bg-card);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tech-item.full-width {
    grid-column: span 2;
}

.tech-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.tech-value {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
}

.tech-value.mono {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    background: var(--bg-input);
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--primary);
}

.tech-value.small {
    font-size: 10px;
    line-height: 1.4;
}

.tech-value .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.tech-value .badge.success {
    background: var(--success-light);
    color: var(--success);
}

.tech-value .badge.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.tech-value .badge.info {
    background: var(--primary-light);
    color: var(--primary);
}

@media (max-width: 600px) {
    .tech-grid {
        grid-template-columns: 1fr;
    }

    .tech-item.full-width {
        grid-column: span 1;
    }
}

/* ==================== SETTINGS PANEL ==================== */

.settings-panel {
    border: 2px solid var(--primary-light);
}

.settings-section {
    margin-bottom: 16px;
}

.settings-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Mode Options */
.mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-option {
    cursor: pointer;
}

.mode-option input {
    display: none;
}

.mode-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.mode-option:hover .mode-content {
    background: var(--bg-hover);
}

.mode-option input:checked + .mode-content {
    background: var(--primary-light);
    border-color: var(--primary);
}

.mode-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
}

.mode-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mode-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* Protocol Options */
.protocol-options {
    display: flex;
    gap: 8px;
}

.protocol-option {
    flex: 1;
    cursor: pointer;
}

.protocol-option input {
    display: none;
}

.protocol-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 10px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 10px;
    text-align: center;
    transition: all 0.2s ease;
}

.protocol-option:hover .protocol-content {
    background: var(--bg-hover);
}

.protocol-option input:checked + .protocol-content {
    background: var(--primary-light);
    border-color: var(--primary);
}

.protocol-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.protocol-badge {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.protocol-badge.new {
    background: var(--success-light);
    color: var(--success);
}

.protocol-badge.legacy {
    background: var(--warning-light);
    color: var(--warning);
}

/* Settings Status */
.settings-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    background: var(--success-light);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--success);
    transition: all 0.3s ease;
}

.settings-status.loading {
    background: var(--primary-light);
    color: var(--primary);
}

.settings-status.error {
    background: var(--danger-light);
    color: var(--danger);
}

.settings-status .status-icon {
    font-size: 14px;
}

/* Protocol Indicator in Dashboard */
.protocol-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--primary-light);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-left: 8px;
}

.protocol-indicator.u2f {
    background: var(--warning-light);
    color: var(--warning);
}
