/* kyu.at — one stylesheet, no build step. */
:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #1c1b19;
  --ink-soft: #6b6862;
  --line: #e3e1dc;
  --accent: #2f5d50;
  --accent-soft: #e7efec;
  --amber: #9a6700;
  --amber-soft: #fff5e0;
  --red: #a12a1f;
  --red-soft: #fdeceb;
  --green: #1f6b3a;
  --green-soft: #e7f4ec;
  --blue: #24557f;
  --blue-soft: #e8f0f8;
  --radius: 10px;
  --control-height: 2.3rem;
  --control-height-small: 1.85rem;
  --control-radius: 8px;
  --shadow: 0 1px 2px rgba(28,27,25,.06), 0 8px 24px rgba(28,27,25,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: .5rem 1rem; z-index: 10; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh;
}
.brand a { font-size: 1.35rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.brand-sub { display: block; font-size: .82rem; color: var(--ink-soft); margin-top: .1rem; }
.nav { display: flex; flex-direction: column; gap: .1rem; }
.nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .45rem .6rem; border-radius: 8px; color: var(--ink); font-size: .94rem;
}
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pill { background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .42rem; font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: .85rem; color: var(--ink-soft); display: grid; gap: .5rem; }
.who { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.main { flex: 1; padding: 1.6rem 2rem 4rem; max-width: 1180px; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .main { padding: 1rem; }
  .grid-2, .grid-3, .grid-side { grid-template-columns: 1fr; }
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
.stat b { display: block; font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; }
.stat span { color: var(--ink-soft); font-size: .85rem; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* Lists */
.doclist { list-style: none; margin: 0; padding: 0; }
.doclist li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.doclist li:last-child { border-bottom: 0; }
.doclist-main { flex: 1; min-width: 0; color: var(--ink); }
.doclist-main:hover { text-decoration: none; }
.doclist-main:hover .doclist-title { text-decoration: underline; }
.doclist-title { display: block; font-weight: 560; }
.doclist-meta { display: flex; flex-wrap: wrap; gap: .5rem; color: var(--ink-soft); font-size: .84rem; margin-top: .12rem; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.empty { color: var(--ink-soft); padding: .7rem 0; }

/* Badges */
.badge, .tag { border-radius: 999px; font-size: .74rem; padding: .12rem .5rem; font-weight: 600; white-space: nowrap; }
.tag { background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); font-weight: 500; }
.tag-amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag-grey { background: var(--bg); color: var(--ink-soft); }
.badge-grey { background: var(--bg); color: var(--ink-soft); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }

/* Tasks */
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.tasklist li:last-child { border-bottom: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 560; }
.task-done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .84rem; color: var(--ink-soft); margin-top: .15rem; }
.due-over { color: var(--red); font-weight: 600; }
.due-soon { color: var(--amber); font-weight: 600; }
.due-later { color: var(--ink-soft); }
.check { appearance: none; width: 20px; height: 20px; border: 1.5px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; margin-top: .15rem; }
.check:hover { border-color: var(--accent); }

/* Forms */
label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .2rem; }

/* Every control is the same shape and the same height, whatever it is:
   a text field, a date, a dropdown or a button. Browsers disagree about all
   three by default, so appearance is switched off and set here instead. */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=url],
select, textarea, .btn, .searchbar input[type=search] {
  box-sizing: border-box;
  /* A fixed height rather than a minimum: a native date field measures its own
     contents and ends up a pixel or two taller than everything beside it. */
  height: var(--control-height);
  padding: .42rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fff;
  font: inherit;
  font-size: .95rem;
  line-height: 1.35;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { height: auto; min-height: 5.2rem; resize: vertical; line-height: 1.5; }

/* The dropdown keeps its arrow, drawn rather than inherited. */
select {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b6862' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: .7rem;
}
select:disabled { color: var(--ink-soft); background-color: var(--bg); }

/* Dates: the same box as the rest, with the picker button kept usable. */
input[type=date] { min-width: 9.5rem; }
input[type=date]::-webkit-datetime-edit { padding: 0; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
.field { margin-bottom: .75rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 160px; }
.checkbox { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--ink); margin-bottom: .4rem; }
.checkbox input { width: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font-weight: 560; cursor: pointer; text-align: center; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #26493f; }
.btn-danger { color: var(--red); border-color: #f0d4d1; }
.btn.btn-small { height: var(--control-height-small); padding: .2rem .6rem; font-size: .84rem; }
.btn-block { display: flex; width: 100%; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.inline-form { display: inline; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .field { margin: 0; }
.toolbar .btn { align-self: flex-end; }

/* Flash */
.flashes { margin-bottom: 1rem; display: grid; gap: .5rem; }
.flash { padding: .6rem .8rem; border-radius: 8px; font-size: .92rem; border: 1px solid transparent; }
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }
.flash-info { background: var(--blue-soft); color: var(--blue); }

/* Document detail */
.doc-viewer { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.doc-viewer img { max-width: 100%; }
.kv { display: grid; grid-template-columns: 40% 1fr; gap: .3rem .6rem; font-size: .9rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }
.trail { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.trail li { position: relative; padding: .5rem 0 .5rem 1rem; }
.trail li::before { content: ""; position: absolute; left: -6px; top: 1rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.trail li.is-current::before { background: var(--accent); }
.doctext { white-space: pre-wrap; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fbfbfa; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; max-height: 460px; overflow: auto; }
details > summary { cursor: pointer; font-weight: 560; padding: .3rem 0; }

/* Tree */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 0; }
.tree ul { padding-left: 1.1rem; border-left: 1px solid var(--line); margin-left: .4rem; }
.tree li { padding: .18rem 0; }
.tree .count { color: var(--ink-soft); font-size: .82rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: .82rem; }
tr:last-child td { border-bottom: 0; }
.pagination { display: flex; gap: .35rem; align-items: center; margin-top: .8rem; flex-wrap: wrap; }
.pagination a { padding: .15rem .5rem; border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; }
.pagination a.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 2.5rem 1.5rem; text-align: center;
  background: var(--panel); transition: border-color .15s, background .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone h2 { margin-bottom: .3rem; }
.uploads { list-style: none; margin: 1rem 0 0; padding: 0; font-size: .9rem; }
.uploads li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: .8rem; display: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Bare pages */
body.bare { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }
.bare-wrap { width: 100%; max-width: 460px; }
.bare-wrap.wide { max-width: 720px; }
.bare-brand { font-size: 1.6rem; font-weight: 700; margin-bottom: 1rem; letter-spacing: -.02em; }
.checklist { list-style: none; margin: 0 0 1rem; padding: 0; font-size: .9rem; }
.checklist li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.ok { color: var(--green); font-weight: 600; }
.nok { color: var(--red); font-weight: 600; }
.warn { color: var(--amber); font-weight: 600; }

/* Search */
.searchbar { position: relative; display: flex; gap: .5rem; margin-bottom: 1.1rem; }
.searchbar input[type=search] { flex: 1; }
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: .25rem; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.suggest a { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem .7rem; color: var(--ink); font-size: .9rem; }
.suggest a:hover, .suggest a.is-active { background: var(--accent-soft); text-decoration: none; }
.suggest .kind { color: var(--ink-soft); font-size: .78rem; text-transform: lowercase; }
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }
.result-title { font-weight: 580; font-size: 1.02rem; }
.snippet { margin: .3rem 0 0; color: var(--ink-soft); font-size: .88rem; line-height: 1.5; }
mark { background: #fff2a8; color: inherit; padding: 0 .1em; border-radius: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; gap: .3rem; align-items: center; padding: .18rem .55rem; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-size: .84rem; color: var(--ink);
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-filter { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip form { display: inline; }
.chip .remove { background: none; border: 0; color: var(--ink-soft); cursor: pointer; padding: 0 0 0 .1rem; font-size: .9rem; line-height: 1; }
.chip .remove:hover { color: var(--red); }
table.help td { padding: .25rem .5rem .25rem 0; border: 0; vertical-align: top; }
table.help td:first-child { white-space: nowrap; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .3rem; font-size: .86em; }

/* Security */
.qr-wrap { display: flex; justify-content: center; padding: .8rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-wrap svg { max-width: 260px; height: auto; }
.mono-key { font: 1.05rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem .8rem; font: .95rem ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: .5rem; }
.answer { font-size: 1.02rem; line-height: 1.65; }
.chip-form { display: inline; }
.chip-form .chip { cursor: pointer; font: inherit; font-size: .84rem; }

/* Instructions instead of forms */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The document list */
.table-scroll { overflow-x: auto; }
.doctable { width: 100%; font-size: .9rem; }
.doctable th { white-space: nowrap; }
.doctable td { vertical-align: top; }
.doctable td .amount { margin-left: .4rem; font-size: .85rem; }
.nowrap { white-space: nowrap; }
