:root {
  --bg:     #f6f6f4;
  --card:   #ffffff;
  --ink:    #1a1a1a;
  --muted:  #6b6b6b;
  --line:   #dcdcd6;
  --accent: #2f6f4e;
  --error:  #a33;
  --warn:   #8a6d1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 720px;
  margin-inline: auto;
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase;
     letter-spacing: .06em; color: var(--muted); }

header { display: flex; align-items: center; justify-content: space-between;
         margin-bottom: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1 1 120px; min-width: 0; }
.hidden { display: none !important; }

input, select, button {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
#add-form { flex-wrap: nowrap; gap: 6px; }
#add-name { flex: 1 1 60px; }
#add-qty { flex: 0 0 46px; text-align: center; padding-inline: 2px;
           appearance: textfield; -moz-appearance: textfield; }
#add-qty::-webkit-outer-spin-button,
#add-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#add-type { flex: 0 1 150px; }
#add-location { flex: 0 1 auto; }
#add-form input, #add-form select { min-width: 0; }
#add-form button { flex: 0 0 auto; }

button { cursor: pointer; background: #f0f0ec; }
button:hover { background: #e6e6e0; }
button.big { background: var(--accent); color: #fff; border-color: var(--accent);
             font-weight: 600; padding: 10px 18px; }
button.big:hover { filter: brightness(1.08); }
button.big.recording { background: var(--error); border-color: var(--error); }
button.link { background: none; border: none; color: var(--muted);
              text-decoration: underline; padding: 2px 4px; font-size: 14px; }

.status  { color: var(--muted); font-size: 14px; }
.muted   { color: var(--muted); font-weight: 400; text-transform: none;
           letter-spacing: 0; }
.error   { color: var(--error); font-size: 14px; margin: 6px 0 0; min-height: 0; }
.warn    { color: var(--warn);  font-size: 14px; margin: 6px 0; }
.transcript { font-size: 15px; margin: 12px 0 6px; }

/* proposed voice actions */
#proposed { list-style: none; padding: 0; margin: 8px 0 12px; }
#proposed li { display: flex; gap: 9px; align-items: flex-start;
               padding: 8px 0; border-top: 1px solid var(--line); }
#proposed .act-kind { margin-top: 7px; }
.act-body { flex: 1 1 auto; min-width: 0; }
.act-fields { display: flex; gap: 5px; flex-wrap: nowrap; align-items: center; }
.act-fields input, .act-fields select { padding: 5px 6px; font-size: 14px;
                                        min-width: 0; }
.f-name  { flex: 1 1 60px; }
.f-qty   { flex: 0 0 44px; text-align: center; padding-inline: 2px;
           appearance: textfield; -moz-appearance: textfield; }
.f-qty::-webkit-outer-spin-button,
.f-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.f-type  { flex: 0 1 132px; }
.f-loc   { flex: 0 1 auto; }
/* transparent border so text cells match the inputs' height exactly */
.f-fixed { padding: 5px 0; font-size: 14px; border: 1px solid transparent; }
.act-drop { flex: 0 0 auto; margin-top: 4px; padding: 4px 9px; font-size: 13px;
            color: var(--error); }
.act-drop:hover { background: #f7dede; }
.act-kind { font-weight: 700; font-size: 12px; padding: 1px 6px; border-radius: 4px;
            text-transform: uppercase; letter-spacing: .04em; flex: 0 0 auto; }
.act-add     { background: #dff0e4; color: #245c3c; }
.act-remove  { background: #f7dede; color: #8a2a2a; }
.act-set_qty { background: #e6e9f5; color: #2f3c73; }
.act-why { color: var(--muted); font-size: 13px; }

/* contents list */
.group-title { font-weight: 700; margin: 14px 0 4px; text-transform: capitalize; }
.group-title:first-child { margin-top: 0; }
.item { display: flex; align-items: center; gap: 8px;
        padding: 7px 0; border-top: 1px solid var(--line); }
.item-name { flex: 1 1 auto; }
.item-qty  { color: var(--muted); font-variant-numeric: tabular-nums; }
.item-date { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.item button { padding: 3px 9px; font-size: 14px; }
.empty { color: var(--muted); font-style: italic; }

#debug { background: #14161a; color: #d8dee9; padding: 10px; border-radius: 6px;
         font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
         max-height: 320px; overflow: auto; white-space: pre-wrap;
         word-break: break-word; margin: 0; }

#gate { max-width: 320px; margin: 15vh auto 0; }
#gate form { display: flex; gap: 8px; margin-top: 12px; }

/* voice pipeline stages */
.stage { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; margin: 14px 0; }
.stage-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stage-tag { font-weight: 700; font-size: 12px; text-transform: uppercase;
             letter-spacing: .05em; }
.stage-meta { color: var(--muted); font-size: 12px;
              font-variant-numeric: tabular-nums; }
.stage details { margin-top: 6px; }
.stage summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.stage pre { background: #14161a; color: #d8dee9; padding: 9px; border-radius: 6px;
             font: 11px/1.45 ui-monospace, "Cascadia Code", Consolas, monospace;
             max-height: 220px; overflow: auto; white-space: pre-wrap;
             word-break: break-word; margin: 6px 0 0; }
#applied { list-style: none; padding: 0; margin: 8px 0 0; }
#applied li { display: flex; gap: 9px; align-items: flex-start;
              padding: 7px 0; border-top: 1px solid var(--line); }
#applied li.failed { opacity: .75; }
.act-why.err { color: var(--error); }

/* same item, several container sizes */
.size-group { border-top: 1px solid var(--line); padding: 7px 0 3px; }
.size-group-name { font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
.size-group-tally { color: var(--muted); font-size: 12px; font-weight: 400; }
.size-group .item { border-top: none; padding: 3px 0 3px 14px; }
.item-sub .item-name { color: var(--muted); font-size: 14px; }

/* set_qty shows the old count struck out next to the new one */
.f-was { flex: 0 0 auto; padding: 5px 0; font-size: 14px; color: var(--muted);
         border: 1px solid transparent; font-variant-numeric: tabular-nums;
         white-space: nowrap; }
.qty-was { color: var(--muted); }
.qty-now { font-weight: 600; }

/* receipt */
label.filebtn { display: inline-block; text-align: center; }
.hint { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
#receipt-thumb { display: block; max-width: 220px; max-height: 260px;
                 border: 1px solid var(--line); border-radius: 6px; margin: 8px 0 0; }

/* merge-into-existing offer on an add row */
.act-merge { display: flex; align-items: center; gap: 6px; margin-top: 5px;
             font-size: 13px; color: var(--accent); cursor: pointer; }
.act-merge input[type=checkbox] { width: 15px; height: 15px; padding: 0;
                                  margin: 0; flex: 0 0 auto; accent-color: var(--accent); }

/* raw purchase log */
.header-links { display: flex; gap: 4px; align-items: center; }
.table-scroll { overflow-x: auto; }
.data-table { border-collapse: collapse; width: 100%; font-size: 13px;
              font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; white-space: nowrap;
                                 padding: 5px 10px 5px 0;
                                 border-bottom: 1px solid var(--line); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 11px;
                 text-transform: uppercase; letter-spacing: .04em; }
.data-table tr:last-child td { border-bottom: none; }
