/* v.0.2.0 2026-11-25 | Niramaya tokens (brand-guide.md), mobile-first, grid on >= 820px */
:root {
  --ink: #1A1A1A; --ink-soft: #4a463f; --muted: #7a7366;
  --gold: #B08D2E; --gold-deep: #8f6f1f; --gold-tint: #f6efdc;
  --paper: #FBFAF7; --card: #ffffff; --line: #EBE5D8; --line-soft: #F2EDE2;
  --red: #b3261e; --red-tint: #fbeceb; --amber: #8a5a00; --amber-tint: #fdf3dd; --green: #2f6b4f;
  --r: 12px; --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--paper); }
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--red); min-height: 1.4em; margin: 10px 0 0; }
.red { color: var(--red); font-weight: 600; }
.amber { color: var(--amber); font-weight: 600; }

/* Buttons */
.btn { min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost-red { color: var(--red); border-color: transparent; background: none; }
.btn.ghost-red.armed { background: var(--red); color: #fff; }
.icon { min-width: var(--tap); min-height: var(--tap); border: 0; background: none; font-size: 20px; cursor: pointer; border-radius: var(--r); color: var(--ink-soft); }
.link { border: 0; background: none; color: var(--gold-deep); font-weight: 600; cursor: pointer; padding: 6px 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Inputs */
input, select, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
textarea { resize: vertical; min-height: 64px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* Login */
.login { max-width: 400px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 20px 32px; }
.login h1 { font-size: 24px; margin: 0 0 28px; }
.login label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: var(--paper); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { flex: 1; max-width: 140px; min-height: 40px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.menu { position: absolute; right: 12px; top: 56px; display: flex; flex-direction: column; min-width: 220px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.menu button { text-align: left; min-height: var(--tap); padding: 0 12px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.menu span { padding: 8px 12px 4px; }

/* Toolbar */
.bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
.bar #search { grid-column: 1 / -1; }
.bar #add-btn { grid-column: 1 / -1; }
.bar #f-status[hidden] + #add-btn { grid-column: 2; }
.summary { padding: 0 14px; margin: 0 0 6px; min-height: 1.4em; }

/* Phone cards */
.list { padding: 0 12px 96px; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cards li { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding-left: 4px; }
.cards li.late { border-left: 3px solid var(--red); }
.cards li.today { border-left: 3px solid var(--amber); }
.cards li.done .card-title { text-decoration: line-through; color: var(--muted); }
.card-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-height: 56px; padding: 10px 12px; border: 0; background: none; text-align: left; cursor: pointer; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }
.card-meta { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 6px; align-items: center; }
.card-meta i { font-style: normal; opacity: .6; }

/* Done check */
.check { flex: none; width: var(--tap); height: var(--tap); border: 0; background: none; cursor: pointer; position: relative; }
.check::before { content: ""; position: absolute; inset: 11px; border: 2px solid var(--muted); border-radius: 50%; }
.check.on::before { background: var(--green); border-color: var(--green); }
.check.on::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }

/* Tags */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-soft); color: var(--ink-soft); white-space: nowrap; }
.t-problem, .t-blocked, .t-lowstock, .t-high { background: var(--red-tint); color: var(--red); }
.t-follow-up, .t-in-progress, .t-medium { background: var(--amber-tint); color: var(--amber); }
.t-buy, .t-client { background: var(--gold-tint); color: var(--gold-deep); }
.t-done { background: #e7f2ec; color: var(--green); }

/* Empty / loading */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.skel div { height: 58px; margin-bottom: 8px; border-radius: var(--r); background: linear-gradient(90deg, var(--line-soft), #fff, var(--line-soft)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* Record panel: full-screen sheet on phone, side panel on laptop */
.scrim { position: fixed; inset: 0; background: rgba(17,16,16,.28); z-index: 9; }
.panel { position: fixed; inset: 0; z-index: 10; overflow-y: auto; background: var(--paper); padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.panel-head { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 0 10px; background: var(--paper); border-bottom: 1px solid var(--line); margin-bottom: 14px; z-index: 1; }
.panel-head h2 { flex: 1; margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: 13px; color: var(--muted); }
.fld.wide, .fld:has(textarea) { grid-column: 1 / -1; }
.fld.saved input, .fld.saved select, .fld.saved textarea { border-color: var(--green); transition: border-color .2s; }
.fields .btn.block { grid-column: 1 / -1; }
.sec { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.sec h3, .sec summary { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; cursor: pointer; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.notes, .hist { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.notes li, .hist li { font-size: 15px; overflow-wrap: anywhere; }
.notes time, .hist time { display: block; font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.danger { margin-top: 28px; text-align: center; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 16px; max-width: calc(100% - 24px); padding: 12px 16px; background: var(--ink); color: #fff; border-radius: var(--r); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast .link { color: var(--gold-light, #d8b95e); }

/* Hover only where a real pointer exists (no sticky hover on phones) */
@media (hover: hover) {
  .btn.primary:hover { background: var(--ink); border-color: var(--ink); }
  .icon:hover, .menu button:hover { background: var(--line-soft); }
  .check:hover::before { border-color: var(--green); }
  .grid tr:hover td { background: #fdfcf8; }
}

/* Laptop */
@media (min-width: 820px) {
  .top { padding: 10px 24px; }
  .tabs { flex: none; }
  .tabs button { min-width: 110px; }
  .top .icon { margin-left: auto; }
  .menu { right: 24px; }
  .bar { display: flex; padding: 14px 24px; }
  .bar #search { flex: 1; max-width: 420px; }
  .bar select { width: auto; min-width: 160px; }
  .bar #add-btn { margin-left: auto; }
  .summary { padding: 0 26px; }
  .list { padding: 0 24px 48px; }
  .grid-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
  .grid { width: 100%; border-collapse: collapse; font-size: 15px; }
  .grid th { position: sticky; top: 0; background: var(--card); text-align: left; border-bottom: 1px solid var(--line); padding: 0; }
  .th { width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
  .grid td { padding: 0 12px; height: 44px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; cursor: text; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid td.c-title { font-weight: 600; max-width: 380px; }
  .grid td.c-check, .grid td.c-open { width: 44px; padding: 0; cursor: default; }
  .grid tr.late td.f-due_date, .grid tr.late td.f-next_step_date { color: var(--red); font-weight: 600; }
  .grid tr.today td.f-due_date, .grid tr.today td.f-next_step_date { color: var(--amber); font-weight: 600; }
  .grid tr.done td.c-title { text-decoration: line-through; color: var(--muted); }
  .grid td.editing { padding: 2px; overflow: visible; }
  .grid td.editing input, .grid td.editing select { min-height: 38px; padding: 6px 8px; border-color: var(--gold); }
  .scrim { background: rgba(17,16,16,.12); }
  .panel { left: auto; width: 460px; border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0,0,0,.06); padding: 0 24px 32px; }
}
