:root {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: #263c32;
    background: #fafaf5;
    font-synthesis: none;
    --green: #215b48;
    --green-dark: #173e32;
    --sage: #eef2e9;
    --ink: #263c32;
    --muted: #596a60;
    --line: #dfe5db;
    --radius: 12px;
    --shadow: 0 12px 36px #23392b0b;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.6; }
h1, h2, h3, p, dl { margin: 0; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { font-size: clamp(1.85rem, 4.3vw, 3rem); letter-spacing: -.045em; }
h2 { font-size: clamp(1.15rem, 2.2vw, 1.45rem); letter-spacing: -.025em; }
h3 { font-size: 1rem; }
a { color: var(--green); text-underline-offset: 4px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
:focus-visible { outline: 3px solid #ae732b; outline-offset: 4px; }
.muted { color: var(--muted); }
.timestamp { font-variant-numeric: tabular-nums; }
.reference { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.verbatim { white-space: pre-wrap; overflow-wrap: anywhere; }

.container { width: min(1160px, calc(100% - 48px)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 2; top: -100px; left: 16px; padding: 10px 14px; background: var(--green); color: #fff; }
.skip-link:focus { top: 10px; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner, .header-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-inner { min-height: 82px; justify-content: space-between; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; line-height: 1.1; font-size: .88rem; }
.brand img { flex: none; border-radius: 9px; }
.brand strong { display: block; font-size: 1.25rem; letter-spacing: -.04em; }
.brand-dot { color: #87a35b; }
.portal-label { color: var(--green); font-size: .78rem; font-weight: 700; }

.portal-main { display: grid; gap: 20px; padding-block: 32px 56px; }
.centered { display: grid; justify-items: center; padding-block: clamp(40px, 9vw, 105px); }
.centered .card { width: min(100%, 460px); }
.page-heading, .card, .action-form { display: grid; gap: 16px; align-content: start; min-width: 0; }
.page-heading { gap: 8px; }
.page-heading p { font-size: .85rem; }
.back-link { justify-self: start; padding-block: 8px; font-weight: 650; }
.detail-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; }
.detail-heading { justify-content: flex-start; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card {
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
}
.login-card h1 { font-size: clamp(1.8rem, 4vw, 2.35rem); }
.empty-state { padding-block: 10px; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--green);
    border-radius: 6px;
    padding: 9px 15px;
    background: var(--green);
    color: #fff;
    font-size: .88rem;
    font-weight: 650;
    line-height: 1.35;
    text-align: center;
}
.button:not(:disabled):hover { background: var(--green-dark); border-color: var(--green-dark); }
.button.secondary { border-color: #b7c6b8; background: #fff; color: var(--green); }
.button.secondary:not(:disabled):hover { background: var(--sage); border-color: #b7c6b8; }
.button.delete-button { color: #8e332b; border-color: #d5b6af; }
.action-form { justify-items: start; gap: 12px; }
.login-card .action-form { justify-items: stretch; }
.lookup-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
label { display: grid; min-width: 0; gap: 4px; color: var(--ink); font-size: .875rem; font-weight: 650; }
input:not([type="checkbox"]):not([type="hidden"]) { min-height: 44px; width: 100%; padding: 8px 11px; border: 1px solid #aebcaf; border-radius: 7px; background: #fff; color: var(--ink); }
.check { display: flex; align-items: baseline; gap: 10px; font-weight: 500; }
.check input { flex: none; width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--green); }
.separated { border-top: 1px solid var(--line); padding-top: 16px; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 22px; }
.facts dt, .cell-label { color: var(--muted); font-size: .76rem; font-weight: 700; }
.facts dd { margin: 2px 0 0; }
.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .76rem;
    font-weight: 720;
    line-height: 1.55;
    background: var(--sage);
    color: var(--green-dark);
}
.status-new { background: #f8efd7; color: #684c1c; }
.status-processing { background: #e6eff8; color: #284b69; }
.status-completed { background: #e4f1e6; color: #22513a; }
.status-invoiced { background: #ede8f5; color: #554074; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; text-align: left; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { color: var(--muted); font-size: .78rem; }
tbody th { font-weight: 650; }
tbody tr:last-child > * { border-bottom: none; }
.cell-label { display: none; }
.item-list { display: grid; list-style: none; padding: 0; margin: 0; }
.item-list li { display: grid; gap: 6px; padding-block: 12px; border-top: 1px solid var(--line); min-width: 0; }
.documents li { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px 20px; }
.document-name { display: grid; gap: 2px; align-content: start; }
.notice { padding: 14px 16px; border-left: 3px solid #a7883f; border-radius: 4px; background: #f8f4e8; color: #61532e; }
.notice.danger { border-left-color: #a64c3f; color: #7c3029; background: #fbefeb; }
.antivirus { display: grid; gap: 10px; }

@media (max-width: 820px) {
    .container { width: calc(100% - 36px); }
    .detail-grid { grid-template-columns: 1fr; }
    .orders-table, .mail-table, tbody { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    tbody { display: grid; gap: 9px; }
    tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
    tbody th { grid-column: 1 / -1; }
    tbody th, tbody td { display: block; min-width: 0; padding: 0; border: 0; }
    .cell-label { display: block; }
    .mail-table tbody td:last-child { grid-column: 1 / -1; }
}

@media (max-width: 510px) {
    .container { width: calc(100% - 28px); }
    .portal-main { padding-top: 22px; gap: 14px; }
    .header-inner, .header-actions { gap: 8px; }
    .header-inner { min-height: 68px; }
    .brand { font-size: .75rem; }
    .brand img { width: 34px; height: 34px; }
    .brand strong { font-size: 1rem; }
    .header-actions .button { padding-inline: 9px; }
    .section-heading { align-items: flex-start; }
    .lookup-form { display: grid; width: 100%; }
    .documents li { grid-template-columns: 1fr; }
    .facts { grid-template-columns: 1fr; gap: 8px; }
}
