/* Nahla Office. Calm, ledger-like: the number of days leads every line. */
:root {
  --ink: #1B2131;
  --ink-2: #3A4152;
  --muted: #6A6E78;
  --stone: #F2F1EE;
  --surface: #FFFFFF;
  --line: #E2DED7;
  --line-2: #D2CCC2;
  --tan: #BD9C73;
  --tan-ink: #8A6A42;
  --tan-wash: #F4EDE3;
  --wine: #5C2441;
  --wine-wash: #F5EAEF;
  --ok: #46624F;
  --ok-wash: #E9F0EA;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-variation-settings: 'wdth' 100;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--stone);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; padding-bottom: calc(72px + var(--safe-b)); }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--stone) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-variation-settings: 'wdth' 88; font-size: 17px; letter-spacing: 0.01em; }
.brand img { border-radius: 7px; }

.rail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.rail a {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 2px;
  text-decoration: none; font-size: 13px; font-weight: 500; color: var(--muted);
  font-variation-settings: 'wdth' 90;
  border-radius: var(--radius-s);
  -webkit-tap-highlight-color: transparent;
}
.rail a[aria-current='page'] { color: var(--ink); }
.rail a[aria-current='page']::after {
  content: ''; position: absolute; left: 30%; right: 30%; top: 2px; height: 2px; border-radius: 2px; background: var(--ink);
}
.badge { margin-left: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--wine); color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.badge:empty { display: none; }

main { max-width: 680px; margin: 0 auto; padding: 4px 16px 32px; outline: none; }
.loading { padding: 64px 0; color: var(--muted); text-align: center; }

@media (min-width: 900px) {
  .shell { padding-bottom: 0; display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; padding: 14px 28px; }
  .rail {
    position: sticky; top: 64px; bottom: auto; align-self: start;
    display: flex; flex-direction: column; gap: 2px;
    padding: 16px 12px; background: transparent; border-top: 0;
  }
  .rail a { justify-content: flex-start; padding: 0 14px; min-height: 40px; font-size: 15px; }
  .rail a[aria-current='page'] { background: var(--surface); }
  .rail a[aria-current='page']::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; }
  main { margin: 0; padding: 8px 28px 48px; }
}

/* ---------- type ---------- */
h1 { font-size: 28px; line-height: 1.15; font-weight: 650; font-variation-settings: 'wdth' 82; margin: 14px 0 4px; letter-spacing: -0.005em; }
.lede { margin: 0 0 18px; color: var(--muted); }
h2.group { font-size: 15px; font-weight: 600; margin: 26px 0 6px; display: flex; align-items: baseline; gap: 8px; }
h2.group .count { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- trial strip ---------- */
.trial {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin: 8px 0 4px; padding: 10px 14px;
  background: var(--tan-wash); border-radius: var(--radius-m);
  font-size: 14px; color: var(--tan-ink);
}
.trial a { font-weight: 600; white-space: nowrap; }

/* ---------- the four counters ---------- */
.tally { display: grid; grid-template-columns: repeat(4, 1fr); margin: 14px 0 6px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tally button {
  appearance: none; background: none; border: 0; padding: 12px 4px 10px; text-align: left; cursor: pointer;
  border-left: 1px solid var(--line);
}
.tally button:first-child { border-left: 0; padding-left: 0; }
.tally b { display: block; font-size: 30px; line-height: 1; font-weight: 600; font-variation-settings: 'wdth' 72; font-variant-numeric: tabular-nums; }
.tally span { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.tally .hot b { color: var(--wine); }

/* ---------- segmented ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #E7E4DE; border-radius: 10px; margin: 10px 0 2px; }
.seg button { appearance: none; border: 0; background: none; padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background-color 160ms ease, color 160ms ease; }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

/* ---------- the ledger rows ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-m); border: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease;
}
.list > li:first-child .row { border-top: 0; }
.row:active { background: #FAF9F7; }
@media (hover: hover) and (pointer: fine) { .row:hover { background: #FAF9F7; } }
.days { text-align: right; line-height: 1; }
.days b { display: block; font-size: 30px; font-weight: 600; font-variation-settings: 'wdth' 70; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.days span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.days.over b { color: var(--wine); }
.days.soon b { color: var(--wine); }
.days.near b { color: var(--tan-ink); }
.days.calm b { color: var(--ink); }
.days.word b { font-size: 19px; font-variation-settings: 'wdth' 80; padding-top: 6px; }
.what { min-width: 0; }
.what .t { display: block; font-weight: 550; font-size: 16px; line-height: 1.3; }
.what .s { display: block; margin-top: 2px; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 550; background: var(--stone); color: var(--ink-2); }
.chip.started { background: var(--tan-wash); color: var(--tan-ink); }
.chip.block { background: var(--wine-wash); color: var(--wine); }
.chip.ok { background: var(--ok-wash); color: var(--ok); }
.chev { width: 8px; height: 8px; border-right: 1.5px solid var(--line-2); border-bottom: 1.5px solid var(--line-2); transform: rotate(-45deg); margin-right: 4px; }
.more-later { display: block; width: 100%; margin-top: 10px; padding: 12px; background: none; border: 1px dashed var(--line-2); border-radius: var(--radius-m); color: var(--ink-2); font-weight: 500; cursor: pointer; }

.empty { padding: 28px 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 22px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
  -webkit-tap-highlight-color: transparent; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--wine); border-color: #E3CBD6; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-add { min-height: 38px; padding: 0 16px; background: var(--ink); border-color: var(--ink); color: #fff; font-size: 15px; }
.btn-add::before { content: ''; width: 11px; height: 11px; background: linear-gradient(#fff, #fff) center/100% 1.6px no-repeat, linear-gradient(#fff, #fff) center/1.6px 100% no-repeat; }
.actions { display: grid; gap: 10px; margin-top: 18px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.linkish { appearance: none; background: none; border: 0; padding: 6px 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); cursor: pointer; font-size: 15px; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(27, 33, 49, 0.32); opacity: 0; transition: opacity 220ms ease; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-l) var(--radius-l) 0 0;
  transform: translateY(100%); transition: transform 300ms var(--ease-drawer);
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-body { overflow-y: auto; padding: 8px 20px 24px; overscroll-behavior: contain; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; max-height: 86vh; border-radius: var(--radius-l); transform: translate(-50%, -46%); opacity: 0; transition: transform 240ms var(--ease-out), opacity 200ms ease; }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grip { display: none; }
  .sheet-body { padding: 22px 26px 26px; }
}
.sheet h2 { font-size: 22px; line-height: 1.2; font-weight: 650; font-variation-settings: 'wdth' 84; margin: 8px 0 2px; }
.sheet .sub { color: var(--muted); margin: 0 0 16px; }
.close-x { float: right; appearance: none; border: 0; background: var(--stone); width: 34px; height: 34px; border-radius: 17px; cursor: pointer; position: relative; margin: 4px 0 0 12px; }
.close-x::before, .close-x::after { content: ''; position: absolute; left: 11px; top: 16.25px; width: 12px; height: 1.5px; background: var(--ink-2); transform: rotate(45deg); }
.close-x::after { transform: rotate(-45deg); }

.bigdate { display: flex; align-items: baseline; gap: 14px; padding: 16px 0 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bigdate b { font-size: 46px; line-height: 1; font-weight: 600; font-variation-settings: 'wdth' 68; font-variant-numeric: tabular-nums; }
.bigdate .over { color: var(--wine); }
.bigdate .near { color: var(--tan-ink); }
.bigdate span { color: var(--ink-2); }
.facts { margin: 12px 0 0; display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.need { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-m); background: var(--ok-wash); color: var(--ok); font-size: 15px; }
.need.block { background: var(--wine-wash); color: var(--wine); }
.need.missing { background: var(--stone); color: var(--ink-2); }
.hint { margin-top: 12px; font-size: 14px; color: var(--muted); }

.renew { margin-top: 16px; padding: 16px; border-radius: var(--radius-m); background: var(--stone); }
.renew .quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.renew .quick button { appearance: none; border: 1px solid var(--line-2); background: var(--surface); border-radius: 18px; padding: 7px 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.renew .quick button[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #fff; }
.renew .said { font-size: 15px; margin: 8px 0 0; min-height: 22px; }

/* ---------- forms ---------- */
.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: 14px; font-weight: 550; margin-bottom: 6px; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-2); background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.input[aria-invalid='true'] { border-color: var(--wine); }
.error { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--wine-wash); color: var(--wine); font-size: 14px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { appearance: none; border: 1px solid var(--line-2); background: var(--surface); border-radius: 18px; padding: 8px 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.pick button[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- holders ---------- */
.search { margin: 12px 0; }
.hrow .days b { font-size: 24px; }

/* ---------- clean-up ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.steps { list-style: none; margin: 12px 0 0; padding: 0; }
.steps li + li { border-top: 1px solid var(--line); }
.step { display: flex; gap: 12px; align-items: center; width: 100%; padding: 11px 0; background: none; border: 0; text-align: left; cursor: pointer; font-size: 15px; }
.box { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: background-color 140ms ease, border-color 140ms ease; }
.step[aria-pressed='true'] .box { background: var(--ok); border-color: var(--ok); }
.step[aria-pressed='true'] .box::after { content: ''; width: 6px; height: 11px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg) translate(-1px, -1px); }
.step[aria-pressed='true'] .label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.card .actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- more ---------- */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; margin-top: 14px; }
.block h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.block p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.block .actions { margin-top: 12px; }
.lead-list { list-style: none; margin: 8px 0 0; padding: 0; }
.lead-list li { display: grid; grid-template-columns: 1fr 86px; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.lead-list input { min-height: 38px; text-align: right; }
.hist { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.hist li { padding: 8px 0; border-top: 1px solid var(--line); }
.hist time { display: block; color: var(--muted); font-size: 12.5px; }
.status-line { display: flex; gap: 8px; align-items: center; font-size: 15px; margin-bottom: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--wine); }
.ios-steps { margin: 8px 0 0; padding-left: 20px; font-size: 15px; }
.ios-steps li { margin: 4px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(86px + var(--safe-b));
  max-width: min(92vw, 460px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 15px;
  transform: translate(-50%, 12px); opacity: 0;
  transition: transform 220ms var(--ease-out), opacity 180ms ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  .sheet, .toast { transition: opacity 160ms ease; }
  .sheet { transform: none; opacity: 0; }
  .sheet.open { transform: none; opacity: 1; }
  @media (min-width: 720px) { .sheet, .sheet.open { transform: translate(-50%, -50%); } }
  .toast, .toast.show { transform: translate(-50%, 0); }
  .btn:active { transform: none; }
}
