:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #6b7587;
  --line: #e4e8f0;
  --primary: #0f7ae5;
  --primary-ink: #ffffff;
  --ok: #138a4c;
  --warn: #b26a00;
  --bad: #c62f3a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 1.25rem 0 0.75rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
h3 { margin: 0 0 0.25rem; font-size: 1rem; }
ul { padding-left: 1.2rem; margin: 0.25rem 0 0.75rem; }

.container { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 440px; }
.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pre { white-space: pre-wrap; }
.label { display: block; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.5rem; }

.banner { background: #fff4d6; color: #7a5600; text-align: center; font-size: 0.8rem; padding: 4px; }

/* topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 600; color: var(--text); }
.logo { font-size: 1.4rem; }
.logo.big { font-size: 2.6rem; }
.user { display: flex; gap: 12px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar.initials { display: inline-flex; align-items: center; justify-content: center; background: #dbe9fb; color: var(--primary); font-weight: 600; }
.link { color: var(--primary); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 0.92rem; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; display: block; color: inherit; }
a.card:hover { border-color: #c4d6ee; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + section { margin-top: 16px; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.cta h2 { margin-bottom: 0.25rem; }
.big-number { font-size: 1.8rem; font-weight: 700; margin: 0.25rem 0; }

/* pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.pill.confirmed, .pill.done, .pill.paid, .pill.completed, .pill.accepted { background: #e3f5ea; color: var(--ok); }
.pill.requested, .pill.pending, .pill.proposed, .pill.booked { background: #fff3dc; color: var(--warn); }
.pill.in_progress, .pill.checked_in { background: #e1efff; color: var(--primary); }
.pill.overdue, .pill.cancelled, .pill.no_show, .pill.rejected { background: #fde7e9; color: var(--bad); }

.progress { height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress span { display: block; height: 100%; background: var(--primary); }
.plan-line + .plan-line { margin-top: 16px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.table .num { text-align: right; white-space: nowrap; }
.table tr.cancelled td { color: var(--muted); text-decoration: line-through; }

/* forms & buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: var(--primary-ink); border: 0; border-radius: 10px; padding: 10px 16px; font-size: 0.95rem; cursor: pointer; font-weight: 500; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.btn.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; width: 100%; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
textarea { resize: vertical; }

.alert { background: #fde7e9; color: var(--bad); padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; }
.alert.ok { background: #e3f5ea; color: var(--ok); }

/* login */
.login { padding-top: 10vh; }
.login .card { display: grid; gap: 12px; padding: 28px 24px; }
.login form { margin: 0; }
.login form .btn { width: 100%; }

/* org list */
.card.org ul { margin: 0.5rem 0 0; color: var(--muted); }

/* timeline */
.visit .row { border-bottom: 0; padding: 0 0 4px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; }
.bubble.in { align-self: flex-end; background: #dbe9fb; border-bottom-right-radius: 4px; }
.bubble.out { align-self: flex-start; background: #f0f2f6; border-bottom-left-radius: 4px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 24px; }
.composer textarea { flex: 1; }

.footer { padding: 16px; margin-top: 8px; }

@media (max-width: 600px) {
  h1 { font-size: 1.25rem; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .cta { flex-direction: column; align-items: stretch; }
}

@media (max-width: 600px) {
  .user { gap: 8px; }
  .user a { white-space: nowrap; font-size: 0.8rem; }
  .brand span:last-child { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
