:root {
  --bg: #f6f4f1; --card: #ffffff; --ink: #1f1a17; --muted: #6b625c; --line: #e4ded8;
  --brand: #3b2a20; --accent: #a8532f; --accent-soft: #f6e8e1;
  --ok: #2f7a4a; --ok-soft: #e6f3ea; --warn: #9a6a00; --warn-soft: #fbf1d9; --bad: #b3261e; --bad-soft: #fbe8e6;
  --radius: 10px; --tap: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; } h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; } h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; }

/* top bar */
.top { background: var(--brand); color: #fff; }
.top-in { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo { font-weight: 700; color: #fff; text-decoration: none; letter-spacing: .02em; margin-right: auto; }
.top nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.top nav a { color: #f1e6df; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.who { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: #e8dcd4; }
.who form { margin: 0; }
.who button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: .35rem .7rem; cursor: pointer; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.tile b { display: block; margin-bottom: .25rem; }

/* forms */
label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
input:not([type]), input[type=text], input[type=tel], input[type=password], input[type=email], input[type=search], input[type=date], input[type=number], input[type=url], select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .75rem; font-size: 1rem; border: 1px solid #cfc6bf; border-radius: 8px; background: #fff; }
input:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.help { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.errorlist { list-style: none; padding: 0; margin: .3rem 0; color: var(--bad); font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: .6rem 1.2rem; font-size: 1rem; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #cfc6bf; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e4b3ae; }
.btn.small { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }
.btn.block { width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.inline { display: inline; margin: 0; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }

/* messages */
.msg { padding: .75rem 1rem; border-radius: 8px; margin-bottom: .75rem; border: 1px solid; }
.msg.success { background: var(--ok-soft); border-color: #b9dcc5; }
.msg.error { background: var(--bad-soft); border-color: #efc2bd; }
.msg.warning { background: var(--warn-soft); border-color: #ecd59b; }
.msg.info { background: #eef3f8; border-color: #c9d8e6; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #faf8f6; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eee8e3; color: var(--ink); }
.badge.owner { background: var(--brand); color: #fff; } .badge.full { background: var(--accent-soft); color: var(--accent); }
.badge.off { background: var(--bad-soft); color: var(--bad); } .badge.on { background: var(--ok-soft); color: var(--ok); }

/* permission grid */
.perm th.site, .perm td.c { text-align: center; width: 110px; }
.perm td.c input { width: 24px; height: 24px; accent-color: var(--accent); cursor: pointer; }
.perm td.c input:disabled { cursor: not-allowed; opacity: .45; }
.perm td.all { background: #fbf7f4; }
.tick { color: var(--ok); font-weight: 700; } .dash { color: #c9c0b9; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); margin-top: 1rem; }

/* login */
.auth { max-width: 420px; margin: 8vh auto; padding: 0 1rem; }
.auth .brand { text-align: center; font-weight: 700; font-size: 1.4rem; color: var(--brand); margin-bottom: 1rem; }
.secret { font: 600 1.6rem/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; background: #fff; border: 2px dashed var(--accent);
  border-radius: 10px; padding: 1rem; text-align: center; margin: 1rem 0; user-select: all; }
.pager { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }

@media (max-width: 640px) {
  .top nav { width: 100%; order: 3; }
  .who span { display: none; }
  h1 { font-size: 1.3rem; }
}

/* catalogue */
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem; }
.tabs a { padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); background: #fff; }
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.flag { display: inline-block; padding: .05rem .45rem; border-radius: 6px; font-size: .74rem; font-weight: 700; margin-right: .2rem; }
.flag.ess { background: var(--bad-soft); color: var(--bad); }
.flag.exp { background: #f4d4cf; color: #8a1d14; }
.flag.case { background: #fff3b0; color: #6b5300; }
.missing { color: var(--bad); font-weight: 600; font-size: .9rem; }
.rule { font-size: .9rem; } .rule .sup { font-weight: 600; }
.hidden-note { font-size: .8rem; color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.days .d { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; background: #fcfbfa; }
.days .d label { margin: 0 0 .25rem; font-size: .85rem; }
.days select, .days input { min-height: 40px; }
details.box { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; background: #fff; margin-top: .6rem; }
details.box summary { cursor: pointer; font-weight: 600; }
.lineitem { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.lineitem:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .3rem .8rem; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.check-row label { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }

textarea { font: inherit; }
input[type=file] { font: inherit; font-size: .9rem; }
input:disabled, select:disabled, textarea:disabled { background: #f6f4f1; color: var(--ink); }

/* shopping list (phone first) */
.count-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .6rem 0; display: flex; gap: .8rem; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.count-bar input { max-width: 260px; }
.count-h { margin: 1.4rem 0 .5rem; font-size: 1.05rem; }
.count-h.ess { color: var(--bad); }
.count-list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.count-row { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.count-row:last-child { border-bottom: 0; }
.count-row.is-ess { background: #fffaf9; }
.count-row .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.cname { flex: 1; min-width: 0; } .cname b { font-size: 1.05rem; }
.cin { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.cin input { width: 92px; min-height: 52px; font-size: 1.25rem; text-align: center; font-weight: 600; }
.cin .unit { width: 52px; font-size: .85rem; color: var(--muted); }
.state.ok { color: var(--ok); } .state.err { color: var(--bad); font-weight: 600; } .state.warn { color: var(--warn); font-weight: 600; }
.submit-bar { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; border-top: 1px solid var(--line); margin-top: 1rem; }
.total-card { display: flex; gap: 1.5rem; justify-content: space-between; flex-wrap: wrap; align-items: center; }
.big { font-size: 2rem; font-weight: 700; }
.card.internal { border-color: #c9b8f0; background: #fbf9ff; }
tfoot td { border-top: 2px solid var(--line); }
@media (max-width: 640px) { .count-bar { flex-direction: column; align-items: stretch; } .count-bar input { max-width: none; } .cin input { width: 80px; } }

.olines { border-top: 1px solid var(--line); }
.oline { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.oline .ol-main { flex: 1; min-width: 0; }
.oline .ol-qty { margin: .15rem 0; }
.oline .ol-total { flex: 0 0 auto; text-align: right; font-weight: 600; white-space: nowrap; }
.oline.subtotal { border-bottom: 0; border-top: 2px solid var(--line); }

.bell { position: relative; color: #fff; text-decoration: none; font-size: 1.15rem; padding: .2rem .4rem; }
.bell .dot { position: absolute; top: -4px; right: -6px; background: #e24c3b; color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 0 .35rem; line-height: 1.3rem; min-width: 1.3rem; text-align: center; }
.gactions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.gactions form { margin: 0; }
.gactions textarea { min-height: 44px; }
.qtyform { display: inline-flex; gap: .3rem; align-items: center; margin-top: .3rem; }
.qtyform input { width: 84px; min-height: 40px; padding: .3rem .5rem; }
.edited { font-size: .8rem; color: var(--warn); }
.notice-row { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.notice-row.unread { background: #fff8ef; } .notice-row:last-child { border-bottom: 0; }

/* reports (Stage 8) */
.tbl th, .tbl td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.bar-row { display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .6rem; align-items: center; padding: .3rem 0; }
.bar-track { background: #f0ebe6; border-radius: 4px; height: 14px; }
.bar { background: var(--accent); border-radius: 4px; height: 14px; min-width: 2px; }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 5.5rem 1fr; } .bar-val { grid-column: 2; font-size: .9rem; } }

/* price data page */
.pd-row { display: grid; grid-template-columns: minmax(200px, 1.1fr) 2.4fr; gap: .4rem 1rem; align-items: end; padding: .8rem 1rem; margin-bottom: .5rem; }
.pd-fields { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.pd-fields > div { flex: 0 1 7rem; }
.pd-fields label { font-size: .78rem; margin-bottom: .15rem; }
.pd-fields input, .pd-fields select { min-height: 40px; }
.pd-fields .pd-check { flex: 0 0 auto; padding-bottom: .55rem; }
.pd-fields .pd-check label { display: flex; gap: .3rem; align-items: center; font-size: .85rem; }
.pd-fields .pd-check input { width: auto; min-height: 0; }
.pd-fields .pd-save { flex: 1 0 8rem; display: flex; gap: .5rem; align-items: center; }
.pd-dirty { box-shadow: 0 0 0 2px var(--accent); }
.pd-msg.ok { color: #2e7d32; }
@media (max-width: 760px) { .pd-row { grid-template-columns: 1fr; } .pd-fields > div { flex: 1 1 6.5rem; } }

.btn:disabled, button:disabled { opacity: .45; cursor: not-allowed; }
