:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafc;
    --border: #e5e8f0;
    --text: #111827;
    --muted: #6b7280;
    --accent: #4338ca;
    --accent-hover: #3730a3;
    --accent-soft: #eef2ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #047857;
    --success-soft: #ecfdf5;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --radius: 16px;
    --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
}

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

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Auth screen ---------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(67, 56, 202, 0.10), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(14, 165, 233, 0.10), transparent 40%),
        var(--bg);
}

.auth-shell {
    width: 100%;
    max-width: 430px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 40px 34px;
    box-shadow: var(--shadow);
    text-align: center;
}

.brand-mark {
    width: 54px;
    height: 54px;
    margin: 0 auto 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, #4f46e5, #2563eb);
    color: #fff;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 20px rgba(67, 56, 202, 0.25);
}

.brand-mark svg {
    width: 26px;
    height: 26px;
}

.brand-mark-sm {
    width: 40px;
    height: 40px;
    margin: 0;
    border-radius: 12px;
    flex-shrink: 0;
}

.brand-mark-sm svg {
    width: 20px;
    height: 20px;
}

.auth-title {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 26px;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 13px 18px;
    border-radius: 12px;
    border: 1px solid #d7dce6;
    background: #ffffff;
    color: #1f2937;
    font-size: 0.96rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.04);
}

.google-btn:hover {
    border-color: #b7c0d2;
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.08);
    transform: translateY(-1px);
}

.google-btn.is-muted {
    opacity: 0.85;
}

.google-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-footer {
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Alerts ---------- */
.alert {
    text-align: left;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.82em;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 5px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecaca;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: #a7f3d0;
}

.alert-warning {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: #fde68a;
}

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

.sidebar {
    width: 264px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.brand-name {
    font-weight: 700;
    font-size: 0.98rem;
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.78rem;
    color: var(--muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 0 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: #374151;
    font-size: 0.93rem;
    font-weight: 500;
    transition: background 0.14s ease, color 0.14s ease;
}

.nav-item svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

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

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

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

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    border: none;
    background: transparent;
    color: var(--danger);
    font-family: inherit;
    font-size: 0.93rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.14s ease;
}

.logout-btn svg {
    width: 19px;
    height: 19px;
}

.logout-btn:hover {
    background: var(--danger-soft);
}

/* ---------- Main area ---------- */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.menu-toggle svg {
    width: 20px;
    height: 20px;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 6px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-lg {
    width: 68px;
    height: 68px;
    font-size: 1.4rem;
}

.avatar-fallback {
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.84rem;
}

.user-pill-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-pill-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-pill-email {
    font-size: 0.74rem;
    color: var(--muted);
}

.content {
    padding: 28px;
    max-width: 1120px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.hero-banner {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 55%, #2563eb 100%);
    color: #ffffff;
    border-radius: 20px;
    padding: 28px 30px;
    box-shadow: 0 12px 28px rgba(67, 56, 202, 0.22);
}

.hero-banner h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 10px 0 6px;
}

.hero-banner p {
    color: rgba(255, 255, 255, 0.88);
    max-width: 640px;
    font-size: 0.95rem;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card,
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.03);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-sm {
    font-size: 1rem;
    padding-top: 6px;
}

.stat-cap {
    text-transform: capitalize;
}

.stat-hint {
    font-size: 0.76rem;
    color: var(--muted);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.quick-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.14s ease, transform 0.14s ease, background 0.14s ease;
}

.quick-card:hover {
    border-color: #c7d2fe;
    background: #ffffff;
    transform: translateY(-2px);
}

.quick-card span {
    font-size: 0.85rem;
    color: var(--muted);
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.detail-list dt {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.detail-list dd {
    font-size: 0.95rem;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ua-cell {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 460px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field span {
    font-size: 0.86rem;
    font-weight: 600;
}

.field input {
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-family: inherit;
    font-size: 0.94rem;
    outline: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.14);
}

.field input:disabled {
    background: var(--surface-soft);
    color: var(--muted);
}

.primary-btn {
    align-self: flex-start;
    padding: 11px 20px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.14s ease;
}

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

.sidebar-backdrop {
    display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .quick-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: inline-flex;
    }
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 30;
        transition: left 0.2s ease;
    }
    .sidebar.open {
        left: 0;
    }
    .sidebar-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, 0.4);
        z-index: 20;
    }
    .topbar {
        padding: 14px 16px;
    }
    .user-pill-text {
        display: none;
    }
    .user-pill {
        padding: 4px;
    }
    .content {
        padding: 18px 16px;
    }
    .detail-list {
        grid-template-columns: 1fr;
    }
}
