:root {
    --color-ink: #0e2832;
    --color-muted: #59717a;
    --color-city-blue: #014e66;
    --color-city-red: #e40146;
    --color-city-green: #01a48b;
    --color-city-sky: #80cef5;
    --color-bg: #f4f8f9;
    --color-surface: #ffffff;
    --color-border: #d8e4e8;
    --shadow-panel: 0 18px 38px rgba(1, 78, 102, 0.12);
    --radius: 8px;
    --font-sans: "Source Sans Pro", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: "Roboto Slab", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-sans);
    letter-spacing: 0;
}

button,
input,
textarea {
    font: inherit;
    letter-spacing: 0;
}

a {
    color: var(--color-city-blue);
    text-decoration: none;
}

:focus-visible {
    outline: 3px solid var(--color-city-sky);
    outline-offset: 3px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    transform: translateY(-140%);
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--color-city-blue);
    color: #ffffff;
    font-weight: 900;
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(220px, auto) 1fr auto;
    align-items: center;
    min-height: 74px;
    padding: 0 32px;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    gap: 14px;
    align-items: center;
    color: var(--color-city-blue);
    text-decoration: none;
    font-weight: 800;
}

.brand img {
    width: 138px;
    height: auto;
}

.brand span {
    padding-left: 14px;
    border-left: 2px solid var(--color-city-red);
    white-space: nowrap;
}

.top-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.top-nav a,
.icon-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-muted);
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
}

.top-nav a.active,
.top-nav a:hover,
.icon-link:hover {
    border-color: var(--color-border);
    color: var(--color-city-blue);
    background: #f1f7f8;
}

.user-menu {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: var(--color-muted);
    font-size: 0.95rem;
    font-weight: 700;
}

.flash-stack {
    position: fixed;
    top: 86px;
    right: 24px;
    z-index: 30;
    display: grid;
    gap: 10px;
}

.flash {
    min-width: 260px;
    padding: 13px 16px;
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-city-green);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-panel);
    font-weight: 700;
}

.flash-error {
    border-left-color: var(--color-city-red);
}

.login-page {
    background:
        linear-gradient(120deg, rgba(1, 78, 102, 0.9), rgba(1, 78, 102, 0.76)),
        linear-gradient(45deg, rgba(128, 206, 245, 0.18), rgba(1, 164, 139, 0.14)),
        #014e66;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
}

.login-visual {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
    padding: 54px;
    color: #ffffff;
}

.login-logo {
    width: 260px;
    max-width: 70vw;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: #ffffff;
}

.login-visual h1,
.hero-band h1,
.admin-title h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 4vw, 4.8rem);
    line-height: 1.02;
    font-weight: 800;
}

.login-visual p {
    margin: 18px 0 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 36px;
    background: #ffffff;
}

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

.section-heading span,
.panel-header span,
.eyebrow {
    display: block;
    margin: 0 0 8px;
    color: var(--color-city-red);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.section-heading h2,
.panel-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.85rem;
    line-height: 1.1;
}

.inline-alert {
    margin: 22px 0;
    padding: 13px 14px;
    border: 1px solid rgba(228, 1, 70, 0.22);
    border-radius: var(--radius);
    background: rgba(228, 1, 70, 0.06);
    color: #95113a;
    font-weight: 700;
}

.form-stack {
    display: grid;
    gap: 10px;
    margin-top: 28px;
}

.form-stack label,
.settings-list label span {
    color: var(--color-city-blue);
    font-size: 0.9rem;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--color-ink);
    outline: none;
}

input {
    min-height: 46px;
    padding: 0 13px;
}

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

input:focus,
textarea:focus {
    border-color: var(--color-city-sky);
    box-shadow: none;
}

.primary-button,
.secondary-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 900;
    text-decoration: none;
}

.primary-button {
    margin-top: 10px;
    padding: 0 18px;
    background: var(--color-city-red);
    color: #ffffff;
}

.primary-button:hover {
    background: #c9013e;
}

.secondary-button {
    padding: 0 13px;
    border: 1px solid var(--color-border);
    background: #ffffff;
    color: var(--color-city-blue);
    white-space: nowrap;
}

.secondary-button:hover {
    border-color: var(--color-city-blue);
}

.demo-note {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
    line-height: 1.55;
}

.auth-actions {
    margin-top: 18px;
}

.auth-actions a {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--color-city-blue);
    font-weight: 600;
}

.auth-actions a::after {
    content: "\2192";
    transition: transform 0.16s ease;
}

.auth-actions a:hover {
    color: #003d52;
}

.auth-actions a:hover::after {
    transform: translateX(2px);
}

.app-shell {
    width: min(1220px, calc(100% - 40px));
    margin: 0 auto;
    padding: 34px 0 64px;
}

.hero-band,
.admin-title {
    display: grid;
    grid-template-columns: 1fr minmax(330px, 0.72fr);
    gap: 30px;
    align-items: end;
    margin-bottom: 30px;
    padding: 36px;
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, rgba(1, 78, 102, 0.97), rgba(1, 78, 102, 0.9)),
        #014e66;
    color: #ffffff;
    box-shadow: var(--shadow-panel);
}

.hero-band p,
.admin-title p {
    max-width: 660px;
    margin: 14px 0 0;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.1rem;
}

.hero-band .eyebrow,
.admin-title .eyebrow {
    color: var(--color-city-sky);
}

.identity-grid,
.profile-list {
    margin: 0;
}

.identity-grid {
    display: grid;
    gap: 12px;
}

.identity-grid div {
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
}

dt {
    margin-bottom: 4px;
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.identity-grid dt {
    color: rgba(255, 255, 255, 0.66);
}

dd {
    margin: 0;
    font-weight: 800;
}

.content-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.side-panel,
.document-area,
.panel {
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: 0 12px 28px rgba(1, 78, 102, 0.08);
}

.side-panel {
    padding: 24px;
}

.side-panel h2 {
    margin: 0 0 20px;
    font-family: var(--font-display);
}

.profile-list {
    display: grid;
    gap: 18px;
}

.document-area {
    padding: 26px;
}

.accordion-list {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.document-class {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #ffffff;
}

.document-class summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
    min-height: 64px;
    padding: 0 18px;
    cursor: pointer;
    list-style: none;
}

.document-class summary::-webkit-details-marker {
    display: none;
}

.class-marker {
    width: 12px;
    height: 34px;
    border-radius: 999px;
    background: var(--color-city-green);
}

.document-class-title {
    font-size: 1.08rem;
    font-weight: 900;
}

.document-count {
    color: var(--color-muted);
    font-size: 0.9rem;
    font-weight: 800;
}

.document-class-body {
    padding: 0 18px 18px;
}

.document-class-body p {
    margin: 0 0 14px;
    color: var(--color-muted);
}

.document-table,
.admin-table {
    display: grid;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.document-row,
.admin-row {
    display: grid;
    min-width: 0;
    align-items: center;
    min-height: 56px;
    border-top: 1px solid var(--color-border);
}

.document-row {
    grid-template-columns: 170px minmax(160px, 1fr) 170px;
}

.admin-row {
    grid-template-columns: minmax(210px, 1fr) 110px 120px 150px;
}

.document-row:first-child,
.admin-row:first-child {
    border-top: 0;
}

.document-row > span,
.admin-row > span {
    min-width: 0;
    padding: 12px 14px;
    overflow-wrap: anywhere;
}

.document-row-head,
.admin-row-head {
    min-height: 42px;
    background: #f1f7f8;
    color: var(--color-city-blue);
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.file-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius);
    background: rgba(228, 1, 70, 0.08);
    color: var(--color-city-red);
    font-weight: 900;
    text-decoration: none;
}

.file-link:hover {
    background: rgba(228, 1, 70, 0.14);
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    color: var(--color-muted);
    font-weight: 700;
}

.admin-shell {
    width: min(1320px, calc(100% - 40px));
}

.admin-title {
    grid-template-columns: 1fr auto;
}

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(2, 150px);
    gap: 12px;
}

.admin-metrics div {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
}

.admin-metrics strong {
    display: block;
    font-size: 2rem;
}

.admin-metrics span {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.86rem;
    font-weight: 800;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

.admin-grid > * {
    min-width: 0;
}

.lower-grid {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    margin-top: 24px;
}

.panel {
    padding: 22px;
}

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

.panel-header span {
    margin-top: 4px;
    white-space: nowrap;
}

.admin-row small {
    display: block;
    min-width: 0;
    margin-top: 4px;
    color: var(--color-muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 900;
}

.status-on {
    background: rgba(1, 164, 139, 0.12);
    color: #007967;
}

.status-off {
    background: rgba(89, 113, 122, 0.14);
    color: var(--color-muted);
}

.compact-form {
    margin-top: 0;
}

.check-row {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    color: var(--color-ink);
}

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

.settings-list {
    display: grid;
    gap: 14px;
}

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

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-action-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.audit-list {
    display: grid;
    gap: 12px;
}

.audit-item {
    display: grid;
    gap: 4px;
    padding: 13px 0;
    border-bottom: 1px solid var(--color-border);
}

.audit-item:last-child {
    border-bottom: 0;
}

.audit-item time {
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.audit-item strong {
    color: var(--color-city-blue);
}

.audit-item span {
    color: var(--color-muted);
}

@media (max-width: 920px) {
    .app-header {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px 20px;
        position: static;
    }

    .top-nav {
        justify-content: flex-start;
    }

    .user-menu {
        justify-content: space-between;
    }

    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: auto;
        padding: 34px 24px;
        gap: 42px;
    }

    .login-panel {
        padding: 24px;
    }

    .hero-band,
    .admin-title,
    .content-layout,
    .admin-grid,
    .lower-grid {
        grid-template-columns: 1fr;
    }

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

    .document-row,
    .admin-row {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 12px 0;
    }

    .document-row-head,
    .admin-row-head {
        display: none;
    }

    .document-row > span,
    .admin-row > span {
        padding: 6px 14px;
    }

    .panel-header {
        flex-direction: column;
        gap: 6px;
    }

    .panel-header span {
        white-space: normal;
    }
}

@media (max-width: 560px) {
    .app-shell,
    .admin-shell {
        width: min(100% - 24px, 1220px);
        padding-top: 18px;
    }

    .brand {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand span {
        padding-left: 0;
        border-left: 0;
    }

    .brand img {
        width: 124px;
    }

    .top-nav {
        flex-wrap: wrap;
    }

    .hero-band,
    .admin-title,
    .document-area,
    .panel,
    .side-panel {
        padding: 20px;
    }

    .document-class summary {
        grid-template-columns: auto 1fr;
        min-height: 74px;
    }

    .document-count {
        grid-column: 2;
    }
}
