:root {
    --fg: #1a1a1a;
    --fg-muted: #666;
    --bg: #fafafa;
    --accent: #0b5cff;
    --border: #e2e2e2;
    --max: 720px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fg: #f0f0f0;
        --fg-muted: #aaa;
        --bg: #161616;
        --border: #2a2a2a;
        --accent: #6ea4ff;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover, a:focus { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 600;
    color: var(--fg);
    font-size: 1.1rem;
}

.site-header nav { display: flex; gap: 1rem; }

.container {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    color: var(--fg-muted);
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h1 small { color: var(--fg-muted); font-weight: normal; font-size: 1rem; margin-left: 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }

.search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.search label { position: absolute; left: -9999px; }
.search input {
    flex: 1 1 200px;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    min-height: 44px;
}
.search button {
    padding: 0.65rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
}

.product-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--border);
}
.product-list li { border-bottom: 1px solid var(--border); }
.product-list a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.85rem 0.25rem;
    color: var(--fg);
    gap: 1rem;
    min-height: 44px;
}
.product-list a:hover, .product-list a:focus { background: rgba(11, 92, 255, 0.06); text-decoration: none; }
.product-name { font-weight: 500; }
.product-size { color: var(--fg-muted); font-size: 0.95rem; }

.empty { color: var(--fg-muted); }
.notes { color: var(--fg-muted); font-style: italic; }
.error {
    color: #b00020;
    border-left: 3px solid #b00020;
    padding: 0.5rem 0.75rem;
    background: rgba(176, 0, 32, 0.05);
}

section { margin-top: 1.5rem; }

.form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}
.form label { font-weight: 500; }
.form input {
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    min-height: 44px;
}
.form button {
    padding: 0.65rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
    align-self: flex-start;
}

.hint { color: var(--fg-muted); font-weight: normal; font-size: 0.9rem; }

.stats-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.stats-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.stats-list li:last-child { border-bottom: 0; }

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.history-table th, .history-table td {
    text-align: left;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.history-table th { font-weight: 600; color: var(--fg-muted); }
.history-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 480px) {
    .history-table th:nth-child(4),
    .history-table td:nth-child(4) { display: none; }
}

.form textarea {
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    font-family: inherit;
    resize: vertical;
}

.form fieldset.kind {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
}
.form fieldset.kind legend { padding: 0 0.25rem; font-weight: 500; }
.form .radio { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; }

.form .row { display: flex; gap: 0.75rem; }
.form .col { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.form .row label { font-weight: 500; }

.inline-form { display: inline; margin: 0; }
.link-button {
    background: none;
    border: 0;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: none;
}
.link-button:hover, .link-button:focus { text-decoration: underline; }
