/* LB Υποθέσεις — one stylesheet. Tokens first; light theme default, dark follows the system. */
:root {
  --fs-1: 13px; --fs-2: 15px; --fs-3: 18px; --fs-4: 24px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --radius: 6px;
  --touch: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bg: #ffffff;
  --surface: #f6f7f7;
  --fg: #1b1f1f;
  --muted: #5d6666;
  --line: #dde2e2;
  --accent: #0B6E69;
  --accent-fg: #ffffff;
  --accent-soft: #e3f1f0;
  --warn-bg: #fff6e0;
  --warn-line: #e4c56d;
  --warn-fg: #5c4300;
  --error: #a61b1b;
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1b201f;
    --fg: #e6eaea;
    --muted: #9aa5a4;
    --line: #2d3534;
    --accent: #4FBFB6;
    --accent-fg: #0d1414;
    --accent-soft: #173533;
    --warn-bg: #2d260f;
    --warn-line: #6f5c1f;
    --warn-fg: #f1dc9c;
    --error: #ff8a80;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: var(--fs-2)/1.5 var(--font);
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--sp-5) var(--sp-4); }
h1 { font-size: var(--fs-4); line-height: 1.25; margin: 0 0 var(--sp-3); }
h2 { font-size: var(--fs-3); margin: var(--sp-6) 0 var(--sp-3); }
h3 { font-size: var(--fs-2); margin: var(--sp-5) 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.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;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--sp-4); top: var(--sp-2); z-index: 20; background: var(--bg); padding: var(--sp-2); }
.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: var(--fs-1); }
.lead { font-size: var(--fs-3); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: var(--sp-5) 0; color: var(--muted); font-size: var(--fs-3); }
.crumb { font-size: var(--fs-1); margin-bottom: var(--sp-2); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.kv { display: block; }
.warn-text { color: var(--warn-fg); }

/* Controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  min-height: var(--touch); padding: 0 var(--sp-4);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--accent-fg); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius);
}
button.secondary, .button.secondary { color: var(--accent); background: transparent; }
button.link {
  min-height: var(--touch); padding: 0 var(--sp-1); background: none; border: 0;
  color: var(--accent); font-weight: 400; text-decoration: underline; text-underline-offset: 2px;
}
input, textarea, select {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-2) var(--sp-3); min-height: var(--touch);
}
input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
input[type=file] { border: 0; padding-left: 0; }
label { display: block; }
form.inline { display: inline; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: var(--sp-2); }

/* Top bar */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4);
  padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.top nav { display: flex; gap: var(--sp-1); }
.top nav a {
  display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 var(--sp-3);
  color: var(--fg); text-decoration: none; border-radius: var(--radius);
}
.top nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top .seed { display: flex; gap: var(--sp-2); flex: 1 1 320px; max-width: 560px; }
.top .seed input { flex: 1; min-width: 0; }
.top .logout { margin-left: auto; }

/* Notices and flashes */
.flash, .notice { padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); margin-bottom: var(--sp-3); }
.flash { background: var(--accent-soft); }
.flash.error, p.error { color: var(--error); }
.flash.error { background: var(--warn-bg); }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); }
.done { color: var(--muted); margin: 0; }
.since { color: var(--muted); }
.coverage { margin-top: var(--sp-4); color: var(--muted); }

/* Day bar */
.daybar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-4); }
.daybar h1 { margin: 0; }
.daybar .step { display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 var(--sp-2); }
.daybar .jump { display: flex; gap: var(--sp-2); margin-left: auto; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); }
thead th { font-size: var(--fs-1); font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody + tbody { border-top: var(--sp-4) solid transparent; }
tr.case th { font-size: var(--fs-3); padding-top: var(--sp-4); border-bottom: 2px solid var(--fg); }
tr.case a { color: var(--fg); text-decoration: none; }
tr.case a:hover { text-decoration: underline; }
tr.dim td { color: var(--muted); }
tr:has(.done) td:not(.c-menu) { opacity: .55; }
.c-name strong { font-weight: 600; }
.c-stage { white-space: nowrap; }
.c-quote { max-width: 340px; }
.c-menu { width: 1%; white-space: nowrap; text-align: right; }

.badge {
  display: inline-block; padding: 1px var(--sp-2); border-radius: 999px; font-size: var(--fs-1); font-weight: 600;
  white-space: nowrap; border: 1px solid var(--accent);
}
.badge.new { background: var(--accent); color: var(--accent-fg); }
.badge.stage { color: var(--accent); }

/* One-line quote that expands */
details.quote summary {
  display: block; list-style: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic;
}
details.quote summary::-webkit-details-marker, details.menu summary::-webkit-details-marker { display: none; }
details.quote[open] summary { white-space: normal; }

/* «⋯» menu */
details.menu { position: relative; display: inline-block; text-align: left; }
details.menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--touch); min-height: var(--touch); padding: 0 var(--sp-2);
  border-radius: var(--radius); color: var(--accent); font-weight: 600;
}
details.menu summary:hover, details.menu[open] summary { background: var(--accent-soft); }
.menu-body {
  position: absolute; right: 0; z-index: 10; width: 300px; max-width: calc(100vw - 32px);
  padding: var(--sp-4); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); white-space: normal;
}
.casehead .menu-body { left: 0; right: auto; }
.menu-body .opt { display: flex; align-items: center; gap: var(--sp-2); min-height: 36px; }
.menu-body .note { margin: var(--sp-2) 0; font-size: var(--fs-1); }
.menu-body textarea { width: 100%; margin-top: var(--sp-1); min-height: 0; }

/* Sections */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-5); }
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.upload label { display: flex; align-items: center; gap: var(--sp-2); }
.casehead .actions { margin-top: var(--sp-3); }
.sugg { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.choices { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.search { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.search label { width: 100%; font-weight: 600; }
.search input { flex: 1 1 260px; }
.seeds li { font-size: var(--fs-1); }
.login { max-width: 360px; margin: var(--sp-6) auto; }
.login label { margin-bottom: var(--sp-3); }
.login input { width: 100%; margin-top: var(--sp-1); }
.login button { width: 100%; }

.foot {
  padding: var(--sp-4); text-align: center; font-size: var(--fs-1); color: var(--muted);
  border-top: 1px solid var(--line);
}

/* Under 640 px: each table row becomes a two-line list item */
@media (max-width: 639px) {
  main { padding: var(--sp-4); }
  .top .logout { margin-left: 0; }
  .daybar .jump { margin-left: 0; }
  table, tbody, tr, td, th { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  td, th { border: 0; padding: 0; }
  tbody + tbody { border-top: 0; }
  tr.case th { padding: var(--sp-4) 0 var(--sp-1); }
  tr.row, table.list tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-2);
    padding: var(--sp-3) 0; border-bottom: 1px solid var(--line);
  }
  tr.row::after { content: ""; flex-basis: 100%; order: 5; }
  .c-name { order: 1; } .c-badge { order: 2; } .c-stage { order: 3; }
  .c-menu { order: 4; margin-left: auto; width: auto; }
  .c-inv { display: none; }
  .c-quote { order: 6; flex: 1 1 0; min-width: 0; max-width: none; }
  .c-src { order: 7; font-size: var(--fs-1); }
  .c-name .sub, .c-src .sub, .c-stage .sub { display: inline; margin-left: var(--sp-1); }
  table.list td:first-child { flex-basis: 100%; }
  table.list td:not(:first-child):not(.c-menu) { font-size: var(--fs-1); color: var(--muted); }
  table.list td:not(:first-child):not(.c-menu) + td:not(.c-menu)::before { content: "· "; }
  .menu-body { position: fixed; left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); width: auto; }
}

/* «Ίδια υπόθεση με άλλη;» on the case page */
details.merge { margin-top: var(--sp-3); }
details.merge summary { cursor: pointer; color: var(--accent); min-height: var(--touch); display: inline-flex; align-items: center; }
details.merge form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-2); }
details.merge label { flex-basis: 100%; color: var(--muted); font-size: var(--fs-1); }
details.merge select { max-width: 100%; }

/* htmx failure message (app.js fills it; persistent until the page is reloaded) */
#htmx-error[hidden] { display: none; }
