:root {
  --ink: #1c1915;
  --muted: #6d655b;
  --paper: #f3eee6;
  --card: #fffdf8;
  --line: #e5dccf;
  --teal: #0f4f4c;
  --teal-mid: #1a6b66;
  --gold: #e39b12;
  --gold-soft: #fff3d4;
  --clay: #9c341f;
  --clay-soft: #fde8e1;
  --ok: #0d6b45;
  --ok-soft: #e5f6ee;
  --wa: #efe6da;
  --shadow: 0 16px 40px rgba(48, 32, 12, 0.08);
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--teal);
  color: #f6f1e7;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.arch { width: 42px; height: 28px; color: #f6f1e7; }
.brand strong { font-family: var(--serif); font-size: 22px; font-weight: 560; display: block; line-height: 1; }
.brand span { display: block; color: #d5ebe7; font-size: 12px; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav button, .text-btn, .primary, .ghost, .danger {
  border: 0;
  border-radius: 999px;
}
.nav button {
  background: transparent;
  color: #f6f1e7;
  text-align: left;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.nav button.active { background: var(--gold); color: var(--ink); font-weight: 650; }
.nav button em, .count {
  font-style: normal;
  background: var(--clay);
  color: white;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  padding: 0 6px;
}
.nav button.active em { background: var(--ink); }
.side-note { margin-top: auto; color: #d5ebe7; font-size: 12px; line-height: 1.45; padding: 0 8px; }

.main { padding: 22px 28px 48px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.logo { font-family: var(--serif); font-size: 40px; line-height: 0.9; margin: 0; font-weight: 560; }
.tag { margin: 6px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
select, input, textarea {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.lang { display: flex; background: white; border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.lang button { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; }
.lang button.on { background: var(--teal); color: white; }
.ghost, .primary, .danger, .text-btn { padding: 10px 14px; }
.ghost { background: white; border: 1px solid var(--line); }
.primary { background: var(--teal); color: white; }
.danger { background: var(--clay); color: white; }
.text-btn { background: transparent; padding-inline: 0; color: var(--teal-mid); font-weight: 650; }
.notice {
  background: var(--gold-soft);
  border: 1px solid #efd48a;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.stat-grid, .split, .card-grid { display: grid; gap: 14px; }
.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.stat, .panel, .biz-card, .thread, .offer, .booking, .road-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.stat { padding: 16px 16px 14px; }
.stat span, .eyebrow { color: var(--muted); font-size: 13px; display: block; }
.stat strong { font-family: var(--serif); font-size: 32px; font-weight: 560; display: block; margin-top: 4px; }
.stat em { font-style: normal; color: var(--muted); font-size: 13px; }

.biz-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.biz-card { text-align: left; padding: 12px; box-shadow: none; }
.biz-card.on { border-color: var(--teal); background: #f3faf8; }
.biz-card b { display: block; margin: 3px 0; }
.biz-card small { color: var(--muted); }

.panel { padding: 18px; margin-bottom: 16px; }
.panel h2, .inspector h2, .chat h2 { font-family: var(--serif); font-weight: 560; margin: 0 0 8px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 14px 0; padding: 0; list-style: none; }
.steps li { background: #f7f3eb; border-radius: 14px; padding: 12px; min-width: 0; }
.steps li.done { background: var(--ok-soft); }
.steps li strong { display: block; }
.script { margin: 8px 0 0; padding-left: 18px; color: var(--ink); }
.script li { margin: 4px 0; }
.row-list { display: flex; flex-direction: column; gap: 8px; }
.mini {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line); background: transparent; width: 100%; text-align: left;
}
.pill, .tag-pill {
  border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 650; white-space: nowrap;
}
.bad { background: var(--clay-soft); color: var(--clay); }
.wait { background: var(--gold-soft); color: #8a5a00; }
.ok { background: var(--ok-soft); color: var(--ok); }
.mute { background: #eeeae4; color: var(--muted); }

.inbox { display: grid; grid-template-columns: 270px minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.threads, .chat, .inspector { min-height: 680px; }
.threads, .inspector { background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: auto; max-height: calc(100vh - 150px); }
.thread { width: calc(100% - 16px); margin: 8px; text-align: left; box-shadow: none; padding: 12px; display: block; }
.thread.on { border-color: var(--teal); }
.thread b { display: block; }
.thread p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.chat {
  background: var(--wa);
  background-image: radial-gradient(rgba(80, 55, 20, 0.05) 0.7px, transparent 0.7px);
  background-size: 12px 12px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid #e3d5c4;
  max-height: calc(100vh - 150px);
}
.chat-head, .pause-banner, .sim, .composer { background: rgba(255, 253, 248, 0.94); }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.back { display: none; }
.messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; position: relative; }
.bubble p { margin: 0; white-space: pre-wrap; line-height: 1.4; }
.bubble time { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.bubble.customer { background: white; align-self: flex-start; border-top-left-radius: 4px; }
.bubble.mohallio { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 4px; }
.bubble.staff { background: #d7efe9; align-self: flex-end; border-top-right-radius: 4px; }
.who { font-size: 11px; font-weight: 700; color: var(--teal); }
.typing { align-self: flex-start; background: white; border-radius: 12px; padding: 10px 12px; color: var(--muted); }
.pause-banner { margin: 10px 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--clay-soft); color: var(--clay); }
.sim, .composer { padding: 12px; border-top: 1px solid var(--line); }
.sim h3, .inspector h3 { margin: 0 0 6px; font-size: 15px; }
.sim p, .inspector p, .help { color: var(--muted); font-size: 13px; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; text-align: left; }
.composer { display: flex; gap: 8px; }
.composer input, .composer textarea, .sim input { flex: 1; width: 100%; }
.inspector { padding: 16px; }
.quote { background: #f7f3eb; border-radius: 12px; padding: 10px; margin: 8px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; }
.filters button.on { background: var(--teal); color: white; border-color: var(--teal); }
.booking, .offer { padding: 14px; box-shadow: none; display: grid; gap: 8px; }
.booking { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.offer { grid-template-columns: minmax(0, 1.4fr) 120px 110px auto; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { width: 100%; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel div { display: grid; grid-template-columns: 150px 1fr 52px; gap: 8px; align-items: center; }
.track { background: #efe8dc; border-radius: 999px; height: 12px; overflow: hidden; }
.track span { display: block; height: 100%; background: var(--teal-mid); }
.track.gold span { background: var(--gold); }
.track.ok span { background: var(--ok); }
.money-line { display: flex; height: 18px; border-radius: 999px; overflow: hidden; background: #efe8dc; margin: 10px 0; }
.money-line i { display: block; height: 100%; }
.money-line .rec { background: var(--ok); }
.money-line .book { background: var(--teal-mid); }
.money-line .wait { background: var(--gold); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.card-grid { grid-template-columns: 1fr 1fr; }
.road-card { padding: 16px; box-shadow: none; }
.road-card h3 { margin: 6px 0; font-family: var(--serif); font-weight: 560; }
.phase { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--teal-mid); }
.add-form { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(90px, 0.6fr)) auto; gap: 8px; margin-top: 12px; }
.shift-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line); }
.shift-grid input[type="text"], .shift-grid input:not([type="checkbox"]) { width: 118px; }
button:disabled { opacity: 0.45; cursor: default; }
.two { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 14px; }

@media (max-width: 1180px) {
  .stat-grid, .biz-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inbox { grid-template-columns: 230px minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; min-height: 0; }
  .steps { grid-template-columns: 1fr 1fr; }
  .offer, .add-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 5;
    flex-direction: row; padding: 8px; gap: 6px;
    border-top: 1px solid rgba(255,255,255,0.08);
  }
  .brand, .side-note { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 2px; }
  .sidebar { width: auto; max-width: 100vw; }
  .nav button { position: relative; flex: 1; min-width: 0; justify-content: center; padding: 10px 0; font-size: 11px; gap: 0; border-radius: 12px; }
  .nav button em { position: absolute; top: 2px; right: 4px; margin: 0; }
  .offer, .add-form { grid-template-columns: 1fr; }
  input, select, textarea { max-width: 100%; min-width: 0; }
  .main { padding: 16px 14px 96px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .logo { font-size: 34px; }
  .stat-grid, .biz-row, .card-grid, .two, .steps { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-grid > *, .biz-row > *, .card-grid > *, .two > *, .steps > * { min-width: 0; }
  .inbox { display: block; }
  .threads, .chat, .inspector { max-height: none; min-height: 0; }
  .inbox:not(.chat-open) .chat,
  .inbox:not(.chat-open) .inspector { display: none; }
  .inbox.chat-open .threads { display: none; }
  .back { display: inline-flex; }
  .booking { grid-template-columns: 1fr; }
  .funnel div { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stat-grid, .biz-row, .card-grid, .steps, .two { grid-template-columns: 1fr; }
}
