:root {
  --bg: #f5f2ec;
  --surface: #fffdf9;
  --ink: #1d1b18;
  --muted: #6b665d;
  --line: #e6e0d5;
  --soft: #efe9de;
  --accent: #1f6f5c;
  --accent-soft: #dcebe5;
  --warn: #a5402d;
  --radius: 18px;
  --font: Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }
h2 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.top { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 18px 16px 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 36px; height: 36px; stroke: none; }
.app-name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.biz { color: var(--muted); font-size: 14px; min-height: 1px; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn.small { width: 40px; height: 40px; }
.icon-btn:hover { background: var(--soft); }

.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; padding: 8px 16px; background: var(--bg); max-width: 1180px; margin: 0 auto; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 10px 8px; color: var(--muted); font-weight: 500; cursor: pointer; min-height: 44px; }
.tabs button[aria-current="page"] { background: var(--ink); color: var(--bg); }

.layout { max-width: 1180px; margin: 0 auto; padding: 8px 16px 40px; display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
@media (max-width: 959px) {
  body[data-view="day"] .panel:not(.day),
  body[data-view="week"] .panel:not(.week),
  body[data-view="history"] .panel:not(.history) { display: none; }
}

@media (min-width: 960px) {
  .tabs { display: none; }
  .layout { grid-template-columns: 380px 1fr; align-items: start; padding-top: 12px; }
  .day { position: sticky; top: 16px; }
  .history { grid-column: 1 / -1; }
}

/* Day entry */
.day-head, .week-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px; margin-bottom: 18px; }
.day-title-wrap, .week-title-wrap { text-align: center; }
.date-pick input { border: 0; background: transparent; color: var(--muted); font-size: 14px; text-align: center; padding: 2px 0; cursor: pointer; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 500; }
.opt { font-weight: 400; color: #9a948a; }
.field input, .field select { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; min-height: 48px; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.money { position: relative; }
.money .cur { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.money input { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.money.has-cur input { padding-left: 52px; }
.field.big input { font-size: 26px; min-height: 60px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 14px; color: var(--muted); margin: -4px 0 14px; }
.hint.off { color: var(--warn); }
.error { color: var(--warn); font-size: 14px; margin: 0 0 12px; }
.saved { font-size: 14px; color: var(--accent); min-height: 20px; margin: 10px 0 0; }
.form-actions, .week-actions, .settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Buttons: pill with round arrow badge, flat */
.btn { display: inline-flex; align-items: center; gap: 10px; border-radius: 999px; padding: 6px 6px 6px 18px; min-height: 48px; border: 1.5px solid var(--ink); background: transparent; font-weight: 500; cursor: pointer; }
.btn.ghost { padding: 6px 18px; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn .badge { width: 36px; height: 36px; border-radius: 999px; background: var(--bg); color: var(--ink); display: grid; place-items: center; }
.btn .badge svg { width: 18px; height: 18px; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn:active { transform: translateY(1px); }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#save { flex: 1; justify-content: space-between; }

/* Week */
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.headline { display: grid; gap: 14px; margin-bottom: 18px; }
.kpi { display: grid; gap: 2px; }
.k-label { font-size: 14px; color: var(--muted); }
.k-value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.kpi.main .k-value { font-size: 40px; color: var(--accent); line-height: 1.1; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; padding-top: 14px; border-top: 1px solid var(--line); }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

/* Signature: the week strip fills up day by day, bar height = that day's sales */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; }
.cell { display: grid; grid-template-rows: 72px auto; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; text-align: center; min-width: 0; }
.cell .bar-box { background: var(--soft); border-radius: 10px; display: flex; align-items: flex-end; overflow: hidden; }
.cell .bar { width: 100%; background: var(--accent); border-radius: 10px; min-height: 0; }
.cell.empty .bar-box { background: #f8f5ef; box-shadow: inset 0 0 0 1px var(--line); }
.cell .d { font-size: 13px; color: var(--muted); }
.cell.today .d { color: var(--ink); font-weight: 600; }
.cell.selected .bar-box { outline: 2px solid var(--ink); outline-offset: 2px; }
.progress { font-size: 14px; color: var(--muted); margin: 10px 0 16px; }

.table-wrap { overflow-x: auto; margin: 0 -4px 18px; }
table.days { width: 100%; border-collapse: collapse; font-size: 15px; }
.days th, .days td { padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.days thead th { font-weight: 500; color: var(--muted); font-size: 13px; }
.days .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.days tbody tr { cursor: pointer; }
.days tbody tr:hover { background: var(--bg); }
.days td.miss { color: #a8a298; }
.days tfoot th, .days tfoot td { font-weight: 600; border-bottom: 0; }
.days tfoot td:first-of-type { color: var(--accent); }

/* History */
.history h2 { margin-bottom: 12px; }
.week-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.week-row:last-child { border-bottom: 0; }
.week-row:hover { background: var(--bg); }
.week-row .w-label { font-weight: 500; }
.week-row .w-sales { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--accent); font-weight: 500; }
.week-row .w-detail { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
.empty-state { color: var(--muted); padding: 8px 0; margin: 0; }
@media (min-width: 960px) {
  #weeks { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 32px; }
  .week-row:last-child { border-bottom: 1px solid var(--line); }
}

/* Settings */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(29, 27, 24, 0.35); }
dialog form { padding: 22px; }
dialog h2 { margin-bottom: 16px; }
.backup { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.backup p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.danger { margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s cubic-bezier(.2,.8,.2,1), transform .2s cubic-bezier(.2,.8,.2,1); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media print {
  .top .icon-btn, .tabs, .day, .history, .week-actions, .week-head .icon-btn { display: none !important; }
  .layout { display: block; } .panel { border: 0; display: block !important; }
}

.short { display: none; }
@media (max-width: 559px) {
  .table-wrap { margin: 0 0 18px; }
  table.days { font-size: 13.5px; }
  .days th, .days td { padding: 9px 2px; }
  .days .long { display: none; }
  .days .short { display: inline; }
}
