:root {
    --ink: #14213d;
    --muted: #5c6b7a;
    --line: #d7dee7;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --accent: #1f6f5b;
    --accent-ink: #0f3d32;
    --danger: #9b1c1c;
    --warning: #8a5a00;
    --success: #146c43;
    --sidebar: #102033;
    --sidebar-text: #d9e2ec;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 248px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem 1rem;
    flex-shrink: 0;
}
.sidebar-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.75rem; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { opacity: .7; font-size: .75rem; }
.sidebar-mark, .guest-mark, .profile-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; border-radius: .5rem;
    background: #1f6f5b; color: #fff; font-weight: 700; font-size: .8rem;
}
.sidebar-nav { display: grid; gap: .25rem; }
.sidebar-nav a {
    padding: .65rem .75rem; border-radius: .45rem; color: var(--sidebar-text); opacity: .9;
}
.sidebar-nav a.is-active, .sidebar-nav a:hover:not(.is-disabled) { background: rgba(255,255,255,.08); }
.sidebar-nav a.is-disabled { opacity: .35; cursor: not-allowed; }
.sidebar-section {
    margin-top: 1rem; margin-bottom: .35rem; padding: 0 .75rem;
    font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; opacity: .5;
}

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.admin-topbar h1 { margin: 0; font-size: 1.15rem; }
.admin-content { padding: 1.5rem; }

.profile-menu { position: relative; }
.profile-trigger {
    display: flex; align-items: center; gap: .65rem; border: 1px solid var(--line);
    background: #fff; border-radius: .6rem; padding: .35rem .7rem .35rem .35rem; cursor: pointer;
}
.profile-meta { display: grid; text-align: left; }
.profile-meta strong { font-size: .85rem; }
.profile-meta small { color: var(--muted); font-size: .72rem; }
.profile-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + .4rem); width: 220px;
    background: #fff; border: 1px solid var(--line); border-radius: .6rem; box-shadow: 0 10px 30px rgba(16,32,51,.08);
    overflow: hidden; z-index: 20;
}
.profile-dropdown.is-open { display: block; }
.profile-dropdown-head { padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.profile-dropdown-head strong, .profile-dropdown-head small { display: block; }
.profile-dropdown-head small { color: var(--muted); margin-top: .15rem; }
.profile-logout {
    width: 100%; border: 0; background: transparent; text-align: left;
    padding: .85rem 1rem; cursor: pointer; color: var(--danger);
}
.profile-logout:hover { background: #fff5f5; }

.flash {
    border-radius: .55rem; padding: .85rem 1rem; margin-bottom: 1rem; border: 1px solid;
}
.flash ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.flash-success { background: #e8f8ef; border-color: #b7e4c7; color: var(--success); }
.flash-error { background: #fdecec; border-color: #f2c0c0; color: var(--danger); }
.flash-warning { background: #fff7e6; border-color: #f0d59a; color: var(--warning); }

.dashboard-lead { color: var(--muted); margin: 0 0 1rem; }
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem;
}
.stat-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: .75rem; padding: 1.1rem 1.2rem;
}
.stat-card span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .45rem; }
.stat-card strong { font-size: 1.8rem; }

.admin-guest-body {
    min-height: 100vh; display: grid; place-items: center;
    background:
        radial-gradient(circle at top left, rgba(31,111,91,.12), transparent 40%),
        linear-gradient(160deg, #eef2f6, #f7f8fa 50%, #e9eef3);
}
.guest-shell { width: min(420px, calc(100% - 2rem)); }
.guest-card {
    background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: 1.75rem;
    box-shadow: 0 18px 50px rgba(16,32,51,.08);
}
.guest-brand { margin-bottom: 1.25rem; }
.guest-brand h1 { margin: .75rem 0 .25rem; font-size: 1.35rem; }
.guest-brand p { margin: 0; color: var(--muted); }
.login-form { display: grid; gap: .9rem; }
.login-form label { display: grid; gap: .35rem; font-size: .9rem; }
.login-form input[type="email"],
.login-form input[type="password"] {
    border: 1px solid var(--line); border-radius: .5rem; padding: .7rem .8rem; background: #fff;
}
.remember-row { display: flex !important; align-items: center; gap: .5rem; }
.btn-primary {
    display: inline-flex; justify-content: center; align-items: center;
    border: 0; border-radius: .5rem; padding: .75rem 1rem; background: var(--accent);
    color: #fff; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-ink); }
.error-panel { text-align: center; }
.error-code { font-size: 2.5rem; font-weight: 700; margin: 0; color: var(--accent); }
.error-panel h2 { margin: .35rem 0; }
.error-panel p { color: var(--muted); }
.error-panel .btn-primary { margin-top: 1rem; }

@media (max-width: 860px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar { width: 100%; }
    .profile-meta { display: none; }
}

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .75rem;
}
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
    flex: 1;
}
.filters-grid label,
.form-grid label {
    display: grid;
    gap: .35rem;
    font-size: .9rem;
}
.filters-grid input,
.filters-grid select,
.form-grid input,
.form-grid select,
.form-grid textarea {
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .65rem .75rem;
    background: #fff;
    width: 100%;
}
.filters-actions,
.form-actions,
.preview-actions,
.media-picker-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}
.checkbox-inline {
    display: flex !important;
    align-items: center;
    gap: .5rem;
    padding-top: 1.5rem;
}
.inline-form { display: inline; }

.btn-secondary,
.btn-danger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: .5rem;
    padding: .55rem .85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--line);
    background: #fff;
}
.btn-secondary:hover { background: #f7f9fb; }
.btn-danger {
    border-color: #efc2c2;
    background: #fff5f5;
    color: var(--danger);
}
.btn-danger:hover { background: #fdecec; }

.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .75rem;
    overflow: auto;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th,
.admin-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.admin-table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #fafbfc;
}
.table-meta {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    margin-top: .2rem;
}
.table-empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem !important;
}
.col-actions { white-space: nowrap; width: 1%; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: .2rem .55rem;
    font-size: .72rem;
    font-weight: 600;
    margin-right: .25rem;
    margin-bottom: .25rem;
}
.badge-muted { background: #eef2f6; color: var(--muted); }
.badge-featured { background: #fff7e6; color: var(--warning); }
.badge-status-draft { background: #eef2f6; color: var(--muted); }
.badge-status-in_review { background: #eef4ff; color: #1d4ed8; }
.badge-status-scheduled { background: #f3e8ff; color: #6b21a8; }
.badge-status-published { background: #e8f8ef; color: var(--success); }
.badge-status-archived { background: #fdecec; color: var(--danger); }

.pagination-wrap { margin-top: 1rem; }
.pagination-wrap nav { display: flex; gap: .35rem; flex-wrap: wrap; }
.pagination-wrap a,
.pagination-wrap span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: .45rem .65rem;
    border: 1px solid var(--line);
    border-radius: .45rem;
    background: #fff;
}
.pagination-wrap span[aria-current="page"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.form-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .75rem;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
}
.form-section h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .9rem;
}
.form-grid .span-2 { grid-column: span 2; }
.field-label,
.required-mark { font-weight: 600; }
.required-mark { color: var(--danger); margin-left: .15rem; }

.media-picker {
    border: 1px dashed var(--line);
    border-radius: .65rem;
    padding: .85rem;
    background: #fafbfc;
}
.media-picker-preview {
    min-height: 120px;
    display: grid;
    place-items: center;
    margin: .65rem 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: .5rem;
    overflow: hidden;
}
.media-picker-preview img {
    max-width: 100%;
    max-height: 180px;
    display: block;
}
.media-picker-empty { color: var(--muted); font-size: .85rem; }

.preview-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .75rem;
    padding: 1.25rem;
}
.preview-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}
.preview-header h2 { margin: 0 0 .25rem; }
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .85rem 1rem;
    margin: 0 0 1rem;
}
.preview-grid dt {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: .2rem;
}
.preview-grid dd { margin: 0; }
.preview-media img {
    max-width: 320px;
    border-radius: .5rem;
    border: 1px solid var(--line);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.media-grid-item {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: .65rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.media-grid-thumb {
    aspect-ratio: 4 / 3;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.media-grid-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-grid-body {
    padding: .65rem .75rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex: 1;
}
.media-grid-title {
    font-size: .85rem;
    font-weight: 600;
    margin: 0;
    word-break: break-word;
}
.media-grid-meta {
    font-size: .75rem;
    color: var(--muted);
}
.media-grid-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: auto;
}
.form-help {
    font-size: .8rem;
    color: var(--muted);
    margin: .25rem 0 0;
}

@media (max-width: 860px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .preview-header { flex-direction: column; }
}

/* Sprint 5 — Operations & Trust CMS */
.settings-group {
    border: 1px solid var(--line);
    border-radius: .75rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--panel);
}
.settings-group h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--accent-ink);
}
.lock-banner {
    background: #fff7e6;
    border: 1px solid #f0d59a;
    border-radius: .55rem;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.lock-banner-action { margin-left: auto; }
.consultation-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}
.consultation-section h3 {
    margin: 0 0 .75rem;
    font-size: .95rem;
}
.masked-cell {
    font-family: ui-monospace, "Cascadia Code", monospace;
    letter-spacing: .02em;
}
.badge-warning {
    background: #fff7e6;
    color: var(--warning);
    border: 1px solid #f0d59a;
}
