/* Oliekartotek — hand-written, mobile-first. No framework, no preprocessor.
   Design follows the approved mock-up: warm amber accent on cool grey ground,
   Barlow Condensed for headings/nav, IBM Plex Sans for body, IBM Plex Mono
   for part numbers and codes. Fonts are self-hosted (no CDN). */

@font-face {
    font-family: "Barlow Condensed";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("fonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
    font-family: "Barlow Condensed";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("fonts/barlow-condensed-700.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 100 700; /* variable font, one file covers all weights */
    font-display: swap;
    src: url("fonts/ibm-plex-sans.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --ground: #EEF1F3;
    --surface: #FFFFFF;
    --surface-2: #F6F8F9;
    --line: #D6DDE1;
    --line-soft: #E7ECEF;
    --ink: #12181C;
    --ink-2: #4A575F;
    --ink-3: #78868E;
    --accent: #B4741A;
    --accent-soft: #F6EBD9;
    --accent-ink: #8A5810;
    --accent-contrast: #FFFFFF;
    --ok: #256B4C;
    --ok-soft: #DFF0E7;
    --warn: #A9391F;
    --warn-soft: #F8E3DD;
    --shadow: 0 1px 2px rgba(18, 24, 28, .06), 0 8px 24px rgba(18, 24, 28, .07);
    --radius: 10px;
    --touch: 44px;
    --font-sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
    --font-condensed: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

/* Dark theme is an explicit opt-in via the topbar toggle (stored in
   localStorage, applied to <html> before first paint). The OS preference
   is deliberately ignored: the shop's other systems are light, so this
   one defaults to light everywhere. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --ground: #0F1417;
    --surface: #171E22;
    --surface-2: #1D262B;
    --line: #2C383F;
    --line-soft: #232D33;
    --ink: #E7EDF0;
    --ink-2: #A6B4BC;
    --ink-3: #7C8B94;
    --accent: #E0A343;
    --accent-soft: #332814;
    --accent-ink: #F0BE6C;
    --accent-contrast: #171E22;
    --ok: #6FCFA0;
    --ok-soft: #16301F;
    --warn: #EE8A6E;
    --warn-soft: #351A13;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--ground);
    -webkit-font-smoothing: antialiased;
}

h1, h2 {
    font-family: var(--font-condensed);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}
h1 { font-size: 24px; margin: 0 0 .5rem; }
h2 { font-size: 19px; margin: 1.75rem 0 .5rem; }
a { color: var(--accent-ink); }
code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--ink-2);
}

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.topbar__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    max-width: 70rem;
    margin: 0 auto;
    padding: 10px 16px;
}
.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    min-height: var(--touch);
    margin-right: 8px;
}
.topbar__mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-contrast);
    display: grid;
    place-items: center;
    font-family: var(--font-condensed);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: .04em;
}
.topbar__name {
    font-family: var(--font-condensed);
    font-weight: 600;
    font-size: 23px;
    letter-spacing: .02em;
    line-height: 1;
    text-transform: uppercase;
}
.topbar__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar__gear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch);
    height: var(--touch);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ink-3);
}
.topbar__gear:hover { color: var(--ink); background: var(--surface-2); }
/* Theme toggle shares the gear's look but is a <button> */
button.topbar__gear {
    appearance: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}
.theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }
.topbar__gear--active {
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-color: var(--line-soft);
}
.topbar__logout .link-button {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--ink-3);
    text-decoration: none;
}
.topbar__logout .link-button:hover { color: var(--ink); text-decoration: underline; }

/* Page */
.page {
    max-width: 70rem;
    margin: 0 auto;
    padding: 16px 16px 72px;
}
.page--bare {
    max-width: 24rem;
    padding-top: 12vh;
}
.page-intro { color: var(--ink-2); font-size: 14px; max-width: 62ch; margin-top: 0; }

/* Flash */
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash--success { background: var(--ok-soft); color: var(--ok); }
.flash--error { background: var(--warn-soft); color: var(--warn); }

/* Buttons */
.button, .link-button {
    font-family: var(--font-sans);
    font-size: 14.5px;
    cursor: pointer;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 18px;
    font-weight: 600;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-2);
    text-decoration: none;
}
.button:hover { border-color: var(--ink-3); color: var(--ink); }
.button--primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-contrast);
}
.button--primary:hover {
    filter: brightness(1.06);
    border-color: transparent;
    color: var(--accent-contrast);
}
.button--danger {
    background: var(--surface);
    border-color: var(--line);
    color: var(--warn);
}
.button--danger:hover { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.button--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.button--ghost:hover { background: var(--surface-2); border-color: transparent; }
.button--block { width: 100%; }
.button--small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.link-button {
    border: 0;
    background: none;
    color: var(--accent-ink);
    text-decoration: underline;
    min-height: var(--touch);
    padding: 0 8px;
}
.link-button--danger { color: var(--warn); }
.inline-form { display: inline; }
.button:focus-visible, .link-button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Forms */
.form-field { margin-bottom: 14px; }
.form-field__label {
    display: block;
    font-size: 12.5px;
    color: var(--ink-2);
    font-weight: 500;
    letter-spacing: .01em;
    margin-bottom: 5px;
}
.form-field input[type="text"],
.form-field input[type="search"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="file"],
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: var(--touch);
    padding: 9px 11px;
    font-family: var(--font-sans);
    font-size: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    background: var(--surface);
}
.form-field textarea { resize: vertical; }
.form-field__checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--touch);
    font-size: 14px;
}
.form-field__checkbox input { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); }
.form-field__choices { display: block; }
.form-field__message { color: var(--warn); font-size: 13px; }
.form-field__hint { color: var(--ink-3); font-size: 13px; }
.form-field--error input,
.form-field--error select,
.form-field--error textarea { border-color: var(--warn); }
.input--narrow { max-width: 6rem; }
.admin-form { max-width: 30rem; }

/* Panels — white cards that group a form or a section */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
}

/* Login */
.login__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}
.login__title { margin: 0; font-size: 26px; }
.login .panel { margin-top: 0; }
.login__back { text-align: center; margin: 16px 0 0; font-size: 14px; }
.login__back a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 12px;
    color: var(--ink-2);
    text-decoration: none;
}
.login__back a:hover { color: var(--ink); text-decoration: underline; }

/* Search */
.search { margin-bottom: 4px; }
.search__row { display: flex; gap: 8px; }
.search__wrap { position: relative; flex: 1; }
.search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
}
.search__input {
    width: 100%;
    min-height: var(--touch);
    padding: 12px 14px 12px 38px;
    font-family: var(--font-sans);
    font-size: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
}
.search__input::placeholder { color: var(--ink-3); }
.search__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.search__filter {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    text-decoration: none;
    color: var(--ink-2);
    font-size: 13px;
}
.search__filter:hover { border-color: var(--ink-3); }
.search__filter--active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--surface);
}

/* Results */
.resultline {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 14px 0 10px;
    font-size: 13px;
    color: var(--ink-3);
}
.resultline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.results__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.results__empty { text-align: center; padding: 48px 16px; color: var(--ink-3); }
.item-card { margin: 0; }
.item-card__link {
    display: block;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
}
.item-card__link:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.item-card__name {
    font-weight: 600;
    font-size: 15.5px;
    line-height: 1.3;
    display: block;
}
.item-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--ink-2);
}
.item-card__field .mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 5px;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--ink-2);
    border: 1px solid var(--line-soft);
    vertical-align: middle;
}
.badge--muted { background: var(--surface-2); color: var(--ink-3); }

/* Item detail */
.item__header { margin-bottom: 4px; }
.item__name { margin-bottom: 2px; }
.item__category { color: var(--ink-3); font-size: 13px; margin: 0 0 14px; }
.item__fields {
    margin: 0 0 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 18px;
}
.item__field {
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 14px;
}
.item__field:last-child { border-bottom: none; }
.item__field dt { color: var(--ink-2); font-weight: 400; }
.item__field dd { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.item__attachments h2, .item-form__attachment-admin h2 {
    font-size: 13px;
    letter-spacing: .1em;
    color: var(--ink-3);
    margin: 18px 0 8px;
}
.attachment-list { list-style: none; padding: 0; margin: 0 0 16px; }
.attachment-list li { margin-bottom: 6px; font-size: 14px; }
.attachment-list a { font-weight: 500; text-decoration: none; }
.attachment-list a:hover { text-decoration: underline; }
.item__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Tables */
.table-wrap {
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.table th {
    font-family: var(--font-condensed);
    text-transform: uppercase;
    font-size: 12.5px;
    letter-spacing: .09em;
    color: var(--ink-3);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
}
.table tr:last-child td { border-bottom: none; }
.table__row--muted { color: var(--ink-3); }
.table__actions { white-space: nowrap; }

.item-form__actions { display: flex; gap: 10px; margin-top: 18px; }

/* Settings hub — the pages behind the gear icon */
.settings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
    max-width: 34rem;
}
.settings-list__link {
    display: block;
    padding: 14px 40px 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    position: relative;
}
.settings-list__link::after {
    content: "\203A";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 22px;
    color: var(--ink-3);
}
.settings-list__link:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.settings-list__title { display: block; font-weight: 600; font-size: 15.5px; }
.settings-list__description { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-2); }

/* Sheet overlay — with JavaScript an item opens in a side panel (bottom
   sheet on small screens) instead of navigating. Same fragment as the
   standalone item page. */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(10, 14, 17, .45);
}
body.sheet-open { overflow: hidden; }
.sheet {
    position: fixed;
    z-index: 41;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(460px, 100%);
    background: var(--surface);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .22s ease;
    visibility: hidden;
}
.sheet--open { transform: none; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
@media (max-width: 620px) {
    .sheet {
        top: auto;
        width: 100%;
        max-height: 88vh;
        border-left: none;
        border-top: 1px solid var(--line);
        border-radius: 14px 14px 0 0;
        transform: translateY(100%);
    }
}
.sheet__bar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: flex-end;
    padding: 12px 14px 0;
    background: var(--surface);
}
.sheet__close {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    width: 30px;
    height: 30px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
}
.sheet__close:hover { color: var(--ink); border-color: var(--ink-3); }
.sheet__body { padding: 0 18px 28px; }
.sheet .item__name {
    font-family: var(--font-sans);
    text-transform: none;
    letter-spacing: 0;
    font-size: 18px;
}
.sheet .item__fields {
    background: transparent;
    border: none;
    padding: 0;
}
.sheet .item__back { display: none; }

/* Callout — accent-edged note, used for hints that need weight */
.callout {
    margin-top: 20px;
    border-left: 3px solid var(--accent);
    background: var(--surface-2);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: var(--ink-2);
}

@media (min-width: 40rem) {
    h1 { font-size: 27px; }
    .admin-form--inline {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        max-width: none;
    }
    .admin-form--inline .form-field { margin-bottom: 0; flex: 1; }
    .admin-form--inline .form-field:has(.input--narrow) { flex: 0; }
}
