:root {
    --bg: #f6f5f2; --surface: #ffffff; --text: #1d1d1f; --muted: #6b6b70;
    --line: #e2e0da; --accent: #2f5d50; --accent-text: #ffffff; --danger: #a4372b;
    --notice-bg: #eef4f1;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17181a; --surface: #202225; --text: #ececee; --muted: #9a9aa1;
        --line: #33363b; --accent: #7fb8a4; --accent-text: #10201b; --danger: #e58a7e;
        --notice-bg: #22302b;
    }
}
* { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }

.topbar {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 600; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }
.topbar nav a[aria-current="page"] { font-weight: 600; }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
main.narrow { max-width: 24rem; padding-top: 4rem; }

.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.notice { background: var(--notice-bg); border-radius: 8px; padding: .6rem .9rem; margin-bottom: 1rem; }
.error { color: var(--danger); font-size: .9rem; margin: .25rem 0 0; }

label { display: block; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], select, textarea {
    width: 100%; padding: .6rem .7rem; font: inherit; color: inherit;
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.field { margin-bottom: 1rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check label { margin: 0; }

button, .button {
    display: inline-block; padding: .55rem 1rem; font: inherit; cursor: pointer;
    background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
    text-decoration: none;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: 0; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }
.badge { font-size: .8rem; padding: .1rem .5rem; border-radius: 99px; background: var(--notice-bg); }
code, .codes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.codes { columns: 2; list-style: none; padding: 0; margin: 0 0 1rem; }
.qr { background: #fff; display: inline-block; padding: .75rem; border-radius: 8px; margin-bottom: 1rem; }
.pagination { display: flex; gap: .75rem; align-items: center; margin-top: 1rem; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin-bottom: .25rem; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.25rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.tile-value { font-size: 1.8rem; font-weight: 600; }
.tile-label { color: var(--muted); font-size: .9rem; }
.row-link { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.row-link:last-child { border-bottom: 0; }

.filters, .repeat { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.repeat { margin-bottom: .75rem; }
.repeat .field, .filters .field { margin-bottom: 0; min-width: 9rem; }
.field.grow { flex: 1 1 12rem; }
.field.full, .repeat.nested { flex: 1 1 100%; }
.repeat.nested { padding-left: 1rem; border-left: 2px solid var(--line); margin-bottom: 0; }
.checks { display: flex; flex-direction: column; gap: .2rem; }
.checks label { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .9rem; }
textarea { resize: vertical; }
input.short { width: 5.5rem; }
.settings-table { margin: .5rem 0 1rem; }
.settings-table input[type=text] { min-width: 5rem; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab { background: transparent; color: var(--text); border: 1px solid var(--line); }
.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(15rem, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; }
.board-column { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .75rem; align-self: start; }
.board-card { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .7rem; margin-bottom: .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-decoration: none; color: var(--text); font-size: .92rem; }

.states { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.state-axis { display: flex; flex-direction: column; gap: .35rem; }
.segmented { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { flex: 1; background: transparent; color: var(--text); border-radius: 0; padding: .45rem .6rem; font-size: .9rem; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }
.segmented button:disabled { cursor: default; }
.badge.state-inquiry { background: #f4e7c3; color: #5c4400; }
.badge.state-cancelled, .badge.state-lost { background: var(--line); color: var(--muted); }

.alert { border: 1px solid var(--danger); color: var(--danger); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
button:disabled { opacity: .6; cursor: progress; }

.checklist { margin-bottom: 1rem; }
.checklist ul, .attachments { list-style: none; padding: 0; margin: .35rem 0 0; font-size: .92rem; }
.checklist li.done { color: var(--muted); }
.archive-detail { margin: .6rem 0; padding: .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.notice ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.quick-add { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.quick-add .field { margin-bottom: 0; }
.todo { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.todo:last-of-type { border-bottom: 0; }
.todo .check { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 50%; width: 1.9rem; height: 1.9rem; padding: 0; flex: none; }
.todo-body { flex: 1; min-width: 0; }
.todo-title { text-align: left; color: var(--text); }
.todo-meta { font-size: .88rem; }
.todo-notes { margin: .25rem 0 0; white-space: pre-line; font-size: .92rem; }
.todo-checklist { list-style: none; padding: 0; margin: .35rem 0 0; font-size: .92rem; }
.todo-checklist button { color: var(--text); text-align: left; }
.done { color: var(--muted); text-decoration: line-through; }
h2.error { margin-bottom: .75rem; font-size: 1.1rem; }
.track { margin-bottom: .9rem; }
.track:last-child { margin-bottom: 0; }
.track-head { margin-bottom: .35rem; }
.steps { display: flex; flex-wrap: wrap; gap: .3rem; }
.step { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: .3rem .7rem; font-size: .88rem; }
.step.done { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.segmented button:disabled { opacity: 1; }

.order-head { margin-bottom: 1rem; }
.order-head .page-head { margin-bottom: .5rem; }
.head-states { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.head-states .badge { font-size: .88rem; padding: .2rem .7rem; }
.next-task { margin: 0; }
.glance { border-color: var(--accent); }
.glance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .9rem 1.5rem; margin: 0; }
.glance-grid dt { color: var(--muted); font-size: .85rem; margin-bottom: .15rem; }
.glance-grid dd { margin: 0; line-height: 1.6; }
.section-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 1.25rem; flex-wrap: wrap; padding: .6rem 0; margin-bottom: .5rem; background: var(--bg); border-bottom: 1px solid var(--line); }
.section-nav a { text-decoration: none; font-weight: 500; }
.section-title { font-size: 1.25rem; margin: 1.75rem 0 .75rem; scroll-margin-top: 3.5rem; }
h3 { font-size: 1.02rem; margin: 0 0 .75rem; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
