:root {
    --ink: #172033;
    --muted: #637087;
    --line: #dce2eb;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --navy: #17365d;
    --blue: #2a66bc;
    --blue-light: #eaf2ff;
    --green: #0c7a4c;
    --green-light: #e8f7ef;
    --orange: #a95a00;
    --orange-light: #fff2df;
    --red: #b42318;
    --red-light: #ffefef;
    --shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    color: #ecf3ff;
    background: linear-gradient(180deg, #102947 0%, #0a1e36 100%);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 760;
    letter-spacing: 0.01em;
}

.brand-mark {
    color: #fff;
    background: #2f77d0;
    padding: 5px 7px;
    border-radius: 7px;
    font-size: 12px;
    letter-spacing: 0.08em;
}

.nav {
    display: grid;
    gap: 5px;
    margin-top: 34px;
}

.nav a {
    display: block;
    color: #bdcde0;
    padding: 11px 12px;
    border-radius: 7px;
    font-weight: 650;
}

.nav a:hover,
.nav a.active {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px 12px 6px;
}

.app-version {
    display: grid;
    gap: 2px;
    color: #bdcde0;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.app-version small {
    color: #7890aa;
    font-size: 11px;
    font-weight: 600;
}

.login-version {
    margin-top: 22px;
    color: var(--muted);
    text-align: center;
}

.login-version small {
    color: var(--muted);
}

.sign-out-fixed {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 15px;
    color: #ffffff;
    background: var(--navy);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(10, 30, 54, 0.22);
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
}

.sign-out-fixed:hover {
    color: #ffffff;
    background: #204873;
    text-decoration: none;
}

.sign-out-fixed:focus-visible {
    outline: 3px solid #b9d7ff;
    outline-offset: 3px;
}

.main-content {
    width: 100%;
    max-width: 1600px;
    padding: 32px 36px 54px;
}

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

.topbar h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.025em;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.topbar-meta {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    text-align: right;
}

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

.stat-card {
    background: var(--panel);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(17, 34, 58, 0.03);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 650;
    font-size: 13px;
}

.stat-card strong {
    display: block;
    font-size: 31px;
    line-height: 1;
    margin: 12px 0 7px;
}

.stat-card small {
    color: var(--muted);
}

.stat-card.attention strong {
    color: var(--red);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 2px 8px rgba(17, 34, 58, 0.03);
    margin-bottom: 18px;
}

.panel h2 {
    font-size: 18px;
    margin: 0 0 6px;
}

.panel p {
    color: var(--muted);
    margin: 0;
    line-height: 1.52;
}

.toolbar-panel,
.danger-panel,
.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.danger-panel {
    border-color: #f0c6c2;
    background: #fffafa;
}

.section-heading {
    margin: 0 0 18px;
    align-items: end;
}

.section-heading h2 {
    margin: 0 0 5px;
    font-size: 22px;
}

.section-heading p:not(.eyebrow) {
    color: var(--muted);
    margin: 0;
}

.with-action {
    align-items: center;
}

.section-heading .button {
    white-space: nowrap;
}

.section-heading .eyebrow {
    margin-bottom: 4px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 8px 13px;
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    text-decoration: none;
    filter: brightness(0.98);
}

.button.primary {
    color: #fff;
    background: var(--blue);
    border-color: var(--blue);
}

.button.secondary {
    color: var(--navy);
    background: #fff;
    border-color: #aeb9c9;
}

.button.ghost {
    color: var(--blue);
    background: transparent;
}

.button.danger {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.button.full {
    width: 100%;
}

.button.mini {
    min-height: 31px;
    padding: 5px 9px;
    font-size: 12px;
}

.button-row,
.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.inline-form {
    display: inline;
}

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

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

th {
    color: var(--muted);
    text-align: left;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0 10px 11px;
    border-bottom: 1px solid var(--line);
}

td {
    vertical-align: top;
    padding: 13px 10px;
    border-bottom: 1px solid #edf0f4;
}

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

td strong {
    display: block;
}

td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge.scheduled {
    color: #475569;
    background: #edf1f7;
}

.badge.created,
.badge.existing {
    color: var(--green);
    background: var(--green-light);
}

.badge.warning {
    color: var(--orange);
    background: var(--orange-light);
}

.badge.failed {
    color: var(--red);
    background: var(--red-light);
}

.form-panel {
    max-width: 1040px;
}

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

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

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

[data-schedule-mode][hidden] {
    display: none !important;
}

.field > span {
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

.field small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.42;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    min-height: 41px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #b9c4d3;
    border-radius: 7px;
    font: inherit;
}

input:focus,
select:focus {
    outline: 3px solid #d9e9ff;
    border-color: #4b8ce5;
}

select:disabled {
    color: #95a1b3;
    background: #f4f6f9;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
}

.checkbox-field input {
    width: 17px;
    height: 17px;
}

.checkbox-field span {
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.template-preview {
    margin-top: 3px;
    padding: 10px 12px;
    color: #2b4a70;
    background: var(--blue-light);
    border-radius: 6px;
    font-size: 13px;
}

.api-error,
.flash {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 7px;
    font-weight: 650;
}

.api-error,
.flash.error {
    color: #8c1d18;
    background: #fff1f0;
    border: 1px solid #f2c4c1;
}

.flash.success {
    color: #075c38;
    background: #edf9f2;
    border: 1px solid #bae8ce;
}

.flash.warning {
    color: #7a4500;
    background: #fff6e7;
    border: 1px solid #f1d09b;
}

.empty-state {
    padding: 35px 20px;
    text-align: center;
    color: var(--muted);
}

.empty-state p {
    margin-bottom: 15px;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #eaf1fa, #f7f8fb);
}

.login-shell {
    width: 100%;
    max-width: 430px;
}

.login-card {
    padding: 30px;
    background: #fff;
    border: 1px solid #dce3ec;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.login-brand {
    color: var(--navy);
    margin-bottom: 32px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.muted {
    color: var(--muted);
    margin: 0 0 22px;
}

.stack-form {
    display: grid;
    gap: 17px;
}

.stack-form label {
    display: grid;
    gap: 7px;
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

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

@media (max-width: 780px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        padding: 15px;
    }

    .nav {
        display: flex;
        flex-wrap: wrap;
        margin-top: 16px;
    }

    .nav a {
        padding: 8px 10px;
    }

    .sidebar-footer {
        margin-top: 12px;
        padding: 10px 8px 0;
    }

    .sign-out-fixed {
        right: 14px;
        bottom: 14px;
    }

    .main-content {
        padding: 22px 16px 36px;
    }

    .topbar,
    .toolbar-panel,
    .danger-panel,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-meta {
        text-align: left;
    }

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

    .field.full {
        grid-column: auto;
    }
}
.nav-heading {
    display: block;
    margin: 16px 12px 2px;
    color: #7890aa;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

[data-report-schedule][hidden],
[data-report-period][hidden] {
    display: none !important;
}

input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    min-height: 41px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #b9c4d3;
    border-radius: 7px;
    font: inherit;
}

textarea {
    min-height: 110px;
    line-height: 1.45;
    resize: vertical;
}

input[type="date"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: 3px solid #d9e9ff;
    border-color: #4b8ce5;
}

.grouped-field {
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 9px;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
}

.stack-form label.checkbox-field,
.checkbox-grid label.checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 650;
}

.stack-form label.checkbox-field small {
    flex-basis: 100%;
    margin-left: 26px;
}

.report-stats {
    margin-top: 2px;
}

@media (max-width: 780px) {
    .nav-heading {
        width: 100%;
        margin: 12px 8px 0;
    }

    .checkbox-grid {
        display: grid;
        grid-template-columns: 1fr;
    }
}


.delivery-history {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.delivery-history summary {
    cursor: pointer;
    font-weight: 750;
    color: var(--navy);
    margin-bottom: 12px;
}


.report-jump-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    padding: 12px 14px;
    background: var(--blue-light);
    border: 1px solid #d6e2f1;
    border-radius: 10px;
}

.report-jump-nav > span {
    margin-right: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.report-jump-nav .button {
    min-height: 34px;
    padding: 6px 11px;
    color: var(--blue);
    border-color: #9eb7d8;
    box-shadow: 0 1px 2px rgba(23, 32, 51, 0.04);
}

.report-jump-nav .button:hover {
    background: #f8fbff;
}

.report-anchor-section,
.report-section-anchor {
    scroll-margin-top: 20px;
}

.report-section-anchor {
    display: block;
    height: 0;
    overflow: hidden;
}

.project-task-table {
    min-width: 980px;
    table-layout: fixed;
}

.project-task-name-column {
    width: 30%;
}

.project-task-number-column {
    width: 13%;
}

.project-task-entry-column {
    width: 18%;
}

.project-task-table th:not(:first-child),
.project-task-table td:not(:first-child) {
    white-space: nowrap;
}

.project-summary-body + .project-summary-body .project-summary-row td,
.project-task-rows + .project-summary-body .project-summary-row td {
    border-top: 1px solid #dfe5ed;
}

.project-summary-row td {
    background: #ffffff;
    font-weight: 400;
}

.project-summary-row.has-task-details td {
    background: #f8fafc;
}

.project-summary-row.is-expanded td {
    background: var(--blue-light);
}

.project-task-toggle {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    font: inherit;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
}

.project-task-toggle:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
    border-radius: 4px;
}

.project-task-toggle-icon {
    flex: 0 0 14px;
    width: 14px;
    color: var(--blue);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.project-task-toggle-label,
.project-task-static-label {
    min-width: 0;
    color: var(--ink);
    font-weight: 400;
}

.project-task-rows td {
    background: #fbfdff;
    font-weight: 400;
}

.project-task-detail-row td:first-child {
    padding-left: 34px;
}

.project-task-detail-row:hover td {
    background: #f5f9fe;
}

.project-task-indent,
.project-task-name {
    display: inline-block;
    vertical-align: top;
}

.project-task-indent {
    width: 20px;
    color: #8da1bb;
    font-weight: 700;
}

.project-task-name {
    max-width: calc(100% - 24px);
}

.project-task-controls button:disabled {
    cursor: default;
    opacity: 0.45;
}

@media (max-width: 780px) {
    .report-jump-nav {
        align-items: stretch;
    }

    .report-jump-nav > span {
        width: 100%;
    }

    .report-jump-nav .button {
        flex: 1 1 150px;
    }

    .project-task-controls {
        width: 100%;
    }

    .project-task-controls .button {
        flex: 1 1 120px;
    }
}
