:root {
    color-scheme: light;
    --ink: #12212f;
    --muted: #647383;
    --line: #dbe3e9;
    --surface: #ffffff;
    --canvas: #f3f6f8;
    --navy: #123a52;
    --navy-deep: #0c293b;
    --teal: #17837b;
    --teal-soft: #e5f5f2;
    --amber: #bd7822;
    --amber-soft: #fff3db;
    --danger: #a53a45;
    --danger-soft: #fae9eb;
    --radius: 14px;
    --shadow: 0 12px 32px rgba(18, 58, 82, 0.08);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--canvas);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 88% 0%, rgba(23, 131, 123, 0.08), transparent 30rem),
        var(--canvas);
}

a {
    color: var(--teal);
    font-weight: 650;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-header {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 10px clamp(18px, 3vw, 48px);
    color: white;
    background: linear-gradient(120deg, var(--navy-deep), var(--navy));
    box-shadow: 0 3px 16px rgba(12, 41, 59, 0.18);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: white;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark,
.login-brand {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: var(--navy-deep);
    font-size: 1.35rem;
    font-weight: 900;
    background: #a8e3d9;
    border-radius: 11px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 1.05rem;
}

.brand small {
    margin-top: 2px;
    color: #c9d9e2;
    font-size: 0.76rem;
}

.app-header nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.app-header nav > a {
    padding: 9px 12px;
    color: #dce9ef;
    border-radius: 8px;
}

.app-header nav > a.active {
    color: white;
    background: rgba(255, 255, 255, 0.11);
}

.app-header form {
    margin: 0;
}

.user-name {
    max-width: 220px;
    overflow: hidden;
    color: #c9d9e2;
    font-size: 0.88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-shell {
    width: min(1540px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 64px;
}

.page-heading {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-heading h1,
.content-section h1 {
    margin: 4px 0 0;
    font-size: clamp(2rem, 3vw, 3rem);
    letter-spacing: -0.04em;
}

.lead {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.eyebrow {
    margin: 0;
    color: var(--teal);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 18px;
}

.metric {
    padding: 19px 20px;
    background: linear-gradient(145deg, #f8fcfd, white);
    border: 1px solid var(--line);
    border-top: 3px solid var(--navy);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric span,
.metric strong {
    display: block;
}

.metric span {
    min-height: 2.2em;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.metric strong {
    margin-top: 10px;
    color: var(--navy);
    font-size: clamp(1.4rem, 2vw, 2rem);
    letter-spacing: -0.035em;
}

.metric-amber {
    border-top-color: var(--amber);
}

.metric-green {
    border-top-color: var(--teal);
}

.content-section {
    margin-bottom: 18px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-title {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: #f8fafb;
    border-bottom: 1px solid var(--line);
}

.section-title h2 {
    margin: 3px 0 0;
    font-size: 1.1rem;
    letter-spacing: -0.015em;
}

.section-title > span {
    color: var(--muted);
    font-size: 0.78rem;
    text-align: right;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 17px 15px;
    padding: 22px;
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.span-4 {
    grid-column: span 4;
}

.span-6 {
    grid-column: span 6;
}

.span-7 {
    grid-column: span 7;
}

.span-8 {
    grid-column: span 8;
}

.span-12 {
    grid-column: span 12;
}

.field {
    min-width: 0;
}

.field label,
.check-grid legend {
    display: block;
    margin-bottom: 6px;
    color: #344859;
    font-size: 0.78rem;
    font-weight: 750;
}

.field input:not([type="checkbox"]):not([type="file"]),
.field select,
.field textarea,
.field input[type="file"] {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ink);
    background: white;
    border: 1px solid #c8d3db;
    border-radius: 8px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field textarea {
    resize: vertical;
}

.field input[type="file"] {
    padding: 7px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(23, 131, 123, 0.13);
}

.field > span,
.validation-summary {
    display: block;
    margin-top: 5px;
    color: var(--danger);
    font-size: 0.76rem;
}

.validation-summary:empty,
.field > span:empty {
    display: none;
}

.validation-summary {
    margin: 18px 22px 0;
    padding: 12px 14px;
    background: var(--danger-soft);
    border: 1px solid #ecc6ca;
    border-radius: 8px;
}

.validation-summary ul {
    margin: 0;
    padding-left: 20px;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
    margin: 2px 0 0;
    padding: 16px;
    background: #f8fafb;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.check-grid legend {
    float: none;
    width: auto;
    margin: 0 0 4px;
    padding: 0 6px;
}

.check-grid label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 9px 10px;
    color: #344859;
    font-size: 0.78rem;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.check-grid input,
.remember input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--teal);
}

.attachment-form {
    align-items: end;
}

.field-action {
    display: flex;
    align-items: flex-end;
}

.field-action .button {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 4px 0 28px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 16px;
    color: var(--ink);
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    background: white;
    border: 1px solid #bfcbd4;
    border-radius: 8px;
}

.button:hover {
    text-decoration: none;
    filter: brightness(0.98);
}

.button-primary {
    color: white;
    background: var(--teal);
    border-color: var(--teal);
}

.button-secondary {
    color: var(--navy);
    background: white;
    border-color: #b9c9d3;
}

.button-danger {
    color: var(--danger);
    background: white;
    border-color: #d9aeb3;
}

.button-ghost {
    min-height: 34px;
    padding: 7px 12px;
    color: white;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
}

.button-block {
    width: 100%;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

th,
td {
    padding: 12px 13px;
    vertical-align: top;
    text-align: left;
    border-bottom: 1px solid #e8edf0;
}

th {
    color: #526575;
    font-size: 0.71rem;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    background: #fbfcfd;
}

tbody tr:hover {
    background: #f9fbfc;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.money {
    text-align: right;
    white-space: nowrap;
}

.object-cell {
    min-width: 240px;
    max-width: 380px;
}

.status-pill {
    display: inline-flex;
    padding: 5px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    white-space: nowrap;
    background: #edf1f4;
    border-radius: 999px;
}

.status-ok {
    color: #0c675f;
    background: var(--teal-soft);
}

.status-pending {
    color: #8d5511;
    background: var(--amber-soft);
}

.status-danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.status-muted {
    color: #586a79;
}

.empty-state {
    padding: 32px;
    color: var(--muted);
    text-align: center;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: 9px;
}

.alert-success {
    color: #0c675f;
    background: var(--teal-soft);
    border-color: #a9d8d1;
}

.alert-warning {
    color: #805014;
    background: var(--amber-soft);
    border-color: #e8c88f;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #e5b8bd;
}

.narrow-section {
    max-width: 700px;
    margin: 50px auto;
    padding: 30px;
}

.public-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background:
        radial-gradient(circle at 10% 10%, rgba(168, 227, 217, 0.17), transparent 30rem),
        linear-gradient(135deg, #0b293a, #123f57);
}

.login-shell {
    width: min(430px, calc(100% - 30px));
    padding: 28px 0;
}

.login-card {
    padding: clamp(28px, 6vw, 44px);
    background: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.27);
}

.login-brand {
    width: 52px;
    height: 52px;
    margin-bottom: 22px;
    font-size: 1.6rem;
}

.login-card h1 {
    margin: 4px 0;
    font-size: 2.2rem;
    letter-spacing: -0.045em;
}

.login-copy {
    margin: 0 0 25px;
    color: var(--muted);
}

.login-card .field {
    margin-bottom: 16px;
}

.remember {
    display: flex;
    gap: 9px;
    align-items: center;
    margin: 4px 0 20px;
    color: #526575;
    font-size: 0.82rem;
}

.bootstrap-note {
    margin: 22px 0 0;
    padding-top: 18px;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.5;
    border-top: 1px solid var(--line);
}

code {
    padding: 2px 5px;
    background: #eef2f4;
    border-radius: 4px;
}

@media (max-width: 1100px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-2,
    .span-3 {
        grid-column: span 4;
    }

    .span-4 {
        grid-column: span 6;
    }

    .span-7,
    .span-8 {
        grid-column: span 8;
    }

    .check-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-header {
        position: static;
        align-items: flex-start;
    }

    .brand small,
    .user-name,
    .app-header nav > a {
        display: none;
    }

    .app-shell {
        width: min(100% - 22px, 1540px);
        padding-top: 24px;
    }

    .page-heading,
    .section-title {
        align-items: flex-start;
    }

    .page-heading {
        flex-direction: column;
    }

    .section-title {
        flex-direction: column;
        gap: 6px;
    }

    .section-title > span {
        text-align: left;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
        padding: 17px;
    }

    .span-2,
    .span-3,
    .span-4,
    .span-6,
    .span-7,
    .span-8,
    .span-12 {
        grid-column: auto;
    }

    .check-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
