@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap');

:root {
    --ink: #1f2937; /* Clean Slate Gray */
    --muted: #6b7280; /* Warm gray 500 */
    --page: #f8faf9; /* Super clean light paper */
    --panel: #ffffff;
    --line: #e5e8e6; /* Soft natural borders */
    --green: #10b981; /* High-brightness emerald */
    --green-dark: #047857; /* Deep academic green */
    --gold: #d97706; /* Radiant brand gold */
    --danger: #ef4444; /* Alert red */
    --warning: #f59e0b;
    --soft-green: #ecfdf5; /* Tailwind Emerald 50 */
    --soft-gold: #fffbeb; /* Tailwind Amber 50 */
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
    --font-family: "Plus Jakarta Sans", Inter, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-family);
    background: var(--page);
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Admin shell & Grid */
.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    border-right: 1px solid var(--line);
    background: #041210; /* Prestigious Dark Sidebar */
    color: #ffffff;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.admin-brand strong {
    display: block;
    font-size: 1.1rem;
    color: #ffffff;
}

.admin-brand small {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.8rem;
    font-weight: 600;
}

.admin-brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, var(--green-dark), var(--green) 62%, var(--gold));
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.25);
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-list a {
    padding: 12px 16px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 700;
    transition: all 150ms ease;
}

.nav-list a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-list a.active {
    color: #ffffff;
    background: var(--green);
    box-shadow: 0 8px 18px rgba(16, 185, 129, 0.3);
}

.admin-main {
    min-width: 0;
    padding: 44px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 24px;
}

.admin-eyebrow {
    margin: 0 0 4px;
    color: var(--green-dark);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

h1,
h2 {
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h1 {
    font-size: 2.1rem;
    font-weight: 800;
}

h2 {
    font-size: 1.35rem;
    font-weight: 800;
}

.panel {
    margin-bottom: 28px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel.narrow {
    max-width: 760px;
}

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

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

.stat-grid.compact {
    margin-top: 12px;
}

.portal-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.portal-control h2 {
    margin-top: 4px;
}

.portal-control .muted {
    max-width: 680px;
    margin: 8px 0 0;
}

.portal-status-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    margin-bottom: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.12);
    background: var(--green);
}

.portal-control.is-closed {
    border-color: rgba(239, 68, 68, 0.22);
    background: linear-gradient(180deg, #fff7f7, #ffffff);
}

.portal-control.is-closed .portal-status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.12);
}

.portal-toggle-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-card {
    min-height: 120px;
    display: grid;
    align-content: space-between;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
    transition: transform 200ms ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.stat-card strong {
    font-size: 2.3rem;
    line-height: 1;
    font-weight: 800;
}

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 800;
    white-space: nowrap;
    transition: all 150ms ease;
}

.button.primary {
    color: #fff;
    background: var(--green-dark);
    box-shadow: 0 4px 10px rgba(4, 120, 87, 0.15);
}

.button.primary:hover {
    background: #025940;
    box-shadow: 0 6px 14px rgba(4, 120, 87, 0.25);
}

.button.secondary {
    color: var(--green-dark);
    border-color: rgba(4, 120, 87, 0.15);
    background: var(--soft-green);
}

.button.secondary:hover {
    background: #d1fae5;
}

.button.ghost {
    color: var(--ink);
    border-color: var(--line);
    background: #fff;
}

.button.ghost:hover {
    background: var(--page);
}

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

.button.danger:hover {
    background: #dc2626;
}

.button.tiny {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.alert {
    margin-bottom: 18px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-weight: 700;
}

.alert.success {
    color: var(--green-dark);
    border-color: rgba(16, 185, 129, 0.25);
    background: var(--soft-green);
}

.alert.error {
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.25);
    background: #fef2f2;
}

.alert.warning {
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.25);
    background: var(--soft-gold);
}

.muted {
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 18px;
}

.stack-form label,
.toolbar-form {
    display: grid;
    gap: 6px;
}

.stack-form label span {
    color: var(--ink);
    font-weight: 750;
    font-size: 0.95rem;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
    outline: none;
    transition: all 150ms ease;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.check-row {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 20px;
    min-height: 20px;
}

.form-actions,
.action-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.toolbar-form {
    grid-template-columns: minmax(180px, 1fr) auto auto;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--page);
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge.selected {
    color: var(--green-dark);
    background: var(--soft-green);
}

.badge.not_selected {
    color: #991b1b;
    background: #fef2f2;
}

.badge.viewed {
    color: #075f59;
    background: #ccfbf1;
}

.badge.not_viewed {
    color: #6b7280;
    background: #f3f4f6;
}

.table-note {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

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

.detail-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 750;
}

/* Login styling overrides */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 10% 10%, rgba(16, 185, 129, 0.08), transparent 30rem),
        linear-gradient(135deg, #f3f6f5, #f8fbf7);
}

.login-shell {
    width: min(100%, 460px);
}

.login-card {
    padding: 40px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.06);
}

.login-card .admin-brand-mark {
    margin-bottom: 24px;
}

/* Media Queries */
@media (max-width: 900px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-main {
        padding: 24px;
    }

    .topbar,
    .panel-header,
    .portal-control {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .portal-toggle-form {
        width: 100%;
        justify-content: flex-start;
    }

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

@media (max-width: 560px) {
    .nav-list {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .toolbar-form {
        grid-template-columns: 1fr;
    }

    .detail-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Premium admin refinements */
:root {
    --admin-bg: #030b0f;
    --admin-panel: rgba(4, 17, 22, 0.94);
    --admin-line: rgba(255, 255, 255, 0.08);
    --admin-text: #e2e8f0;
    --admin-muted: #94a3b8;
    --admin-surface: rgba(255, 255, 255, 0.03);
}

body {
    background: radial-gradient(circle at 20% 10%, rgba(45, 212, 191, 0.12), transparent 28rem),
                radial-gradient(circle at 80% 12%, rgba(251, 191, 36, 0.08), transparent 22rem),
                linear-gradient(180deg, #030b0f 0%, #020708 100%);
    color: var(--admin-text);
}

.sidebar {
    background: linear-gradient(180deg, #071f22 0%, #041215 100%);
    border-color: rgba(255, 255, 255, 0.06);
}

.admin-brand strong {
    color: #f8fafc;
}

.admin-brand small {
    color: rgba(248, 250, 252, 0.65);
}

.nav-list a {
    background: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
}

.nav-list a:hover,
.nav-list a.active {
    color: #ffffff;
    background: linear-gradient(135deg, #14b8a6, #22c55e 80%);
    box-shadow: 0 16px 34px rgba(20, 184, 166, 0.22);
}

.admin-main {
    background: transparent;
}

.panel {
    background: var(--admin-panel);
    border-color: var(--admin-line);
    box-shadow: 0 35px 90px rgba(0, 0, 0, 0.35);
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.portal-control {
    background: linear-gradient(180deg, rgba(4, 17, 22, 0.96), rgba(6, 24, 28, 0.94));
    border-color: rgba(45, 212, 191, 0.18);
    box-shadow: 0 35px 90px rgba(0, 0, 0, 0.32);
}

.portal-control.is-closed {
    border-color: rgba(248, 113, 113, 0.32);
    background: linear-gradient(180deg, rgba(35, 12, 15, 0.96), rgba(12, 19, 22, 0.94));
}

.portal-control .muted {
    color: var(--admin-muted);
}

.portal-toggle-form .button.ghost {
    background: rgba(255, 255, 255, 0.04);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
}

.button.primary {
    background: linear-gradient(135deg, #14b8a6, #22c55e);
    box-shadow: 0 18px 42px rgba(20, 184, 166, 0.22);
}

.button.secondary {
    color: #d9f99d;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.button.ghost {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.alert.success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.25);
}

.alert.error,
.alert.warning {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

input,
select,
textarea {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

textarea {
    background: rgba(255, 255, 255, 0.04);
}

input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.12);
}

.table-wrap {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

table {
    background: transparent;
}

th,
td {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.08);
}

th {
    background: rgba(255, 255, 255, 0.03);
}

.badge.selected {
    color: #0f172a;
    background: rgba(16, 185, 129, 0.18);
}

.badge.not_selected {
    color: #fef2f2;
    background: rgba(248, 113, 113, 0.18);
}

.badge.viewed {
    color: #ccfbf1;
    background: rgba(20, 184, 166, 0.18);
}

.badge.not_viewed {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.16);
}

.table-note {
    color: var(--admin-muted);
}

.detail-list div {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

.login-body {
    background: linear-gradient(180deg, #081216 0%, #010405 100%);
}

.login-card {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(7, 17, 22, 0.96);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.login-card .admin-brand-mark {
    background: linear-gradient(135deg, #14b8a6, #22c55e 62%, #fbbf24);
}
