:root {
    color-scheme: light;
    --blue: #164e78;
    --accent: #137cbd;
    --border: #d9e1e8;
    --muted: #617385;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: #f3f5f7;
    color: #243447;
    font: 15px/1.5 Arial, sans-serif;
}

.portal-header {
    min-height: 72px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.portal-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: min(1180px, calc(100% - 32px));
    min-height: 72px;
    margin: auto;
}

.portal-brand {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.portal-brand img {
    display: block;
    width: auto;
    height: 44px;
}

.portal-document-title {
    color: var(--blue);
    font-size: 20px;
    font-weight: 700;
    text-align: right;
}

.portal-page {
    max-width: 1180px;
    margin: auto;
    padding: 24px 16px 60px;
}

.centered-page {
    max-width: 620px;
    margin: 12vh auto;
    padding: 0 16px;
}

.card {
    margin-bottom: 16px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 10px #17324a0d;
}

.centered-card {
    padding: 36px;
    text-align: center;
}

h1,
h2 {
    margin-top: 0;
    color: var(--blue);
}

h1 {
    margin-bottom: 6px;
    font-size: 28px;
}

h2 {
    font-size: 19px;
}

.muted {
    color: var(--muted);
}

.quote-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quote-detail {
    min-width: 0;
    padding: 10px 8px;
    border-top: 1px solid var(--border);
}

.quote-detail:nth-child(-n + 3) {
    border-top: 0;
}

.quote-detail b {
    display: block;
    margin-bottom: 5px;
    color: var(--blue);
    font-size: 14px;
}

.quote-detail-wide {
    grid-column: 1 / -1;
}

.quote-notes {
    margin-top: 18px;
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

button {
    padding: 9px 13px;
    border: 1px solid #aab8c5;
    border-radius: 6px;
    background: #fff;
    color: #243447;
    cursor: pointer;
    font: inherit;
}

button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

button.danger {
    color: var(--danger);
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

input,
textarea {
    width: 100%;
    padding: 9px;
    border: 1px solid #aab8c5;
    border-radius: 5px;
    font: inherit;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    outline: 2px solid #48aff055;
}

input[type="checkbox"] {
    width: auto;
}

.label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
}

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

.inline-field input {
    width: auto;
}

.block-field {
    display: block;
    margin-top: 16px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    background: #edf4f8;
    color: #345;
    font-size: 13px;
}

td.num,
th.num {
    text-align: right;
    white-space: nowrap;
}

tr.excluded {
    background: #f7f7f7;
    opacity: .55;
}

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

.line-title {
    font-weight: 700;
}

.line-note {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    white-space: pre-line;
}

.quote-text {
    white-space: pre-line;
}

.totals {
    min-width: 290px;
    margin-top: 16px;
    margin-left: auto;
}

.totals div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 4px 0;
}

.totals .grand {
    margin-top: 5px;
    padding-top: 8px;
    border-top: 2px solid var(--blue);
    font-size: 18px;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 16px;
}

.checks {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.checks label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.checks input {
    margin-top: 4px;
}

.error {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #f5b7ae;
    border-radius: 6px;
    background: #fff0ee;
    color: var(--danger);
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.success {
    padding: 44px 22px;
    text-align: center;
}

.spinner {
    width: 38px;
    height: 38px;
    margin: 24px auto;
    border: 4px solid #d6e3ec;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 760px) {
    .portal-header-content {
        gap: 12px;
    }

    .portal-brand img {
        height: 36px;
    }

    .portal-document-title {
        font-size: 16px;
    }

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

    .quote-detail-wide {
        grid-column: auto;
    }

    .portal-page {
        padding: 12px 8px 40px;
    }

    .card {
        padding: 16px;
    }

    h1 {
        font-size: 23px;
    }

    .totals {
        width: 100%;
        margin-left: 0;
    }
}
