/* KiddyCoder Admin — modern dashboard UI (Next.js / shadcn-inspired) */

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

:root {
    --sidebar-w: 16rem;
    --topbar-h: 3.75rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --background: #fafafa;
    --foreground: #09090b;
    --muted: #71717a;
    --muted-bg: #f4f4f5;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --card: #ffffff;
    --card-hover: #fafafa;
    --primary: #18181b;
    --primary-fg: #fafafa;
    --primary-hover: #27272a;
    --ring: rgba(24, 24, 27, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --info: #2563eb;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font);
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ── Shell ── */

.admin-shell { display: flex; min-height: 100vh; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
    backdrop-filter: blur(2px);
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--card);
    border-right: 1px solid var(--border);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand .icon {
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-fg);
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-brand span {
    display: block;
    font-size: 0.6875rem;
    color: var(--muted);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.sidebar-section {
    margin-top: 1.25rem;
    padding: 0 0.625rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.sidebar-section:first-child { margin-top: 0.25rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    color: #52525b;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: var(--muted-bg);
    color: var(--foreground);
}

.sidebar-link.active {
    background: var(--muted-bg);
    color: var(--foreground);
    font-weight: 600;
}

.sidebar-link svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-footer .hint {
    font-size: 0.6875rem;
    color: var(--muted);
}

/* ── Main ── */

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 30;
    gap: 1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    cursor: pointer;
    color: var(--foreground);
}

.topbar h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-sub {
    font-size: 0.75rem;
    color: var(--muted);
    display: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem 0.25rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
}

.user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    background: var(--muted-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #52525b;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #3f3f46;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

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

.flash {
    margin: 1rem 1.5rem 0;
    padding: 0.75rem 1rem;
    background: var(--success-bg);
    color: #15803d;
    border: 1px solid var(--success-border);
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flash::before {
    content: '';
    width: 1.25rem;
    height: 1.25rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2316a34a' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center/contain no-repeat;
    flex-shrink: 0;
}

.content {
    padding: 1.25rem 1.75rem 2rem;
    width: 100%;
    max-width: none;
    flex: 1;
}

.page-layout {
    display: grid;
    gap: 1.5rem;
    align-items: start;
}

.page-layout.has-sidebar {
    grid-template-columns: minmax(0, 1fr) 17.5rem;
}

.table-card .card-header h4 {
    margin: 0;
}

.table-card .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
    position: sticky;
    right: 0;
    background: var(--card);
    box-shadow: -4px 0 8px -4px rgba(0, 0, 0, 0.06);
    z-index: 2;
}

table.data-table thead th.col-actions {
    background: #fafafa;
    z-index: 3;
}

table.data-table tbody tr:hover td.col-actions {
    background: #fafafa;
}

/* ── Dropdown actions ── */

.dropdown {
    position: relative;
    display: inline-flex;
}

.dropdown-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    color: #52525b;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.dropdown-trigger:hover,
.dropdown.open .dropdown-trigger {
    background: var(--muted-bg);
    border-color: var(--border-strong);
    color: var(--foreground);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    width: max-content;
    min-width: 6.5rem;
    max-width: 9.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
    z-index: 60;
}

.dropdown-menu.dropdown-menu-floating {
    display: block;
    position: fixed;
    width: max-content;
    max-width: 9.5rem;
    z-index: 200;
    animation: dropdown-in 0.12s ease;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.dropdown.open .dropdown-menu {
    display: block;
    animation: dropdown-in 0.12s ease;
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: auto;
    min-width: 100%;
    gap: 0.5rem;
    padding: 0.4375rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: #3f3f46;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.1s, color 0.1s;
}

.dropdown-item:hover {
    background: var(--muted-bg);
    color: var(--foreground);
}

.dropdown-item-success { color: #15803d; }
.dropdown-item-success:hover { background: var(--success-bg); color: #15803d; }

.dropdown-item-warning { color: #b45309; }
.dropdown-item-warning:hover { background: var(--warning-bg); color: #b45309; }

.dropdown-item-danger { color: #b91c1c; }
.dropdown-item-danger:hover { background: var(--danger-bg); color: #b91c1c; }

.dropdown-item-primary { color: #1d4ed8; }
.dropdown-item-primary:hover { background: var(--info-bg); color: #1d4ed8; }

.dropdown-form { margin: 0; padding: 0; display: block; width: max-content; min-width: 100%; }

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Recent activity sidebar ── */

.recent-card { margin-bottom: 0; }

.recent-card .card-header {
    background: linear-gradient(135deg, #fafafa 0%, #f4f4f5 100%);
}

.recent-list {
    list-style: none;
    padding: 0.375rem 0;
    margin: 0;
}

.recent-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.375rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.recent-item:hover {
    background: #fafafa;
}

.recent-item:last-child { border-bottom: none; }

.recent-item-body { min-width: 0; flex: 1; }

.recent-item-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1.3;
}

.recent-item-sub {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-item-time {
    font-size: 0.6875rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.recent-item .badge { flex-shrink: 0; margin-top: 0.125rem; }

/* ── Page header ── */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-header .breadcrumb,
.breadcrumb {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.page-header .breadcrumb { display: block; }

/* ── Stats ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.25rem 1.25rem 1.375rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--stat-accent, var(--border-strong));
    border-radius: 3px 0 0 3px;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.stat-card[data-accent="violet"] { --stat-accent: #7c3aed; background: linear-gradient(135deg, #fff 0%, #f5f3ff 100%); }
.stat-card[data-accent="amber"] { --stat-accent: #d97706; background: linear-gradient(135deg, #fff 0%, #fffbeb 100%); }
.stat-card[data-accent="emerald"] { --stat-accent: #059669; background: linear-gradient(135deg, #fff 0%, #ecfdf5 100%); }
.stat-card[data-accent="rose"] { --stat-accent: #e11d48; background: linear-gradient(135deg, #fff 0%, #fff1f2 100%); }
.stat-card[data-accent="sky"] { --stat-accent: #0284c7; background: linear-gradient(135deg, #fff 0%, #f0f9ff 100%); }
.stat-card[data-accent="indigo"] { --stat-accent: #4f46e5; background: linear-gradient(135deg, #fff 0%, #eef2ff 100%); }

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

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--muted);
}

.stat-card[data-accent="violet"] .stat-value { color: #7c3aed; }
.stat-card[data-accent="amber"] .stat-value { color: #d97706; }
.stat-card[data-accent="emerald"] .stat-value { color: #059669; }
.stat-card[data-accent="rose"] .stat-value { color: #e11d48; }
.stat-card[data-accent="sky"] .stat-value { color: #0284c7; }
.stat-card[data-accent="indigo"] .stat-value { color: #4f46e5; }

/* ── Cards ── */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: visible;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s;
}

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

.table-card {
    overflow: hidden;
    margin-bottom: 0;
}

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

.card:has(> .data-table) {
    overflow-x: auto;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.375rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
}

.card-header h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--foreground);
}

.card-count {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.125rem;
}

.card-body { padding: 1.375rem; }

.card-footer {
    padding: 1rem 1.375rem;
    border-top: 1px solid var(--border);
    background: #fafafa;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-2 .card {
    margin-bottom: 0;
    height: 100%;
}

.quick-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Tables ── */

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

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

table.data-table th {
    text-align: left;
    padding: 0.75rem 1.25rem;
    background: #fafafa;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    color: #3f3f46;
    vertical-align: middle;
}

table.data-table tbody tr {
    transition: background 0.1s;
}

table.data-table tbody tr:hover td {
    background: #fafafa;
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

table.data-table td strong {
    font-weight: 600;
    color: var(--foreground);
}

/* ── Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-gray { background: #f4f4f5; color: #52525b; border-color: #e4e4e7; }
.badge-blue { background: var(--info-bg); color: #1d4ed8; border-color: var(--info-border); }
.badge-green { background: var(--success-bg); color: #15803d; border-color: var(--success-border); }
.badge-amber { background: var(--warning-bg); color: #b45309; border-color: var(--warning-border); }
.badge-red { background: var(--danger-bg); color: #b91c1c; border-color: var(--danger-border); }
.badge-purple { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-teal { background: #f0fdfa; color: #0f766e; border-color: #99f6e4; }
.badge-pink { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    line-height: 1.25;
}

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
}

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

.btn-green {
    background: var(--success);
    color: #fff;
}

.btn-green:hover { background: #15803d; }

.btn-red {
    background: var(--danger);
    color: #fff;
}

.btn-red:hover { background: #b91c1c; }

.btn-amber {
    background: var(--warning);
    color: #fff;
}

.btn-amber:hover { background: #b45309; }

.btn-outline {
    border-color: var(--border);
    color: #3f3f46;
    background: var(--card);
}

.btn-outline:hover {
    background: var(--muted-bg);
    border-color: var(--border-strong);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ── Forms & inputs ── */

.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-bar form,
.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea,
.search-bar input,
select.filter,
.modal input,
.modal select,
.modal textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--card);
    color: var(--foreground);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form { display: inline; }

a.table-link {
    color: var(--foreground);
    text-decoration: none;
    font-weight: 500;
}

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

.search-bar input { width: 12.5rem; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--ring);
}

select.filter { width: auto; min-width: 7rem; }

label,
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #3f3f46;
    margin-bottom: 0.375rem;
}

.form-field { margin-bottom: 0.875rem; }

.form-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.form-row > * { flex: 1; min-width: 0; }

.form-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #52525b;
    margin: 1rem 0 0.625rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.form-error {
    display: none;
    color: var(--danger);
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-md);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.375rem;
    max-width: 40rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.setting-row:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.setting-row-title {
    font-size: 0.875rem;
    font-weight: 600;
}

.setting-row-desc {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.125rem;
}

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

.text-desc {
    font-size: 0.8125rem;
    color: #52525b;
    line-height: 1.6;
    max-width: 40rem;
    margin-bottom: 1rem;
}

code,
.code {
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: var(--muted-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: #3f3f46;
}

.cell-truncate {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Modals ── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    min-width: min(100%, 28rem);
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    width: 100%;
}

.modal h3 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 1.25rem;
}

/* ── Empty & pagination ── */

.empty {
    text-align: center;
    color: var(--muted);
    padding: 3rem 1.5rem;
    font-size: 0.8125rem;
}

.pagination {
    display: flex;
    gap: 0.25rem;
    padding: 0.875rem 1.375rem;
    font-size: 0.8125rem;
    justify-content: center;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    background: linear-gradient(to bottom, #fafafa 0%, #ffffff 100%);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-md);
    background: var(--card);
    border: 1px solid var(--border);
    color: #52525b;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.1s;
}

.pagination a:hover { background: var(--muted-bg); }

.pagination .active,
.pagination .current,
.pagination span[aria-current="page"] span {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ── Login page ── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(24, 24, 27, 0.06), transparent),
        var(--background);
}

.login-wrap { width: 100%; max-width: 24rem; }

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand .icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-fg);
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.login-brand p {
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 0.375rem;
}

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.login-card .field { margin-bottom: 1.25rem; }

.login-card .check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #52525b;
    margin-bottom: 1.5rem;
}

.form-check-wrap {
    display: flex;
    align-items: flex-end;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    padding-bottom: 0.375rem;
}

.form-check input { width: auto; }

.login-card .check label { margin-bottom: 0; }

.login-card button[type="submit"] {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.login-card button[type="submit"]:hover { background: var(--primary-hover); }

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--danger-border);
}

.login-back {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--muted);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color 0.15s;
}

.login-back:hover { color: var(--foreground); }

/* ── Responsive ── */

@media (max-width: 1200px) {
    .page-layout.has-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }

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

    .sidebar-backdrop.open { display: block; }

    .admin-main { margin-left: 0; }

    .menu-toggle { display: flex; }

    .topbar-sub { display: block; }

    .topbar h2 { font-size: 0.875rem; }

    .user-name { display: none; }

    .content { padding: 1rem; }

    .page-header h3 { font-size: 1.25rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .search-bar input { width: 100%; min-width: 0; }

    .setting-row {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }

    table.data-table th,
    table.data-table td {
        padding: 0.625rem 0.875rem;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
