:root {
    color-scheme: light;
    --ink: #17231e;
    --muted: #64736c;
    --line: #e2e9e5;
    --green: #136b4b;
    --green-dark: #0c5138;
    --paper: #f5f8f6;
    --white: #fff;
    --shadow: 0 16px 42px rgba(25, 55, 42, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 10% 12%, rgba(19, 107, 75, .12), transparent 34%),
        radial-gradient(ellipse at 90% 85%, rgba(172, 201, 111, .14), transparent 33%),
        var(--paper);
}

.card, .panel, .module-card, .intro-panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-card { width: min(100%, 440px); padding: 38px; }

.eyebrow, .module-kicker {
    margin: 0 0 8px;
    color: var(--green);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.035em; }
h2 { margin-bottom: 8px; font-size: 20px; letter-spacing: -.02em; }
.muted { color: var(--muted); }

.stack-form { display: grid; gap: 16px; margin-top: 24px; }
.stack-form label { display: grid; gap: 7px; color: #34443c; font-size: 13px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #ccd8d1;
    border-radius: 9px;
    background: white;
    color: var(--ink);
    font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(19, 107, 75, .16); border-color: var(--green); }
textarea { min-height: 180px; resize: vertical; }
input[type="checkbox"] { width: 17px; min-height: 17px; margin: 0; accent-color: var(--green); }

.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 15px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: white;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.button:hover { border-color: #b6c8be; color: var(--green-dark); }
.button.primary { border-color: var(--green); background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.quiet { background: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 18px 20px;
    border-right: 1px solid var(--line);
    background: #fff;
}
.brand { padding: 0 13px 30px; color: var(--ink); font-size: 19px; font-weight: 850; letter-spacing: -.04em; }
.brand span { display: block; color: var(--green); font-size: 12px; letter-spacing: .15em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 11px 13px; border-radius: 9px; color: #53635b; font-weight: 650; }
.sidebar nav a:hover, .sidebar nav a.active { background: #eaf3ee; color: var(--green-dark); }
.sidebar-user { display: grid; gap: 3px; margin-top: auto; padding: 16px 13px 0; border-top: 1px solid var(--line); }
.sidebar-user span { font-weight: 750; }
.sidebar-user small { color: var(--muted); }
.sidebar-user a { margin-top: 8px; font-size: 13px; }
.sidebar-user form { margin-top: 8px; }

.main-content { width: min(100%, 1440px); margin: 0 auto; padding: 36px clamp(20px, 4vw, 56px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.topbar h1 { margin-bottom: 0; }
.secure-tag, .count { padding: 6px 10px; border: 1px solid #d5e8dc; border-radius: 999px; background: #eef7f1; color: var(--green-dark); font-size: 12px; font-weight: 750; white-space: nowrap; }
.intro-panel { margin-bottom: 20px; padding: 25px 28px; }
.intro-panel p:last-child { margin-bottom: 0; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.module-card { display: flex; flex-direction: column; min-height: 220px; padding: 24px; }
.module-card h2 { font-size: 22px; }
.module-card p { color: var(--muted); }
.module-card .button { align-self: flex-start; margin-top: auto; }
.portal-admin-module { color: var(--ink); }
.portal-admin-module .shell { width: 100%; margin: 0; padding: 0; }
.portal-admin-module .intro .eyebrow,
.portal-admin-module .intro h1,
.portal-admin-module .intro > p:last-child { color: var(--ink); }
.portal-admin-module .intro { padding-top: 0; }
.portal-admin-module .admin-nav { border-color: var(--line); background: var(--white); }
.portal-admin-module .admin-nav a { color: var(--green-dark); }
.portal-admin-module .admin-nav a:hover,
.portal-admin-module .admin-nav a:focus-visible { outline-color: var(--green); background: #eaf3ee; color: var(--green-dark); }
.portal-admin-module .admin-nav a.is-active { background: var(--green); color: var(--white); }
.content-grid { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(440px, 1.25fr); gap: 18px; align-items: start; }
.legal-admin { display: grid; gap: 18px; }
.legal-admin .intro-panel { margin-bottom: 0; }
.legal-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.legal-editor-card .stack-form { margin-top: 20px; }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.legal-form-actions { justify-content: flex-end; }
.panel { min-width: 0; padding: 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.panel .stack-form { margin-top: 20px; }
.check-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; }
.permissions { display: grid; gap: 12px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.legal-fieldset { display: grid; gap: 14px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.legal-fieldset legend { padding: 0 6px; color: var(--green-dark); font-weight: 750; }
.inline-form { display: inline-flex; margin-top: 12px; }
.media-details { display: grid; gap: 0; margin: 20px 0 0; }
.media-details div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.media-details dt { color: var(--muted); font-size: 12px; font-weight: 750; }
.media-details dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; }
.archive-year { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.archive-year h3 { margin: 0 0 8px; font-size: 15px; }
.year-heading, .file-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.file-row { min-height: 40px; padding: 8px 0; border-top: 1px solid #eef2ef; font-size: 12px; }
.file-row > span { min-width: 0; overflow-wrap: anywhere; }
.file-row .role-actions { gap: 12px; }
.teferic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.permissions legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.form-actions, .role-actions { display: flex; align-items: center; gap: 10px; }
.table-wrap { overflow-x: auto; margin: 10px -8px 0; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.table-link { font-size: 13px; font-weight: 750; white-space: nowrap; }
.status { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.status.on { background: #e7f4eb; color: #206840; }
.status.off { background: #f0f1f1; color: #68716d; }
.role-list { display: grid; }
.role-item { display: flex; justify-content: space-between; gap: 12px; padding: 15px 2px; border-bottom: 1px solid var(--line); }
.role-item strong, .role-item small { display: block; }
.role-item small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.role-actions { flex-shrink: 0; }
.text-button { padding: 0; border: 0; background: none; color: var(--green); font: inherit; font-size: 13px; font-weight: 750; cursor: pointer; }
.text-button.danger { color: #a33636; }
.totp-setup-qr { width: fit-content; margin: 20px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.totp-setup-qr img { display: block; width: min(240px, 60vw); height: auto; }
.totp-manual-setup { margin: 14px 0 20px; }
.totp-manual-setup summary { color: var(--green-dark); font-weight: 700; cursor: pointer; }
.totp-manual-setup p { margin: 10px 0 0; }
.notice { margin: 0 0 18px; padding: 12px 15px; border: 1px solid #d6e8dc; border-radius: 10px; background: #f0f8f3; color: #22573b; }
.notice.error { border-color: #f0caca; background: #fff4f3; color: #8d2929; }
code { overflow-wrap: anywhere; color: #34443c; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .legal-editor-grid { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0 6px 12px; }
    .brand span { display: inline; margin-left: 6px; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar nav a { white-space: nowrap; }
    .sidebar-user { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 12px 6px 0; }
    .sidebar-user a { margin: 0 0 0 auto; }
    .sidebar-user form { margin: 0 0 0 auto; }
}
@media (max-width: 680px) {
    .main-content { padding: 24px 16px 40px; }
    .module-grid, .content-grid { grid-template-columns: 1fr; }
    .module-card { min-height: 195px; }
    .panel { padding: 18px; }
    .login-card { padding: 28px 22px; }
    .secure-tag { display: none; }
}
