:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #5f6b66;
  --line: #e1e0d9;
  --accent: #1f7a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --good: #1f7a5a;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --panel: #1c211f;
    --ink: #e7ece9;
    --muted: #9aa7a1;
    --line: #2d3532;
    --accent: #4fbf90;
    --accent-ink: #0d1411;
    --accent-soft: #1d3329;
    --warn: #f0b75b;
    --warn-soft: #3a2e19;
    --bad: #f2867e;
    --bad-soft: #3d2120;
    --good: #4fbf90;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.stack > * + * { margin-top: .7rem; }
.gap { height: .8rem; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 1rem; min-height: 56px; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; color: var(--ink); text-decoration: none; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
#nav { display: flex; gap: .2rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
#nav::-webkit-scrollbar { display: none; }
#nav a { padding: .45rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
#nav a:hover { color: var(--ink); background: var(--bg); }
#nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
#nav .badge { margin-left: .3rem; }
main { padding-top: 1.4rem; padding-bottom: 4rem; outline: none; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.panel + .panel { margin-top: 1rem; }
.panel > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: inherit; display: block; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.45rem; font-weight: 650; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .8rem; }
a.stat:hover { border-color: var(--accent); }
.stat.attn { border-color: var(--warn); background: var(--warn-soft); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.mark { flex: none; width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; }
.mark.ok { background: var(--accent-soft); color: var(--good); }
.mark.todo { background: var(--warn-soft); color: var(--warn); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--bg); }
tr:last-child td { border-bottom: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; }
.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--bg); display: block; }

/* badges */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--accent-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* tabs (filters) */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin: .8rem 0; }
.tabs a { padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--muted); background: var(--panel); font-size: .9rem; }
.tabs a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* forms */
label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: .2rem; font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem;
}
textarea { min-height: 6rem; resize: vertical; }
textarea.tall { min-height: 16rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; margin-bottom: .6rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.cols { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 600; padding: 0 .3rem; }

button, .button {
  font: inherit; font-weight: 600; border-radius: 8px; padding: .5rem .95rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3;
}
button.ghost, .button.ghost { background: transparent; color: var(--accent); }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }

.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: .5rem .75rem; margin: .5rem 0; }
.notice { background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; }
.okbox { background: var(--accent-soft); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; word-break: break-all; }

/* chat transcript */
.chat { display: flex; flex-direction: column; gap: .4rem; max-height: 520px; overflow-y: auto; padding: .6rem; background: var(--bg); border-radius: var(--radius); border: 1px solid var(--line); }
.msg { max-width: 82%; padding: .45rem .7rem; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg .who { display: block; font-size: .72rem; color: var(--muted); margin-bottom: .1rem; }
.msg.customer { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); }
.msg.ai, .msg.bot { align-self: flex-end; background: var(--accent-soft); }
.msg.staff { align-self: flex-end; background: var(--warn-soft); }

.photo-pick { display: flex; gap: .8rem; align-items: center; }
.photo-pick img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.login { max-width: 360px; margin: 4rem auto; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 8px; font-weight: 550; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }

@media (max-width: 640px) {
  .top-in { flex-direction: column; align-items: stretch; gap: 0; padding-top: .5rem; }
  #nav { padding-bottom: .4rem; }
  .msg { max-width: 92%; }
}
