:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #0b1f2f;
    --muted: #55697a;
    --brand: #006d77;
    --brand-dark: #004f56;
    --ok: #2f855a;
    --warn: #d97706;
    --bad: #b42318;
    --border: #d5dde5;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--text);
    background: #f5f7fb;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { background: #0b1f2f; color: #fff; padding: 24px 18px; }
.brand { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; }
.nav-links { display: grid; gap: 8px; }
.nav-links a {
    color: #dbe8f4;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-links a:hover { background: rgba(255,255,255,0.12); }
.nav-links a.is-active {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.nav-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: currentColor;
}
.logout-form { margin-top: 20px; }
.logout-form button { width: 100%; }

.main-content { padding: 24px; }
.topbar h1 { margin: 0; }
.topbar small { color: var(--muted); }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.88rem; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
}
button {
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}
button:hover { background: var(--brand-dark); }
.btn-muted { background: #5d6f7f; }
.btn-secondary { background: #44586b; }
.btn-secondary:hover { background: #33485d; }
a.btn-secondary, a.btn-muted {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    padding: 10px 14px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); }

.status-complete { color: var(--ok); font-weight: 600; }
.status-incomplete { color: var(--warn); font-weight: 600; }
.status-live { color: #005f73; font-weight: 600; }
.status-draft { color: #7c3aed; font-weight: 600; }
.status-unlisted { color: #6b7280; font-weight: 600; }
.status-review { color: #b42318; font-weight: 700; }

.flash-error, .flash-success { margin-top: 12px; border-radius: 10px; padding: 12px; font-size: 0.92rem; }
.flash-error { background: #fdecec; color: var(--bad); border: 1px solid #f8c9c9; }
.flash-success { background: #e9f7ef; color: var(--ok); border: 1px solid #c7e9d2; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { background: #f7fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.metric strong { display: block; font-size: 1.1rem; }
.metric-link { text-decoration: none; color: inherit; display: block; }
.metric-link:hover .metric { border-color: var(--brand); }

.action-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}
.action-list .metric {
    height: 100%;
}
.subtle {
    color: var(--muted);
    font-size: 0.84rem;
}

.auth-body { min-height: 100vh; display: grid; place-items: center; background: #0f2d42; }
.auth-wrap { width: min(520px, 92vw); }
.auth-card { background: #fff; border-radius: 16px; padding: 22px; }
.auth-card h1 { margin-top: 0; margin-bottom: 16px; }
.muted { color: var(--muted); font-size: 0.9rem; }

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

.panel-header-row h2,
.panel-header-row h3 {
    margin: 0;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: #f4f8fc;
}

.clickable-row:focus {
    outline: 2px solid rgba(0, 109, 119, 0.28);
    outline-offset: -2px;
}

.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 24, 39, 0.58);
}

.modal-dialog {
    position: relative;
    width: min(940px, 94vw);
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

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

.modal-header h3 {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.searchable-select-wrap {
    display: grid;
    gap: 8px;
}

.select-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.9rem;
    background: #fff;
}

.select-search-input:focus {
    outline: 2px solid rgba(0, 109, 119, 0.2);
    border-color: var(--brand);
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .action-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-header-row { flex-direction: column; align-items: flex-start; }
    .panel-header-actions { width: 100%; }
}
