/* Flare53 Owner Console. No inline styles anywhere (CSP style-src 'self'). */
:root {
  --bg: #f5f2ee;
  --card: #ffffff;
  --ink: #1d1a17;
  --muted: #6a625a;
  --line: #e6dfd6;
  --soft: #faf7f3;
  --head: #14110f;
  --head-ink: #f4efe9;
  --brand: #e2552a;
  --brand-ink: #ffffff;
  --brand-soft: #fde9e1;
  --focus: #2b5be8;
  --ok: #17794f;
  --ok-soft: #e1f3ea;
  --warn: #9a5b00;
  --warn-soft: #fdf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --info: #2a55c9;
  --info-soft: #e5ecfc;
  --grey-soft: #eeebe7;
  --buddy: #12a06b;
  --book53: #2b5be8;
  --orderlah: #b4532a;
  --speed53: #e2552a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 26, 23, .05), 0 8px 24px rgba(29, 26, 23, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: 24px; }

/* ---------------------------------------------------------------- sign-in */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #3a2a20 0%, var(--head) 55%);
}
.auth-card {
  width: min(100%, 400px);
  background: var(--card);
  border-radius: 20px;
  padding: 28px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #f2a93b, #de4f22);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.auth-card .mark { margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; }
.auth-card p { margin: 0 0 16px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.input {
  width: 100%; padding: 11px 13px; border: 1px solid #d5ccc1; border-radius: 10px; background: #fff;
}
.input:focus { border-color: var(--focus); }
.code-input { font-size: 24px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.qr { display: grid; place-items: center; padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.qr canvas, .qr img { max-width: 100%; height: auto; }
.secret { font-family: Consolas, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--soft); padding: 8px 10px; border-radius: 8px; border: 1px dashed var(--line); }
.steps { margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 4px; }
.auth-note { font-size: 13px; color: var(--muted); margin-top: 16px !important; margin-bottom: 0 !important; }

/* ---------------------------------------------------------------- buttons, pills, messages */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 650;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #c8461f; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--soft); }
.btn-small { padding: 6px 11px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--info); cursor: pointer; text-decoration: underline; }

.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-ok { background: var(--ok-soft); color: var(--ok); }

.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.pill-NEW { background: var(--info-soft); color: var(--info); }
.pill-PLANNED { background: var(--warn-soft); color: var(--warn); }
.pill-DONE { background: var(--ok-soft); color: var(--ok); }
.pill-CLOSED { background: var(--grey-soft); color: var(--muted); }
.pill-ACTIVE { background: var(--ok-soft); color: var(--ok); }
.pill-SUSPENDED { background: var(--bad-soft); color: var(--bad); }
.pill-plan { background: var(--grey-soft); color: var(--ink); }

.app-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.app-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.app-buddy::before { background: var(--buddy); }
.app-book53::before { background: var(--book53); }
.app-orderlah::before { background: var(--orderlah); }
.app-speed53::before { background: var(--speed53); }

/* ---------------------------------------------------------------- shell */
.top {
  background: var(--head); color: var(--head-ink);
  position: sticky; top: 0; z-index: 10;
}
.top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; margin-right: auto; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.brand b { font-size: 16px; }
.brand small { display: block; font-size: 12px; color: #b9aea3; }
.env { background: #f2a93b; color: #2a1a07; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; }
.who { font-size: 13px; color: #cfc5bb; }
.top .btn-ghost { color: var(--head-ink); border-color: #3b332d; }
.top .btn-ghost:hover { background: #241e1a; }
.nav { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; }
.nav a {
  color: #cfc5bb; text-decoration: none; padding: 10px 12px; border-bottom: 3px solid transparent; font-weight: 600; white-space: nowrap;
}
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--brand); }
.nav .count { background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

.main { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.loading { color: var(--muted); padding: 30px 0; }

/* ---------------------------------------------------------------- home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.app-card { display: flex; flex-direction: column; border-top: 4px solid var(--muted); }
.app-card.app-buddy { border-top-color: var(--buddy); }
.app-card.app-book53 { border-top-color: var(--book53); }
.app-card.app-orderlah { border-top-color: var(--orderlah); }
.app-card.app-speed53 { border-top-color: var(--speed53); }
.app-card h2 { margin: 0 0 2px; font-size: 18px; }
.app-card .what { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--soft); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat.hot { background: var(--brand-soft); }
.stat.hot b { color: #b33a14; }
.stat a { color: inherit; text-decoration: none; display: block; }
.stat a:hover span { text-decoration: underline; }
.extras { margin: 0 0 14px; padding: 0; list-style: none; font-size: 14px; }
.extras li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.extras li:last-child { border-bottom: 0; }
.card-foot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.unavailable { color: var(--bad); background: var(--bad-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.later { color: var(--muted); background: var(--soft); border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: 14px; }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters + .filters { margin-top: -4px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--head); color: #fff; border-color: var(--head); }
.chip .n { color: var(--muted); font-weight: 500; margin-left: 3px; }
.chip[aria-pressed="true"] .n { color: #cfc5bb; }
.search { flex: 1 1 240px; max-width: 360px; }

/* ---------------------------------------------------------------- feedback */
.fb-list { display: grid; gap: 12px; }
.fb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.fb-kind { font-weight: 700; }
.fb-head .pill { margin-left: auto; }
.fb-meta { color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }
.fb-msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; }
.fb-reply { background: var(--soft); border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0; padding: 8px 12px; margin-bottom: 10px; font-size: 14px; }
.fb-reply b { display: block; font-size: 12.5px; color: var(--muted); }
.fb-reply p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.seg label { display: inline-flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 14px; background: #fff; }
.seg input:checked + span { background: var(--head); color: #fff; border-color: var(--head); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.answer textarea { min-height: 92px; resize: vertical; }
.answer-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.answer-foot small { color: var(--muted); margin-right: auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------------------------------------------------------------- businesses */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); }
td > div { min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- activity */
.log { display: grid; gap: 0; }
.log-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row time { color: var(--muted); font-size: 13.5px; }
.log-row p { margin: 2px 0 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--head); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  max-width: calc(100% - 32px);
}
.toast.bad { background: var(--bad); }

/* ---------------------------------------------------------------- phones */
@media (max-width: 720px) {
  .who { display: none; }
  .page-head h1 { font-size: 21px; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  tr:last-child { border-bottom: 0; }
  td { border: 0; padding: 4px 14px; display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; }
  .log-row { grid-template-columns: 1fr; gap: 2px; }
}
