:root {
    --bg: #F6F8FA;
    --surface: #FFFFFF;
    --surface-subtle: #FAFBFD;
    --surface-muted: #EEF2F6;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --text: #0F172A;
    --text-muted: #475569;
    --primary: #0A6E6C;
    --primary-hover: #085A58;
    --primary-soft: #D5F5F1;
    --primary-soft-text: #042F2E;
    --danger: #DC2626;
    --danger-soft: #FEE2E2;
    --success: #059669;
    --success-soft: #D1FAE5;
    --warning: #D97706;
    --warning-soft: #FEF3C7;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Brand & Auth */
.brand-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #F6F8FA 0%, #EDF3F5 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.auth-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.auth-header h1 {
    margin: 0 0 2px;
    font-size: 1.25rem;
}

.auth-header .lang-pills { margin-left: auto; }

/* App Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

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

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

.brand-meta { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { font-size: 0.75rem; color: var(--text-muted); }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 16px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--surface-muted); color: var(--text); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-soft-text);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-soft-text);
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-handle { font-size: 0.74rem; color: var(--text-muted); font-family: var(--font-mono); }

.main-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    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: 20;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.page-subtitle { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted); }

/* Language Switcher */
.lang-pills {
    display: inline-flex;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.lang-pill {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    min-height: 32px;
}

.lang-pill.active {
    background: var(--primary);
    color: #fff;
}

.view-container {
    padding: 24px 28px 40px;
    max-width: 1360px;
    width: 100%;
    margin: 0 auto;
}

/* Cards, Grids, Tables */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card, .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.kpi-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 1.65rem; font-weight: 700; margin-top: 6px; font-family: var(--font-mono); }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.tabs {
    display: inline-flex;
    background: var(--surface-muted);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
    margin-bottom: 18px;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
}

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

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: var(--surface-subtle);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-subtle); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}
.badge-success { background: var(--success-soft); color: #065F46; }
.badge-warning { background: var(--warning-soft); color: #92400E; }
.badge-danger { background: var(--danger-soft); color: #991B1B; }
.badge-neutral { background: var(--surface-muted); color: var(--text-muted); }

/* Forms & Buttons */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.84rem; font-weight: 600; color: var(--text); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 500; cursor: pointer; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="color"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: var(--danger-soft); color: #991B1B; }
.btn-danger:hover { background: #FECACA; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.form-error {
    color: var(--danger);
    background: var(--danger-soft);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    margin: 0;
}

.thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-muted);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

.media-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-preview {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: var(--surface-muted);
}

.media-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
}

.token-reveal {
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    color: var(--primary-soft-text);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

/* Modal & Toast */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 50;
}

.modal-dialog {
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.08rem; }
.modal-body { padding: 20px 22px; overflow-y: auto; }

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
}

.toast {
    background: var(--text);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }

.mobile-only { display: none; }

@media (max-width: 900px) {
    .mobile-only { display: grid; }
    .sidebar {
        position: fixed;
        left: -280px;
        z-index: 40;
        transition: left 0.2s ease;
    }
    .sidebar.open { left: 0; box-shadow: var(--shadow-md); }
    .topbar { padding: 14px 16px; }
    .view-container { padding: 18px 16px 32px; }
}
