:root {
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --bg: #ffffff;
    --bg-2: #f7f7f8;
    --bg-3: #efefef;
    --border: #e5e5e5;
    --text-1: #111111;
    --text-2: #6e6e80;
    --text-3: #adadbd;
    --accent: #10a37f;
    --accent-hover: #0d8f6e;
    --danger: #d64545;
    --active-bg: #e7f6f2;
    --active-text: var(--accent);
    --sidebar-w: 276px;
    --sidebar-w-collapsed: 76px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, .10), 0 2px 4px rgba(0, 0, 0, .06);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

button, a, input, textarea, select {
    outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--text-2);
    outline-offset: 2px;
}

html { font-size: 15px; }

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

a { color: inherit; }

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar (Filament-style) ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.15s ease;
}

html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 26px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border);
}
html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 20px 0; }
.sidebar-brand-text { flex: 1; }
html.sidebar-collapsed .sidebar-brand-text { display: none; }

.sidebar-toggle-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-3);
    border-radius: 6px;
    cursor: pointer;
}
.sidebar-toggle-btn:hover { background: var(--bg-3); color: var(--text-1); }
.sidebar-toggle-btn .material-symbols-outlined { font-size: 19px; }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 22px 16px;
    overflow-y: auto;
}
html.sidebar-collapsed .sidebar-nav { padding: 22px 12px; }

.nav-group-label {
    margin: 24px 12px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    overflow: hidden;
}
.nav-group-label:first-child { margin-top: 0; }
html.sidebar-collapsed .nav-group-label { height: 1px; margin: 12px 4px; padding: 0; background: var(--border); text-indent: -9999px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    line-height: 1.3;
    white-space: nowrap;
}
html.sidebar-collapsed .nav-item { justify-content: center; padding: 11px; }

.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: rgba(16, 163, 127, .1); color: var(--accent); font-weight: 600; }

.nav-label { overflow: hidden; text-overflow: ellipsis; }
html.sidebar-collapsed .nav-label { display: none; }

.nav-icon.material-symbols-outlined {
    font-size: 23px;
    width: 23px;
    height: 23px;
    flex-shrink: 0;
    color: var(--text-3);
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.nav-item:hover .nav-icon.material-symbols-outlined { color: var(--text-2); }
.nav-item.active .nav-icon.material-symbols-outlined { color: var(--accent); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
html.sidebar-collapsed .sidebar-footer { padding: 12px; }
.sidebar-logout { width: 100%; }

.logout-btn:hover,
.sidebar-logout .nav-item:hover {
    background: rgba(214, 69, 69, 0.08);
    color: var(--danger);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    padding: 36px 44px 60px;
    overflow-y: auto;
    min-width: 0;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 24px;
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text-1); letter-spacing: -0.02em; }
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-body {}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-card-hover);
}

.stat-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
}

.stat-tag-blue {
    background: #e5edff;
    color: #3d5fd6;
}

.stat-tag-purple {
    background: #f1e9ff;
    color: #8b5cf6;
}

.stat-tag-green {
    background: var(--active-bg);
    color: var(--accent);
}

.stat-tag-orange {
    background: #ffedd9;
    color: #d97a1f;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-1);
    margin-bottom: 4px;
}

.stat-caption {
    font-size: 12.5px;
    color: var(--text-2);
}

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.table-wrap {
    border-top: 1px solid var(--border);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green {
    background: var(--active-bg);
    color: var(--accent);
}

.badge-gray {
    background: var(--bg-3);
    color: var(--text-2);
}

.config-shell {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.config-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 160px;
    flex-shrink: 0;
}

.config-tabs a {
    display: block;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-2);
    font-size: 14px;
}

.config-tabs a:hover {
    background: var(--bg-2);
    color: var(--text-1);
}

.config-tabs a.active {
    background: var(--accent);
    color: #fff;
}

.config-panel {
    flex: 1;
    min-width: 0;
}

.empty-state {
    color: var(--text-2);
    font-size: 14px;
    padding: 48px 20px;
    text-align: center;
}

.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 14px;
    font-family: inherit;
}

.field input[readonly] {
    background: var(--bg-2);
    color: var(--text-2);
    cursor: pointer;
}

.field textarea {
    min-height: 160px;
    resize: vertical;
}

.field .hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-2);
}

.btn-primary {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

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

.btn-danger {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
}

.btn-danger:hover {
    background: rgba(214, 69, 69, 0.1);
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: var(--bg-3);
    color: var(--text-1);
}

.icon-btn .material-symbols-outlined {
    font-size: 18px;
}

.level-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.level-row input {
    flex: 1;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 14px;
    font-family: inherit;
}

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

.add-row-form input {
    flex: 1;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--text-1);
    font-size: 14px;
    font-family: inherit;
}

.add-row-form input:focus {
    border-style: solid;
    border-color: var(--accent);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

.admin-table th {
    color: var(--text-2);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.admin-table tbody tr {
    transition: background-color 0.1s ease;
}

.admin-table tbody tr:hover {
    background: var(--bg-2);
}

.admin-table a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.admin-table a:hover {
    text-decoration: underline;
}

.status-banner {
    background: var(--active-bg);
    border: 1px solid var(--accent);
    color: var(--text-1);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

.error-banner {
    background: rgba(255, 92, 92, 0.12);
    border: 1px solid var(--danger);
    color: var(--text-1);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

/* Login page */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 340px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-card);
}

.login-card h1 {
    font-size: 18px;
    margin: 0 0 24px;
    text-align: center;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-2);
}

.checkbox-field input { width: auto; }

/* ── Horizontal underline tabs (e.g. Dashboard Statistics/Finance) ── */
.tab-row {
    display: flex;
    gap: 28px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-item {
    padding: 10px 2px 12px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text-3);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-item:hover { color: var(--text-1); }
.tab-item.active { color: var(--text-1); border-bottom-color: var(--accent); }

/* ── Platform badges (social media tracking cards) ── */
.platform-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.platform-pill-facebook { background: #e5edff; color: #3d5fd6; }
.platform-pill-instagram { background: #ffe4ef; color: #db2777; }
.platform-pill-tiktok { background: #efefef; color: #111111; }
.platform-pill-youtube { background: #ffe0e0; color: #d32f2f; }
.platform-pill-default { background: var(--bg-3); color: var(--text-2); }

/* ── Secondary button ── */
.btn-secondary {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 14px;
    cursor: pointer;
}

.btn-secondary:hover { background: var(--bg-2); }

/* ── List toolbar (search + filters) ── */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.search-input {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    min-width: 240px;
    flex: 1 1 240px;
}

.search-input .material-symbols-outlined { font-size: 18px; color: var(--text-3); }

.search-input input {
    border: none;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    width: 100%;
}

.list-toolbar select {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 14px;
    font-family: inherit;
}

.list-toolbar .clear-filters {
    font-size: 13px;
    color: var(--text-2);
    text-decoration: none;
    padding: 0 4px;
}

.list-toolbar .clear-filters:hover { color: var(--text-1); text-decoration: underline; }

/* ── Batch action bar ── */
.batch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: var(--active-bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}

.batch-bar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.batch-bar-actions button {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
}

.batch-bar-actions button:hover { background: var(--bg-2); }
.batch-bar-actions button.danger { border-color: var(--danger); color: var(--danger); }
.batch-bar-actions button.danger:hover { background: rgba(214, 69, 69, 0.1); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 17, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 50;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius);
    width: 440px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-card-hover);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15.5px; font-weight: 600; }

.modal-body { padding: 22px; }

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

[x-cloak] { display: none !important; }

/* ── Avatars ── */
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-3);
}

.avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 700;
    color: #fff;
    background: var(--text-3);
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 20px;
}

.avatar-picker {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.avatar-picker-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.avatar-picker-actions label.btn-secondary {
    display: inline-block;
    text-align: center;
}

.avatar-picker-actions .link-btn {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.avatar-picker-actions .link-btn:hover { color: var(--danger); }
