/* =========================================================
   Public Data — admin template
   ========================================================= */
:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e4e7ef;
    --text: #1d2433;
    --text-2: #4b5468;
    --muted: #8a92a6;
    --primary: #5b5bd6;
    --primary-600: #4a48c4;
    --primary-soft: #eeeefc;
    --accent: #06b6d4;
    --success: #12a150;
    --success-soft: #e6f6ed;
    --danger: #dc3545;
    --danger-soft: #fdecee;
    --warning: #c47f0a;
    --warning-soft: #fdf4e3;
    --info: #0b84c6;
    --info-soft: #e6f3fb;
    --sidebar: #141a2b;
    --sidebar-2: #1c2338;
    --sidebar-text: #a7afc4;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(20, 26, 43, .04), 0 4px 16px rgba(20, 26, 43, .05);
    --shadow-lg: 0 20px 50px rgba(20, 26, 43, .18);
    --sidebar-w: 256px;
    --sidebar-mini: 78px;
    --topbar-h: 64px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; color: var(--text); }
p { margin: 0; }
small, .text-muted { color: var(--muted); }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w);
    display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-text);
    transition: width .2s ease, transform .25s ease;
}
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.content { flex: 1; padding: 28px; width: 100%; max-width: 1400px; margin: 0 auto; }

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 20px; color: #fff; white-space: nowrap; overflow: hidden; }
.brand:hover { color: #fff; }
.brand .logo { flex-shrink: 0; }
.brand-text strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand-text small { display: block; font-size: 11px; color: var(--sidebar-text); margin-top: -2px; }

/* Nav */
.nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }
.nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: #5f6880; padding: 16px 12px 8px; white-space: nowrap; }
.nav-link {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--sidebar-text); font: inherit; font-weight: 500; text-align: left; cursor: pointer; white-space: nowrap;
}
.nav-link:hover { background: var(--sidebar-2); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(91, 91, 214, .35); }
.nav-link .chevron { margin-left: auto; width: 16px; height: 16px; transition: transform .2s; }
.nav-group.open > .nav-link .chevron { transform: rotate(180deg); }
.nav-group.open > .nav-link:not(.active) { color: #fff; }
.nav-sub { display: none; margin: 4px 0 6px 21px; padding-left: 14px; border-left: 1px solid #2c3550; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--sidebar-text); font-size: 13.5px; white-space: nowrap; }
.nav-sub a:hover { color: #fff; background: var(--sidebar-2); }
.nav-sub a.active { color: #fff; font-weight: 600; }
.nav-sub a.active::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: -17px; margin-right: 5px; }

.sidebar-foot { padding: 14px; border-top: 1px solid #222a40; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--sidebar-2); overflow: hidden; }
.sidebar-user .who { min-width: 0; flex: 1; }
.sidebar-user .who strong { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who small { color: var(--sidebar-text); font-size: 11.5px; }
.sidebar-user .logout { color: var(--sidebar-text); padding: 6px; border-radius: 8px; display: flex; }
.sidebar-user .logout:hover { color: #fff; background: #2a3350; }

/* Mini (collapsed) sidebar on desktop */
@media (min-width: 992px) {
    .sidebar-mini .sidebar { width: var(--sidebar-mini); }
    .sidebar-mini .main { margin-left: var(--sidebar-mini); }
    .sidebar-mini .sidebar:not(:hover) .brand-text,
    .sidebar-mini .sidebar:not(:hover) .nav-text,
    .sidebar-mini .sidebar:not(:hover) .nav-label,
    .sidebar-mini .sidebar:not(:hover) .chevron,
    .sidebar-mini .sidebar:not(:hover) .nav-sub,
    .sidebar-mini .sidebar:not(:hover) .sidebar-user .who,
    .sidebar-mini .sidebar:not(:hover) .sidebar-user .logout { display: none; }
    .sidebar-mini .sidebar:not(:hover) .nav-link { justify-content: center; }
    .sidebar-mini .sidebar:not(:hover) .sidebar-user { justify-content: center; background: none; }
    .sidebar-mini .sidebar:not(:hover) .brand { padding: 0 19px; }
    .sidebar-mini .sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
}

/* Off-canvas sidebar on tablets / phones */
.backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; }
    .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 20, 35, .5); backdrop-filter: blur(2px); }
    .sidebar-open { overflow: hidden; }
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 28px;
    background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); cursor: pointer; }
.topbar-toggle:hover { color: var(--primary); border-color: #cfd2f5; }
.topbar-toggle .icon-panel { display: none; }
@media (min-width: 992px) { .topbar-toggle .icon-menu { display: none; } .topbar-toggle .icon-panel { display: inline; } }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.crumbs a { color: var(--muted); display: inline-flex; }
.crumbs a:hover { color: var(--primary); }
.crumbs .icon { width: 15px; height: 15px; }
.crumbs .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Avatar + dropdown */
.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .3px;
}
.avatar-lg { width: 46px; height: 46px; font-size: 16px; }
.dropdown { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 40px; background: none; font: inherit; color: var(--text); cursor: pointer; }
.user-btn:hover, .dropdown.open .user-btn { background: var(--surface); border-color: var(--border); }
.user-btn .meta { text-align: left; line-height: 1.2; }
.user-btn .meta strong { display: block; font-size: 13.5px; font-weight: 600; }
.user-btn .meta small { font-size: 11.5px; }
.user-btn .chevron { width: 15px; height: 15px; color: var(--muted); }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: 8px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .15s ease;
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown-head { display: flex; gap: 12px; align-items: center; padding: 10px 10px 14px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: 14px; }
.dropdown-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.dropdown-menu a:hover { background: var(--surface-2); color: var(--primary); }
.dropdown-menu a.danger:hover { color: var(--danger); background: var(--danger-soft); }
@media (max-width: 575.98px) { .user-btn .meta, .user-btn .chevron { display: none; } .topbar { padding: 0 14px; } }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; letter-spacing: -.3px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 16px; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 22px; margin-bottom: 22px; }
.grid-2 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 991.98px) { .grid-2 { grid-template-columns: 1fr; } }
.grid > .card { margin-bottom: 0; }

/* Welcome banner */
.hero {
    position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 26px 28px; margin-bottom: 22px; border-radius: var(--radius); color: #fff;
    background: linear-gradient(120deg, #4f46e5 0%, #5b5bd6 45%, #06b6d4 100%);
}
.hero::after {
    content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
    background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 28px 28px;
    mask-image: linear-gradient(90deg, transparent 30%, #000); -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000);
}
.hero h1 { color: #fff; font-size: 22px; }
.hero p { opacity: .85; margin-top: 4px; }
.hero > * { position: relative; z-index: 1; }
.hero-date { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 30px; background: rgba(255, 255, 255, .16); font-size: 13px; font-weight: 500; white-space: nowrap; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
@media (max-width: 1199.98px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-icon { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.stat-label { color: var(--muted); font-size: 13px; }
.tone-primary { background: var(--primary-soft); color: var(--primary); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info { background: var(--info-soft); color: var(--info); }
@media (max-width: 575.98px) {
    .stats { gap: 12px; }
    .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
    .stat-value { font-size: 22px; }
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 22px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item small { font-size: 12.5px; }
.list-item .end { text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.action-tile { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); margin-bottom: 10px; transition: .15s; }
.action-tile:last-child { margin-bottom: 0; }
.action-tile:hover { border-color: #cfd2f5; background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.action-tile .stat-icon { width: 40px; height: 40px; border-radius: 11px; }
.action-tile strong { display: block; font-weight: 600; }
.action-tile small { font-size: 12.5px; }
.action-tile > .icon:last-child { margin-left: auto; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
    border: 1px solid transparent; border-radius: 10px; font: inherit; font-weight: 600; font-size: 14px; line-height: 1;
    cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(91, 91, 214, .28); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-light { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-light:hover { border-color: #cfd2f5; color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c22a39; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 48px; font-size: 15px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: .15s;
}
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--primary); border-color: #cfd2f5; background: var(--primary-soft); }
.icon-btn.danger:hover { color: var(--danger); border-color: #f6c4ca; background: var(--danger-soft); }
.icon-btn.success:hover { color: var(--success); border-color: #b9e4ca; background: var(--success-soft); }
.actions { display: inline-flex; gap: 6px; }
.actions form { display: inline; margin: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: center; gap: 12px; padding: 13px 16px; margin-bottom: 20px; border-radius: 12px; border: 1px solid; font-weight: 500; animation: drop .25s ease; }
.alert span { flex: 1; }
.alert-success { background: var(--success-soft); border-color: #bfe6cf; color: #0c7a3c; }
.alert-danger { background: var(--danger-soft); border-color: #f6c4ca; color: #b42332; }
.alert-warning { background: var(--warning-soft); border-color: #f1dbad; color: #976105; }
.alert-close { display: flex; padding: 4px; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; border-radius: 6px; }
.alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.alert.hide { opacity: 0; transform: translateY(-6px); transition: .3s; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 22px; }
@media (max-width: 767.98px) { .form-grid { grid-template-columns: 1fr; } }
.form-section { display: flex; align-items: center; gap: 10px; margin: 28px 0 16px; font-size: 14px; font-weight: 650; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-section small { font-weight: 400; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field label .req { color: var(--danger); }
.hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.field-error { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; font-weight: 500; color: var(--danger); }
.field-error .icon { width: 14px; height: 14px; }
.input {
    display: block; width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; appearance: none;
}
.input::placeholder { color: #a9afbf; }
.input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(91, 91, 214, .14); }
.input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 4px rgba(220, 53, 69, .12); }
select.input { padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-left: 42px; }
.input-wrap .input.has-toggle { padding-right: 46px; }
.pw-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: flex; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--primary); background: var(--primary-soft); }
.pw-toggle .icon-eye-off, .pw-toggle.on .icon-eye { display: none; }
.pw-toggle.on .icon-eye-off { display: inline; }
.input-lg { height: 50px; }
.form-actions { display: flex; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
@media (max-width: 575.98px) { .form-actions { flex-direction: column-reverse; } .form-actions .btn { width: 100%; } }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 22px; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row .icon { width: 15px; height: 15px; color: var(--muted); }

/* ---------- Tables ---------- */
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.table-toolbar .input-wrap { flex: 1; max-width: 320px; }
.table-toolbar .input { height: 40px; }
.table-toolbar .page-size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.table-toolbar .page-size .input { width: 84px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 12px 22px; text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbff; }
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]:hover { color: var(--text); }
.table th[data-sort]::after { content: "\2195"; margin-left: 6px; opacity: .35; }
.table th[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; color: var(--primary); }
.table th[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--primary); }
.table .empty td { text-align: center; padding: 40px 20px; color: var(--muted); }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user strong { display: block; font-weight: 600; }
.cell-user small { font-size: 12.5px; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pager { display: flex; gap: 4px; }
.pager button { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.pager button:hover:not(:disabled) { border-color: #cfd2f5; color: var(--primary); }
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager .gap { padding: 0 4px; line-height: 34px; }
.pager .icon { width: 16px; height: 16px; }

/* Tables become cards on tablets / phones */
@media (max-width: 991.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-stack tbody tr:hover td { background: none; }
    .table-stack td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
    .table-stack td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; }
    .table-stack td.primary-cell { justify-content: flex-start; text-align: left; padding-bottom: 10px; }
    .table-stack td.primary-cell::before { display: none; }
    .table-stack .empty td::before { display: none; }
    .table-stack .empty td { justify-content: center; }
    .table-toolbar, .table-foot { padding: 14px 16px; }
    .table-toolbar .input-wrap { max-width: none; flex-basis: 100%; }
    .table-foot { justify-content: center; text-align: center; }
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 20, 35, .5); backdrop-filter: blur(2px); }
.modal.show { display: flex; }
.modal-box { width: 100%; max-width: 420px; padding: 26px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); text-align: center; animation: pop .18s ease; }
.modal-box .stat-icon { margin: 0 auto 14px; }
.modal-box h3 { font-size: 18px; margin-bottom: 6px; }
.modal-box p { color: var(--text-2); }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* ---------- Footer ---------- */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; padding: 18px 28px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- Empty / 404 ---------- */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state .stat-icon { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; }
.empty-state .stat-icon .icon { width: 30px; height: 30px; }
.empty-state h2 { font-size: 22px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin-bottom: 22px; }

@media (max-width: 767.98px) {
    .content { padding: 18px 14px; }
    .page-head { margin-bottom: 16px; align-items: flex-start; }
    .page-head h1 { font-size: 20px; }
    .page-actions, .page-actions .btn { width: 100%; }
    .card-head, .card-body { padding: 16px; }
    .list-item { padding: 12px 16px; }
    .hero { flex-direction: column; align-items: flex-start; padding: 22px 20px; }
    .footer { padding: 16px 14px; justify-content: center; text-align: center; }
    body { font-size: 15px; }
}

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.auth-box { width: 100%; max-width: 400px; padding: 36px 32px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; font-size: 18px; }
.auth-box h1 { font-size: 22px; text-align: center; }
.auth-box > p { color: var(--muted); text-align: center; margin: 4px 0 24px; }
.auth-box .field { margin-bottom: 18px; }
.auth-box .btn { margin-top: 6px; }
.auth-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: 12.5px; color: var(--muted); }
@media (max-width: 479.98px) { .auth-box { padding: 28px 20px 20px; } }

/* ---------- Booths & allocation ---------- */
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-sm .icon { width: 16px; height: 16px; }
.narrow { max-width: 560px; }
.field.stacked { margin-bottom: 18px; }
.card-head p .icon { width: 14px; height: 14px; margin-top: -2px; }
.card-head h2 .badge { margin-left: 6px; vertical-align: middle; }
.booth-no {
    min-width: 42px; height: 36px; padding: 0 8px; border-radius: 10px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: var(--info-soft); color: var(--info); font-weight: 700; font-size: 13px; letter-spacing: .2px;
}
.booth-no-lg { min-width: 54px; height: 48px; font-size: 16px; border-radius: 13px; }
.cell-user strong .badge { margin-left: 6px; vertical-align: middle; }
.count-link { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; background: var(--primary-soft); font-weight: 600; font-size: 13px; }
.count-link .icon { width: 15px; height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.chip-more { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

.check-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.check-toolbar .input-wrap { flex: 1; max-width: 340px; }
.check-toolbar .input { height: 40px; }
.check-count { font-size: 13px; color: var(--muted); }
.check-count strong { color: var(--primary); font-size: 15px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 10px; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: .15s; }
.check-item:hover { border-color: #cfd2f5; background: var(--surface-2); }
.check-item input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }
.check-item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check-item .grow { flex: 1; min-width: 0; }
.check-item strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check-item small { font-size: 12.5px; }
.check-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.check-item[hidden] { display: none; }

.details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin: 0; }
.details dt { font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 4px 0 0; font-weight: 600; }
@media (max-width: 575.98px) {
    .details { grid-template-columns: 1fr; gap: 14px; }
    .check-list { grid-template-columns: 1fr; }
    .check-toolbar .input-wrap { max-width: none; flex-basis: 100%; }
    .chips { justify-content: flex-end; }
}
.booth-no-sm { min-width: 0; height: 26px; padding: 0 10px; font-size: 12.5px; border-radius: 20px; }

/* ---------- Voters ---------- */
[lang="te"] { font-family: "Noto Sans Telugu", var(--font); }
html[data-lang="en"] .te { display: none !important; }
html[data-lang="te"] .en { display: none !important; }
.block { display: block; }
.voters-table strong.en, .voters-table strong.te { display: block; }
html[data-lang="both"] .voters-table strong.te { font-weight: 500; color: var(--text-2); font-size: .95em; }
html[data-lang="both"] .voters-table .block.te { color: var(--text-2); font-size: .95em; }
.voters-table .badge { margin-top: 4px; }
.lang-bar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px 0; font-size: 13px; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(20, 26, 43, .12); }
.serial { display: inline-block; min-width: 34px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-weight: 700; text-align: center; font-size: 13px; }
.epic { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; letter-spacing: .3px; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px; padding: 16px 22px; }
.filter-bar .field { flex: 1; min-width: 240px; max-width: 420px; }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--text-2); cursor: pointer; min-height: 44px; }
.check-inline input { width: 18px; height: 18px; accent-color: var(--primary); }
@media (max-width: 767.98px) {
    .lang-bar { justify-content: space-between; padding: 14px 16px 0; }
    .filter-bar { padding: 14px 16px; }
    .filter-bar .field { max-width: none; }
    .table-stack td .block { display: inline; }
    html[data-lang="both"] .table-stack td .block.te::before { content: " / "; }
}

/* Voter table: keep the Actions column pinned to the right while the other columns scroll */
@media (min-width: 992px) {
    .voters-table th:last-child,
    .voters-table td:last-child { position: sticky; right: 0; z-index: 1; text-align: center; box-shadow: inset 1px 0 0 var(--border), -8px 0 12px -10px rgba(20, 26, 43, .25); }
    .voters-table th:last-child { background: var(--surface-2); }
    .voters-table td:last-child { background: var(--surface); }
    .voters-table tbody tr:hover td:last-child { background: #fafbff; }
}

/* Voter table headers: Telugu title on its own line under the English one */
.voters-table th .th-te { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); }
.voters-table th { vertical-align: top; }
.voters-table th[data-sort] { position: relative; padding-right: 30px; }
.voters-table th[data-sort]::after { position: absolute; top: 12px; right: 12px; margin-left: 0; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline; }
.card-head.filter-bar { justify-content: flex-start; padding: 16px 22px; }
@media (max-width: 767.98px) { .card-head.filter-bar { padding: 14px 16px; } }
.card-head.filter-bar { justify-content: flex-start; padding: 16px 22px; }
@media (max-width: 767.98px) { .card-head.filter-bar { padding: 14px 16px; } }

/* Dashboard */
.section-title { font-size: 13px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin: 4px 0 12px; }
a.stat-link { color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; }
a.stat-link:hover { color: var(--text); border-color: #cfd2f5; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20, 26, 43, .08); }
.grid-even { grid-template-columns: 1fr 1fr; }
@media (max-width: 991.98px) { .grid-even { grid-template-columns: 1fr; } }

/* Settings */
.narrow-lg { max-width: 760px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 4px 0 18px; cursor: pointer; }
.switch-row strong { display: block; font-size: 15px; }
.switch-row small { display: block; margin-top: 4px; color: var(--muted); max-width: 520px; }
.switch { position: relative; flex-shrink: 0; width: 50px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 28px; background: #cfd3de; transition: background .2s; pointer-events: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.device-stats { margin-bottom: 14px; }
.notes { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13.5px; }
.notes li { margin-bottom: 6px; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 16px; border: 1px solid #f6c4ca; border-radius: 12px; background: #fffafa; }
.danger-zone strong { display: block; }
.danger-zone small { color: var(--muted); }
.device-cell small { display: block; font-size: 12px; color: var(--muted); }

/* ---------- Reports ---------- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.report-grid .action-tile { margin-bottom: 0; background: var(--surface); align-items: flex-start; padding: 18px; }
.report-grid .action-tile small { display: block; margin-top: 3px; line-height: 1.45; }
.report-grid .action-tile > .icon:last-child { align-self: center; }
@media (max-width: 479.98px) { .report-grid { grid-template-columns: 1fr; } }
.report-table .num { text-align: right; white-space: nowrap; }
.report-table th.num { text-align: right; }
.report-table tfoot td { padding: 14px 22px; border-top: 2px solid var(--border); background: var(--surface-2); font-weight: 700; }
.report-table.compact th, .report-table.compact td { padding-left: 14px; padding-right: 14px; }
.report-table tr.row-alt td { background: var(--surface-2); }
.report-table .cell-user { min-width: 220px; }
.bar-col { min-width: 180px; }
.bar-col small { display: inline-block; min-width: 44px; text-align: right; }
.bar { display: inline-block; width: calc(100% - 52px); height: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 10px; }
.preset-chips { margin: -6px 0 18px; }
.preset-chips .chip { padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface); }
.preset-chips .chip:hover { border-color: #cfd2f5; color: var(--primary); }
.preset-chips .chip-active, .preset-chips .chip-active:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-warn { background: var(--warning-soft); border-color: transparent; color: var(--warning); font-size: 12px; }
.text-warning { color: var(--warning); }
.filter-bar .field.field-sm { flex: 0 1 170px; min-width: 140px; }
.filter-bar .field.field-xs { flex: 0 1 110px; min-width: 90px; }
.filter-bar > .btn { height: 44px; }
.input-static { display: flex; align-items: center; background: var(--surface-2); color: var(--text-2); }
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.member { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 20px; color: var(--text); font-size: 13px; }
.member:hover { border-color: #cfd2f5; color: var(--primary); }
.member .serial { min-width: 0; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; }
.member small { font-size: 11.5px; }
html[data-lang="both"] .member .te { color: var(--text-2); }
.page-actions .btn .icon { width: 17px; height: 17px; }

@media print {
    @page { margin: 12mm; }
    body { background: #fff; font-size: 12px; }
    .sidebar, .topbar, .footer, .backdrop, .no-print, .table-toolbar, .table-foot, .lang-bar, .alert, .modal, .icon-btn { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0; max-width: none; }
    .card, .stat { box-shadow: none; break-inside: avoid; }
    .card { border-color: #ccc; }
    .table-scroll { overflow: visible; }
    .table th, .table td { padding: 6px 8px; }
    .stats { grid-template-columns: repeat(4, 1fr) !important; gap: 8px; }
    .stat { padding: 10px; }
    .stat-icon { display: none; }
    a { color: inherit; }
}

/* Voter filters + server pager */
.voter-filters .field { flex: 1 1 200px; min-width: 180px; max-width: none; }
.voter-filters .filter-actions { display: flex; gap: 10px; align-items: flex-end; }
.table-foot .page-size { display: flex; align-items: center; gap: 8px; }
.table-foot .page-size .input { width: 84px; height: 34px; }
.pager-link { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.pager-link:hover { border-color: #cfd2f5; color: var(--primary); }
.pager-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-link.disabled { opacity: .45; pointer-events: none; }
.ajax-results { transition: opacity .15s; }
.ajax-results.is-loading { opacity: .5; pointer-events: none; }
.voter-filters + .lang-bar { padding-top: 0; }

/* Door No. wise report: blank columns to fill in by hand, a line between houses */
.door-wise-table .fill-col { min-width: 130px; border-left: 1px solid var(--border); }
.door-wise-table .fill-col-wide { min-width: 200px; }
.door-wise-table tr.house-start td { border-top: 2px solid var(--border); }
@media print {
    .door-wise-table { font-size: 10px; }
    .door-wise-table th, .door-wise-table td { padding: 4px 5px; border: 1px solid #999; }
    .door-wise-table tr { break-inside: avoid; }
    .door-wise-table thead { display: table-header-group; }
}

/* Multi-select dropdown (checkbox list inside <details>) */
.multi-select { position: relative; min-width: 280px; }
.multi-select > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; user-select: none; }
.multi-select > summary::-webkit-details-marker { display: none; }
.multi-select > summary .icon { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.multi-select[open] > summary .icon { transform: rotate(180deg); }
.multi-select .ms-panel { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: max(100%, 320px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .14); padding: 10px; }
.multi-select .ms-tools, .multi-select .ms-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.multi-select .ms-tools { padding-bottom: 8px; border-bottom: 1px solid var(--border); justify-content: flex-start; }
.multi-select .ms-foot { padding-top: 8px; border-top: 1px solid var(--border); }
.multi-select .ms-options { max-height: 280px; overflow-y: auto; padding: 6px 0; }
.multi-select .ms-option { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.multi-select .ms-option:hover { background: var(--bg, #f4f5fb); }
.multi-select .ms-option span { flex: 1; }
.multi-select .ms-option small { color: var(--muted); }
@media (max-width: 600px) { .multi-select { min-width: 0; } .multi-select .ms-panel { width: 100%; } }

/* Clickable booth number badges + booth details popup */
button.booth-link { border: 0; cursor: pointer; font-family: inherit; line-height: 1; }
button.booth-link:hover, button.booth-link:focus-visible { filter: brightness(.94); box-shadow: 0 0 0 3px rgba(91, 91, 214, .18); outline: none; }
.booth-modal { position: relative; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; text-align: left; }
.booth-modal-close { position: absolute; top: 14px; right: 14px; }
.booth-modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding-right: 36px; }
.booth-modal-head h3 { margin-bottom: 4px; }
.booth-modal-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 0 0 18px; }
.booth-modal-details dt { font-size: 11.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.booth-modal-details dd { margin: 2px 0 0; font-weight: 600; }
.booth-modal-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.booth-modal-stats div { padding: 10px; border: 1px solid var(--border); border-radius: 10px; text-align: center; }
.booth-modal-stats strong { display: block; font-size: 18px; }
.booth-modal-stats small { color: var(--muted); font-size: 11.5px; }
.booth-modal-users .chips { margin-top: 6px; }
.booth-modal-foot { margin: 14px 0 0; font-size: 12.5px; }
@media (max-width: 520px) { .booth-modal-stats { grid-template-columns: repeat(2, 1fr); } .booth-modal-details { grid-template-columns: 1fr; } }

/* House-wise report: AC Ref of each member, one per line */
.acref-list small { white-space: nowrap; line-height: 1.7; color: var(--text-2); }

/* Multi-line inputs and a field spanning the form grid (voter Remarks) */
textarea.input { height: auto; min-height: 88px; padding-top: 10px; padding-bottom: 10px; line-height: 1.5; resize: vertical; font-family: inherit; }
.form-grid .field-wide { grid-column: span 2; }
@media (max-width: 767.98px) { .form-grid .field-wide { grid-column: auto; } }

/* Buttons inside a report filter bar (House-wise Search / Clear) */
.filter-bar .filter-actions { display: flex; gap: 10px; align-items: flex-end; }
