:root {
    --sts-midnight: #1B3249;
    --sts-dusk: #768D99;
    --sts-seagrass: #4F7C6E;
    --sts-pindan: #C4622D;
    --sts-bg: #F4F6F8;
    --sts-border: #DDE3E8;
    --sts-text: #1E2A33;
    --sts-muted: #5B6B76;
}

html, body {
    font-family: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--sts-bg);
    color: var(--sts-text);
}

/* ---------- App shell ---------- */
.app-bar {
    border-bottom: 1px solid var(--sts-border);
}

.app-logo img {
    height: 30px;
    margin: 0 16px 0 4px;
    display: block;
}

.app-title {
    color: var(--sts-muted);
    border-left: 1px solid var(--sts-border);
    padding-left: 16px;
}

.app-drawer {
    border-right: 1px solid var(--sts-border);
}

.drawer-help {
    padding: 16px;
    font-size: 0.8rem;
    color: var(--sts-muted);
    border-top: 1px solid var(--sts-border);
    margin-top: 16px;
}

.drawer-help a {
    color: var(--sts-midnight);
    word-break: break-all;
}

.page-container {
    padding-top: 24px;
    padding-bottom: 48px;
}

.sign-out-form {
    margin: 0;
}

.sign-out-button {
    white-space: nowrap;
}

/* Side menu item, styled to sit under the MudNavMenu links. */
.sign-out-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 12px 16px 12px 20px;
    background: none;
    border: none;
    border-top: 1px solid var(--sts-border);
    font: inherit;
    font-size: 0.875rem;
    color: var(--sts-text);
    cursor: pointer;
    text-align: left;
}

.sign-out-nav:hover {
    background: rgba(27, 50, 73, 0.06);
}

/* ---------- Page layout ---------- */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.form-section {
    padding: 20px 24px;
    margin-bottom: 20px;
    background: #fff;
}

.form-section.narrow {
    max-width: 720px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px !important;
    color: var(--sts-midnight);
}

.fw-600 {
    font-weight: 600 !important;
}

.text-secondary {
    color: var(--sts-muted);
}

.small {
    font-size: 0.8rem;
}

.pre-wrap {
    white-space: pre-wrap;
}

.text-danger {
    color: #B3261E;
}

/* ---------- Filters & tables ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: #fff;
}

.filter-field {
    flex: 1 1 170px;
    max-width: 240px;
}

.filter-search {
    max-width: 320px;
}

.filter-buttons {
    display: flex;
    gap: 4px;
}

.shipments-table .mud-table-cell {
    vertical-align: middle;
}

.shipments-table tr.row-cancelled td {
    opacity: 0.55;
}

.shipments-table tr.row-today {
    box-shadow: inset 3px 0 0 var(--sts-pindan);
}

.shipment-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.status-chip {
    font-weight: 600;
    margin: 0 !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px;
    color: var(--sts-muted);
}

/* ---------- Forms ---------- */
.manifest-empty {
    margin-top: 16px;
    padding: 16px;
    border: 1px dashed var(--sts-border);
    border-radius: 8px;
    color: var(--sts-muted);
    text-align: center;
    font-size: 0.9rem;
}

.manifest-table th {
    font-weight: 600 !important;
    color: var(--sts-muted) !important;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    word-break: break-all;
}

.submit-panel {
    position: sticky;
    top: 88px;
}

.detail-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px 16px;
    margin: 0;
}

.detail-list dt {
    color: var(--sts-muted);
    font-size: 0.875rem;
}

.detail-list dd {
    margin: 0;
    font-weight: 500;
}

@media (max-width: 600px) {
    .detail-list {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .detail-list dd {
        margin-bottom: 10px;
    }

    .form-section {
        padding: 16px;
    }
}

/* ---------- Dashboard ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid var(--sts-border);
    border-radius: 8px;
    color: var(--sts-text);
    text-decoration: none;
    transition: box-shadow .15s ease;
}

a.stat-card:hover {
    box-shadow: 0 4px 14px rgba(27, 50, 73, .12);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--sts-midnight);
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--sts-muted);
    margin-top: 4px;
}

.stat-warning {
    border-top: 4px solid var(--sts-pindan);
}

.stat-info {
    border-top: 4px solid #2F6F9F;
}

.calendar-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-top: 1px solid var(--sts-border);
    border-left: 1px solid var(--sts-border);
}

.calendar-dow {
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--sts-muted);
    border-right: 1px solid var(--sts-border);
    border-bottom: 1px solid var(--sts-border);
    background: #FAFBFC;
}

.calendar-day {
    min-height: 104px;
    padding: 4px;
    border-right: 1px solid var(--sts-border);
    border-bottom: 1px solid var(--sts-border);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.calendar-day.weekend {
    background: #FAFBFC;
}

.calendar-day.other-month .calendar-date {
    opacity: .4;
}

.calendar-date {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 6px;
    align-self: flex-start;
    border-radius: 12px;
}

.calendar-day.today .calendar-date {
    background: var(--sts-midnight);
    color: #fff;
}

.calendar-event {
    display: block;
    padding: 2px 6px;
    font-size: 0.72rem;
    line-height: 1.4;
    border-radius: 4px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--sts-midnight);
}

.calendar-more {
    font-size: 0.72rem;
    color: var(--sts-muted);
    padding-left: 4px;
}

.status-0 { background: var(--sts-pindan); }
.status-1 { background: var(--sts-midnight); }
.status-2 { background: var(--sts-seagrass); }
.status-4, .status-5, .status-10 { background: #3E7B4F; }
.status-6 { background: #2F6F9F; }
.status-99 { background: #B3261E; opacity: .6; text-decoration: line-through; }

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--sts-muted);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-item {
    display: flex;
    gap: 14px;
    padding: 10px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
}

.timeline-item:hover {
    background: var(--sts-bg);
}

.timeline-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 52px;
    border-radius: 8px;
    background: var(--sts-midnight);
    color: #fff;
}

.timeline-date .day {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}

.timeline-date .month {
    font-size: 0.7rem;
    text-transform: uppercase;
}

@media (max-width: 900px) {
    .calendar-day {
        min-height: 64px;
    }

    .calendar-event {
        font-size: 0;
        height: 6px;
        padding: 0;
    }
}

/* ---------- Sign-in & email response pages (server-rendered) ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, #1B3249 0%, #2B4A63 55%, #768D99 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 36px 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.auth-logo {
    display: block;
    height: 40px;
    margin: 0 auto 24px;
}

.auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 4px;
    color: var(--sts-midnight);
}

.auth-subtitle {
    font-size: 0.95rem;
    text-align: center;
    color: var(--sts-muted);
    margin: 0 0 24px;
    font-weight: 400;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-form label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--sts-muted);
    margin-bottom: 6px;
}

.auth-form input {
    font: inherit;
    padding: 11px 12px;
    margin-bottom: 16px;
    border: 1px solid #C5CED5;
    border-radius: 8px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--sts-midnight);
    box-shadow: 0 0 0 3px rgba(27, 50, 73, .15);
}

.auth-form .validation-message {
    color: #B3261E;
    font-size: .8rem;
    margin: -12px 0 12px;
}

.auth-button {
    font: inherit;
    font-weight: 600;
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    border: none;
    border-radius: 8px;
    background: var(--sts-midnight);
    color: #fff;
    cursor: pointer;
}

.auth-button:hover {
    background: #24425F;
}

.auth-button.danger {
    background: #B3261E;
}

.auth-alert, .auth-success {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .9rem;
}

.auth-alert {
    background: #FDECEA;
    color: #8A1C15;
}

.auth-success {
    background: #E8F3EC;
    color: #24563A;
}

.auth-switch {
    text-align: center;
    margin: 20px 0 0;
    font-size: .875rem;
}

.auth-switch a, .auth-footer a {
    color: var(--sts-midnight);
}

.auth-form input.code-input {
    font-size: 1.6rem;
    letter-spacing: 0.4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.auth-forgot {
    text-align: right;
    margin: 10px 0 0;
    font-size: .875rem;
}

.auth-forgot a {
    color: var(--sts-midnight);
}

.resend-form {
    margin: 16px 0 0;
    font-size: .875rem;
    color: var(--sts-muted);
    text-align: center;
}

.link-button {
    font: inherit;
    padding: 0;
    border: none;
    background: none;
    color: var(--sts-midnight);
    text-decoration: underline;
    cursor: pointer;
}

.auth-footer {
    margin-top: 20px;
    font-size: .85rem;
    color: rgba(255, 255, 255, .85);
}

.auth-footer a {
    color: #fff;
}

/* ---------- Documents ---------- */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.doc-item {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--sts-border);
}

.doc-item.doc-flagged {
    border-color: #E8C29F;
    background: #FFF8F1;
}

.doc-name {
    display: flex;
    align-items: center;
    gap: 6px;
    word-break: break-all;
    color: var(--sts-midnight);
    text-decoration: none;
    font-size: 0.9rem;
}

a.doc-name:hover {
    text-decoration: underline;
}

.doc-flag {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--sts-muted);
}

.doc-flag a {
    color: var(--sts-midnight);
}

.candidate-empty td {
    background: #F2F7F4;
}

.nowrap {
    white-space: nowrap;
}

.break-all {
    word-break: break-all;
}

/* ---------- Blazor defaults ---------- */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}
