:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f9fbfd;
    --text: #172033;
    --muted: #637083;
    --line: #dce4ee;
    --brand: #0f766e;
    --brand-strong: #115e59;
    --blue: #2563eb;
    --blue-soft: #eaf3ff;
    --amber: #b45309;
    --green: #15803d;
    --gray: #64748b;
    --shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 0 24px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.brand__mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--brand-strong);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
}

.brand__text {
    display: grid;
    gap: 1px;
}

.brand__text strong {
    font-size: 1rem;
}

.brand__text small {
    color: var(--muted);
    font-size: 0.82rem;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.nav form {
    margin: 0;
}

.nav__link,
.nav__pill,
.nav__button,
.button,
.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 0 14px;
    font-size: 0.92rem;
    font-weight: 600;
}

.nav__button {
    cursor: pointer;
    background: var(--panel);
    color: var(--text);
}

.nav__link--active,
.button {
    border-color: var(--brand);
    background: var(--brand);
    color: #ffffff;
}

.button--danger {
    border-color: #dc2626;
    background: #dc2626;
}

.button--warning {
    border-color: var(--amber);
    background: var(--amber);
}

.button:hover,
.nav__button:hover,
.pagination__link:hover {
    filter: brightness(0.96);
}

.button--wide {
    width: 100%;
}

.nav__pill {
    background: var(--panel-soft);
    color: var(--muted);
}

.page {
    padding: 32px 0 48px;
}

.page-subtitle {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.login-shell {
    display: grid;
    min-height: calc(100vh - 152px);
    place-items: center;
}

.auth-card {
    display: grid;
    width: min(440px, 100%);
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 24px;
    box-shadow: var(--shadow);
}

.field {
    display: grid;
    gap: 8px;
}

.field span,
.check-field {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 0 12px;
    outline: none;
}

.input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.input--compact {
    min-height: 38px;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-box {
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
    padding: 12px;
    font-size: 0.92rem;
}

.message-list {
    display: grid;
    gap: 4px;
    margin: 10px 0 0;
    padding-left: 18px;
}

.error-page {
    display: grid;
    min-height: calc(100vh - 152px);
    place-items: center;
}

.error-panel {
    display: grid;
    width: min(680px, 100%);
    gap: 16px;
    border: 1px solid var(--line);
    border-left: 5px solid #b91c1c;
    border-radius: 8px;
    background: var(--panel);
    padding: 28px;
    box-shadow: var(--shadow);
}

.error-code {
    width: fit-content;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    padding: 6px 10px;
    font-size: 0.84rem;
    font-weight: 800;
}

.error-panel p {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.55;
}

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

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
}

.confirm-modal__dialog {
    position: relative;
    z-index: 1;
    display: grid;
    width: min(460px, 100%);
    gap: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 24px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
    outline: none;
}

.confirm-modal__eyebrow {
    display: block;
    margin-bottom: 8px;
    color: #b91c1c;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.confirm-modal__dialog p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.55;
}

.confirm-modal__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.home-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.home-grid {
    display: grid;
    grid-template-columns: minmax(360px, 1.4fr) repeat(3, minmax(220px, 1fr));
    gap: 14px;
}

.home-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-card {
    display: flex;
    min-height: 168px;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 20px;
    box-shadow: var(--shadow);
}

.home-card--primary {
    background: var(--brand-strong);
    color: #ffffff;
}

.home-card__label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.home-card--primary .home-card__label,
.home-card--primary p {
    color: rgba(255, 255, 255, 0.76);
}

.home-card h2,
.home-card strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1.2;
}

.home-card p {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.home-card__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 38px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--brand-strong);
    padding: 0 14px;
    font-size: 0.92rem;
    font-weight: 700;
}

.text-link {
    width: fit-content;
    color: var(--brand-strong);
    font-size: 0.92rem;
    font-weight: 700;
}

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

.inline-form {
    display: inline-flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-field {
    display: grid;
    gap: 5px;
}

.inline-field span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.spacing-top {
    margin-top: 18px;
}

.spacing-bottom {
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--brand);
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 2rem;
    line-height: 1.15;
}

h2 {
    font-size: 1.1rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    min-height: 108px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 1.55rem;
    line-height: 1.1;
}

.stat-card--success {
    border-left-color: var(--green);
}

.stat-card--warning {
    border-left-color: var(--amber);
}

.stat-card--accent {
    border-left-color: var(--blue);
}

.table-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.table-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 74px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-soft);
}

.table-panel__header p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1280px;
    border-collapse: collapse;
}

.table-auto {
    min-width: 720px;
}

th,
td {
    padding: 15px 20px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}

th {
    background: var(--blue-soft);
    color: #1d4f91;
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

td {
    font-size: 0.94rem;
}

td strong,
td span {
    display: block;
}

td span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.84rem;
}

tbody tr:nth-child(odd) {
    background: #fff1f2;
}

tbody tr:nth-child(even) {
    background: #fffbeb;
}

tbody tr:hover {
    background: #eef6ff;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.text-right {
    text-align: right;
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid var(--brand);
    border-radius: 8px;
    color: var(--brand-strong);
    padding: 0 12px;
    font-size: 0.86rem;
    font-weight: 700;
}

.table-action:hover {
    background: #ecfdf5;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions form {
    margin: 0;
}

button.table-action {
    cursor: pointer;
    background: #ffffff;
    font-family: inherit;
}

.table-action--danger {
    border-color: #dc2626;
    color: #b91c1c;
}

.table-action--danger:hover {
    background: #fef2f2;
}

.table-action--warning {
    border-color: var(--amber);
    color: #92400e;
}

.table-action--warning:hover {
    background: #fffbeb;
}

.form-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 22px;
}

.form-grid__full {
    grid-column: 1 / -1;
}

.success-box {
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    background: #f0fdf4;
    color: #166534;
    padding: 12px;
    font-size: 0.92rem;
}

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

.check-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 0 12px;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
}

.check-card input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge--success {
    background: #dcfce7;
    color: #166534;
}

.badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.badge--muted {
    background: #e2e8f0;
    color: #475569;
}

.badge--neutral {
    background: #dbeafe;
    color: #1d4ed8;
}

.empty-row {
    height: 96px;
    color: var(--muted);
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
}

.pagination__link {
    background: var(--panel);
    color: var(--text);
}

.pagination__link--disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

.pagination__status {
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

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

@media (max-width: 640px) {
    .container {
        padding: 0 14px;
    }

    .topbar__inner,
    .home-header,
    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar__inner {
        padding: 14px 0;
    }

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

    h1 {
        font-size: 1.55rem;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .home-grid,
    .home-grid--three {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .toggle-grid {
        grid-template-columns: 1fr;
    }

    .table-panel__header,
    th,
    td {
        padding-left: 14px;
        padding-right: 14px;
    }
}
