* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f7fb;
    color: #102a43;
}

a {
    color: inherit;
}

.site-shell {
    min-height: 100vh;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: #0b253a;
    color: #f0f4f8;
    border-bottom: 4px solid #0f766e;
}

.brand {
    display: inline-block;
    color: #ffffff;
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 700;
}

.subtitle {
    margin: 0.2rem 0 0;
    color: #bcccdc;
    font-size: 0.9rem;
}

.site-nav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.site-nav a {
    padding: 0.6rem 0.85rem;
    border-radius: 0.6rem;
    text-decoration: none;
    color: #d9e2ec;
}

.site-nav a.is-active,
.site-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-bar span {
    display: block;
    color: #9fb3c8;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
}

.page-shell {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-heading,
.section-heading,
.page-actions,
.quick-filters,
.detail-grid,
.stack-lg,
.stack-md {
    display: flex;
    gap: 1rem;
}

.page-heading,
.section-heading {
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.page-heading.compact {
    margin-bottom: 0;
}

.page-heading h1,
.section-heading h2 {
    margin: 0 0 0.25rem;
}

.page-heading p,
.section-heading p {
    margin: 0;
    color: #627d98;
}

.page-actions {
    flex-wrap: wrap;
}

.quick-filters {
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.stack-lg,
.stack-md {
    flex-direction: column;
}

.panel {
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.stat-card {
    min-width: 190px;
    padding: 1rem 1.1rem;
    border-radius: 0.9rem;
    border: 1px solid #d9e2ec;
    background: #ffffff;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.stat-card span {
    display: block;
    color: #486581;
    font-size: 0.9rem;
}

.stat-card strong {
    display: block;
    margin-top: 0.5rem;
    font-size: 1.6rem;
}

.stat-card.is-active {
    border-color: #0f766e;
    background: #ecfdf5;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.72rem 1rem;
    border: 0;
    border-radius: 0.7rem;
    background: #0f766e;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: #0a5f58;
}

.button-secondary {
    background: #d9e2ec;
    color: #102a43;
}

.button-secondary:hover {
    background: #bcccdc;
}

.button-danger {
    background: #b91c1c;
}

.button-danger:hover {
    background: #991b1b;
}

.button-small {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

.inline-form {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

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

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

.field-span-full {
    grid-column: 1 / -1;
}

.field-pair {
    display: grid;
    grid-column: span 2;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.field-pair label {
    margin: 0;
}

.field-pair-full {
    display: grid;
    grid-column: span 4;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.field-pair-full label {
    margin: 0;
}

.field-trio {
    display: grid;
    grid-column: span 4;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.field-trio2 {
    display: grid;
    grid-column: span 5;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.field-trio label {
    margin: 0;
}

.field-quad {
    display: grid;
    grid-column: span 4;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.field-quad label {
    margin: 0;
}

label span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: #334e68;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #bcccdc;
    border-radius: 0.2rem;
    padding: 0.4rem 0.4rem;
    font: inherit;
    color: #102a43;
    background: #ffffff;
}

input[readonly] {
    background: #f7fafc;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 4.75rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    transform: translateY(-50%);
    border: 0;
    border-radius: 0.55rem;
    padding: 0.35rem 0.55rem;
    background: #eef4fb;
    color: #0b5ec9;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.password-toggle:hover {
    background: #dbeafe;
}

.password-toggle:focus-visible {
    outline: 2px solid #0b5ec9;
    outline-offset: 2px;
}

textarea {
    resize: vertical;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.checkbox-field input {
    width: auto;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table-toolbar,
.table-controls,
.table-pagination {
    display: flex;
    gap: 1rem;
}

.table-toolbar,
.table-pagination {
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.table-controls {
    align-items: flex-end;
    flex-wrap: wrap;
}

.table-search {
    flex: 1 1 320px;
    min-width: min(320px, 100%);
}

.table-search,
.table-page-size {
    margin: 0;
}

.table-page-size select {
    min-width: 90px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

.data-table th,
.data-table td {
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid #e3edf5;
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: #f7fafc;
    color: #334e68;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table-sort {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

.table-sort.is-active {
    color: #0f766e;
}

.table-sort-indicator {
    min-width: 0.9rem;
    text-align: right;
}

.dispatch-table td {
    white-space: nowrap;
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #d9e2ec;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

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

.flash {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 0.8rem;
}

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

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.error-list {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: #627d98;
}

.pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.pager.table-pagination {
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.pager-link {
    padding: 0.55rem 0.8rem;
    border-radius: 0.65rem;
    background: #d9e2ec;
    color: #102a43;
    text-decoration: none;
}

.pager button.pager-link {
    border: 0;
    font: inherit;
    cursor: pointer;
}

.pager button.pager-link:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.pager-link.is-disabled {
    opacity: 0.55;
}

.pager-status {
    color: #486581;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.detail-list div {
    padding: 0.85rem;
    border-radius: 0.8rem;
    background: #f7fafc;
}

.detail-list dt {
    margin-bottom: 0.3rem;
    color: #486581;
    font-size: 0.85rem;
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    white-space: pre-wrap;
}

.note-block {
    padding: 1rem;
    border-radius: 0.8rem;
    background: #f7fafc;
    min-height: 7rem;
    white-space: pre-wrap;
}

.auth-wrapper {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-card {
    width: min(520px, 100%);
    padding: 2rem;
    background: #ffffff;
    border: 1px solid #d9e2ec;
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

@media (max-width: 1024px) {
    .site-header,
    .page-heading,
    .section-heading {
        flex-direction: column;
    }

    .filter-grid-compact,
    .form-grid-wide,
    .detail-grid,
    .detail-list {
        grid-template-columns: 1fr;
    }

    .field-pair {
        grid-column: 1 / -1;
    }

    .field-pair-full {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, 1fr);
    }

    .field-trio {
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, 1fr);
    }

    .field-quad {
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 720px) {
    .site-header,
    .page-shell {
        padding: 1rem;
    }

    .user-bar {
        width: 100%;
        justify-content: space-between;
    }

    .site-nav,
    .quick-filters {
        width: 100%;
    }

    .table-toolbar,
    .table-controls,
    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-card {
        min-width: unset;
        width: 100%;
    }

    .field-pair {
        grid-template-columns: 1fr;
    }

    .field-pair-full {
        grid-template-columns: 1fr;
    }

    .field-trio {
        grid-template-columns: 1fr;
    }

    .field-quad {
        grid-template-columns: 1fr;
    }
}
