/* Shared color/type/radius/shadow tokens now live in tokens.css
   (vendored from LhamacorpLabs/design-system). Only app-specific
   layout tokens that aren't part of that shared set stay here. */
:root {
    --sidebar-width: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--gap);
}

/* Dashboard layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--gap);
    left: var(--gap);
    bottom: var(--gap);
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-contrast);
}

.sidebar-brand .brand-name {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 12px 6px;
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.nav-item .nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: currentColor;
}

.nav-badge {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
    background: var(--accent-subtle);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
}

.sidebar-user .user-avatar {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--accent-contrast);
}

.sidebar-user .user-meta {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-meta .user-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-meta .user-role {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.theme-toggle-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-toggle-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: calc(var(--sidebar-width) + var(--gap) * 2);
    margin-top: var(--gap);
    margin-right: var(--gap);
    margin-bottom: var(--gap);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px 40px;
    min-height: calc(100vh - var(--gap) * 2);
}

.page-header {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.page-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.card-header .card-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.card-title {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Section */
.section {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-action-btn {
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.quick-action-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--surface-hover);
}

.quick-action-btn.primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-contrast);
}

.quick-action-btn.primary:hover {
    background: var(--accent-hover);
}

.quick-action-btn.danger {
    color: var(--danger);
    border-color: var(--error-border);
    background: var(--input-bg);
}

.quick-action-btn.danger:hover {
    background: var(--error-bg);
}

/* Detail rows */
.detail-list {
    display: flex;
    flex-direction: column;
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value .role-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent-subtle);
    color: var(--text-secondary);
    margin-left: 4px;
}

.detail-value .role-badge:first-child {
    margin-left: 0;
}

.token-row {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 60%;
}

.token-preview {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.copy-token-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.copy-token-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--surface-hover);
}

.copy-token-btn.copied {
    color: var(--success-text);
    border-color: var(--success-border);
    background: var(--success-bg);
}

/* Auth container */
.auth-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    margin: 20px;
}

.auth-header {
    text-align: center;
    padding: 2rem 2rem 1.5rem;
    position: relative;
}

.auth-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.theme-icon-sun, .theme-icon-moon {
    width: 14px;
    height: 14px;
}

.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }

:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

.tab-container {
    display: flex;
    margin: 0 1.5rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 4px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 0.5rem 1rem;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    transition: all 0.15s;
    font-family: var(--font-mono);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--text-primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.form-container {
    padding: 1.5rem;
}

.form { display: none; }
.form.active { display: block; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: var(--font-mono);
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:hover {
    border-color: var(--border-hover);
}

.form-group input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.submit-btn {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.submit-btn:hover {
    background: var(--accent-hover);
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.message {
    margin-top: 0.75rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
    font-size: 0.75rem;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.message.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.forgot-password-link {
    margin-top: 0.75rem;
    text-align: center;
}

.forgot-password-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.15s;
}

.forgot-password-link a:hover {
    color: var(--text-secondary);
}

.loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-contrast);
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Edit profile in dashboard */
.profile-section, .security-section {
    margin-bottom: 20px;
    padding-top: 16px;
}

.profile-section:first-child {
    padding-top: 0;
}

.security-section {
    border-top: 1px solid var(--border);
}

.profile-section h4, .security-section h4 {
    margin: 0 0 10px 0;
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.form-buttons .submit-btn {
    flex: 1;
    margin: 0;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(38, 30, 60, 0.35);
    z-index: 99;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin: 0;
        border-radius: 0;
        border-width: 0;
        padding: 20px 16px;
        padding-top: 60px;
        min-height: 100vh;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .auth-container {
        margin: 12px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px;
        padding-top: 56px;
    }

    .section {
        padding: 14px;
    }

    .quick-actions {
        flex-direction: column;
    }
}
