:root {
    --ink: #242d26;
    --muted: #505c52;
    --pine: #193b31;
    --pine-hover: #285144;
    --paper: #f2f3ed;
    --surface: #fffefb;
    --line: #d6dbd1;
    --serif: "Times New Roman", Times, serif;
    color: var(--ink);
    background: var(--paper);
    font: 15px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--pine); text-underline-offset: .2em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 4px; }
h1, h2, p { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 400; }
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); line-height: 1; }
h2 { font-size: 1.7rem; line-height: 1.12; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner, .shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.top-inner, .top nav, .brand { display: flex; align-items: center; gap: 16px; }
.top-inner { min-height: 68px; justify-content: space-between; }
.brand { gap: 12px; font: 1.4rem var(--serif); text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 4px; flex: none; }
.top nav { font-size: .9rem; }
.db-link, .link-button { white-space: nowrap; }
.db-link {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    text-decoration: none;
}
.db-link:hover, .secondary:hover { background: #e9ede5; }
.link-button { padding: 0; border: 0; color: var(--pine); background: transparent; text-decoration: underline; }

.shell { padding-block: 48px 64px; }
.login-shell { padding-block-start: clamp(36px, 8vh, 84px); }
.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    max-width: 1000px;
    margin-inline: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.login-art {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 480px;
    object-fit: cover;
    object-position: 50% 54%;
    background: #bdbaa9;
}
.login-content { align-self: center; padding: 40px clamp(28px, 4.4vw, 60px); }
.login-content h1 { font-size: clamp(2.2rem, 4.2vw, 3.4rem); }
.subtitle { margin-top: 12px; color: var(--muted); overflow-wrap: anywhere; }
.login-content .subtitle { max-width: 33ch; }
.fields { display: grid; gap: 16px; }
.login-content .fields { margin-top: 24px; }
.fields label { display: grid; align-content: start; gap: 6px; min-width: 0; }
input, select {
    min-width: 0;
    min-height: 44px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #acb7ab;
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid var(--pine);
    border-radius: 4px;
    background: var(--pine);
    color: #fff;
    font-weight: 550;
    text-align: center;
    text-decoration: none;
}
.button:hover { background: var(--pine-hover); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--pine); }
.button.secondary:hover { background: #e9ede5; }
.login-content .fields > .button:first-of-type { margin-top: 4px; }
.login-content .fields > .button.secondary { margin-top: -8px; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.back { display: inline-block; margin-bottom: 20px; font-size: .9rem; }
.catalog-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.catalog-meta span + span { padding-inline-start: 16px; border-inline-start: 1px solid #aeb9aa; }
.products { padding: 0; margin: 0; list-style: none; display: grid; gap: 12px; }
.product {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
    grid-template-areas: 'details cost';
    gap: 24px;
    padding: 16px 20px 16px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.product.editable:hover, .product:focus-within { border-color: #879b85; }
.product-info { grid-area: details; align-self: center; min-width: 0; }
.product-type { margin-bottom: 4px; color: var(--muted); font-size: .84rem; }
.product h2 { overflow-wrap: anywhere; }
.product-link { text-decoration: none; }
.product-link:hover, .product-link:focus-visible { text-decoration: underline; }
.product-link::after { position: absolute; inset: 0; content: ""; }
.facts { display: flex; flex-direction: column; gap: 4px 16px; margin: 10px 0 0; color: var(--muted); font-size: .84rem; }
.facts div { display: flex; flex-wrap: wrap; gap: 0 5px; }
.facts dt::after { content: ":"; }
.facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.cost {
    grid-area: cost;
    align-self: center;
    padding-inline-start: 20px;
    border-inline-start: 1px solid var(--line);
    text-align: end;
}
.cost > span { color: var(--muted); font-size: .84rem; }
.cost strong { display: block; color: var(--pine); font: 1.75rem/1.12 var(--serif); overflow-wrap: anywhere; }
.cost a { position: relative; display: inline-block; margin-top: 8px; font-size: .86rem; }
.cost a:hover { text-decoration-thickness: 2px; }
.cost strong, .facts dd, td:last-child { font-variant-numeric: tabular-nums; }

.panel, .empty { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 24px; }
.edit-form { max-width: 760px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 4px; }
.materials-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; gap: 20px; }
.calculator { border-top: 3px solid var(--pine); }
#calculator-feedback { scroll-margin-top: 16px; }
.calculator .fields { margin-top: 20px; }
.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: start; }
th { background: #e9eee6; font-size: .9rem; }
td { border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { text-align: end; white-space: nowrap; }
.message { border: 1px solid; border-inline-start-width: 4px; border-radius: 4px; margin-block: 16px; padding: 10px 14px; }
.message ul { margin: 4px 0 0; padding-inline-start: 20px; }
.message.error { background: #fff3eb; border-color: #aa5c4b; color: #74382c; }
.message.success { background: #eaf2e8; border-color: #779675; color: #284528; }
.calculator .message { margin: 0; }
.calculator .message strong { font-size: 1.25rem; }

@media (prefers-reduced-motion: no-preference) {
    .button, .db-link, .product { transition: background-color 150ms ease, border-color 150ms ease; }
}
@media (max-width: 850px) {
    .materials-layout { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 680px) {
    .top-inner, .shell { width: calc(100% - 32px); }
    .top-inner { min-height: 60px; }
    .top nav { gap: 8px; }
    .brand { font-size: 1.15rem; gap: 8px; }
    .brand img { width: 28px; height: 28px; }
    .db-link { padding: 6px 8px; font-size: .82rem; gap: 4px; }
    .shell { padding-top: 28px; }
    .login-layout { grid-template-columns: 1fr; }
    .login-art { height: clamp(188px, 44vw, 264px); min-height: 0; }
    .login-content { padding: 24px; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 20px; }
    .catalog-meta { gap: 4px 10px; }
    .catalog-meta span + span { padding-inline-start: 10px; }
    .product {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: 'details' 'cost';
        padding: 12px;
        gap: 12px;
    }
    .product h2 { font-size: 1.55rem; }
    .facts { gap: 4px 12px; }
    .cost {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0 8px;
        padding: 8px 0 0;
        border: 0;
        border-block-start: 1px solid var(--line);
        text-align: start;
    }
    .cost strong { grid-column: 1; font-size: 1.55rem; }
    .cost a { grid-column: 2; grid-row: 1 / span 2; align-self: end; margin: 0; }
    .panel, .empty { padding: 16px; }
    .field-grid { grid-template-columns: 1fr; }
}
@media (max-width: 365px) {
    .top-inner { gap: 8px; }
    .top .brand img { display: none; }
    .cost { grid-template-columns: 1fr; }
    .cost a { grid-column: 1; grid-row: auto; margin-top: 4px; }
}
