:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1c2228;
  --muted: #66707a;
  /* AyeSay teal (#30C1BF) is the logo colour; --brand is a darker shade so white text on it stays readable. */
  --brand-logo: #30C1BF;
  --brand: #138583;
  --brand-ink: #ffffff;
  --brand-soft: #e4f6f6;
  --brand-grey: #5a5858;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --err: #c2262b;
  --err-soft: #fce9e9;
  --radius: 10px;
  --font: "Inter", "Padauk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a; --surface: #1a2025; --border: #2b333a; --text: #e6e9ec; --muted: #98a2ab;
    --brand: #30C1BF; --brand-ink: #062322; --brand-soft: #123634; --brand-grey: #c9c7c7;
    --ok: #4ade80; --ok-soft: #12291b; --warn: #f5a524; --warn-soft: #2e2412; --err: #f87171; --err-soft: #331b1b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.pre { white-space: pre-line; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .45rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border); }
/* Thin stripe in the logo's colours under the header. */
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  background: linear-gradient(90deg, #1fa3e0 0 25%, #2fb34a 25% 50%, #e6ec1e 50% 75%, var(--brand-logo) 75% 100%); }
.brand { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; text-decoration: none !important; }
.brand img { height: 42px; width: auto; display: block; }
.login-brand { text-align: center; margin-bottom: 1.25rem; }
.login-brand img { height: 80px; width: auto; }
.login-brand div { font-weight: 700; font-size: 1.1rem; color: var(--brand-grey); margin-top: .1rem; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
.nav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a.active, .nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.bell { position: relative; padding: .4rem .6rem; color: var(--muted); }
.account { display: flex; gap: .5rem; align-items: center; }
.account form { margin: 0; }
.menu-toggle { display: none; position: relative; background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .35rem .5rem; cursor: pointer; }
.menu-toggle .dot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--err); }
.bell .count { position: absolute; top: -2px; right: -4px; background: var(--err); color: #fff; border-radius: 999px;
  font-size: .7rem; padding: 0 .35rem; line-height: 1.3rem; min-width: 1.3rem; text-align: center; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cols { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.card + .card { margin-top: 1rem; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
/* Record pages: short facts in columns, long texts (location, detail) across the full width. */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem 1.5rem; }
.facts > div, .long { overflow-wrap: anywhere; }
.facts .k, .long .k { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .15rem; }
.long { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.cols-even { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; margin-top: 1rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--brand-soft); }
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { color: var(--text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Controls */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.danger { color: var(--err); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions form { display: inline; margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
.tabs a { padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tabs a .n { font-weight: 700; margin-left: .25rem; }
.chat-tabs-sep { width: 1px; align-self: stretch; margin: 0 .25rem; background: var(--border); }
.search { display: flex; gap: .5rem; flex-wrap: nowrap; }
.search input { min-width: 0; width: 280px; }
.page-head .actions { align-items: center; }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
.form-grid { display: grid; gap: .9rem 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field.wide { grid-column: 1 / -1; }
.payment-shot { display: block; max-width: 220px; max-height: 260px; margin-top: .4rem; border-radius: 8px; border: 1px solid var(--border); }
.field .err { color: var(--err); font-size: .85rem; }
.field .help { color: var(--muted); font-size: .8rem; }
.checks > div { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.checks > div label { display: inline-flex; align-items: center; gap: .3rem; color: var(--text); font-size: .95rem; }
.checks ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .25rem; }

/* Badges & alerts */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand); }
.badge.completed, .badge.sent, .badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled, .badge.failed, .badge.error { background: var(--err-soft); color: var(--err); }
.badge.dry_run, .badge.queued, .badge.warning, .badge.overdue { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: var(--bg); color: var(--muted); }
.alerts { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.alert { padding: .6rem .9rem; border-radius: 8px; background: var(--brand-soft); }
.alert.success { background: var(--ok-soft); color: var(--ok); }
.alert.warning { background: var(--warn-soft); color: var(--warn); }
.alert.error { background: var(--err-soft); color: var(--err); }
.view-as-bar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: center; padding: .5rem 1rem; background: var(--warn-soft); color: var(--warn); border-bottom: 2px solid var(--warn); }

/* Pickers, timelines */
.picker-results { border: 1px solid var(--border); border-radius: 8px; margin-top: .35rem; overflow: hidden; }
.picker-results button { display: block; width: 100%; text-align: left; padding: .5rem .7rem; border: 0; border-bottom: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.picker-results button:hover { background: var(--brand-soft); }
.selected-customer { display: flex; justify-content: space-between; gap: .5rem; padding: .6rem .8rem; border-radius: 8px; background: var(--brand-soft); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.notif.unread { border-left: 3px solid var(--brand); }
.pagination { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1rem; }
.empty { text-align: center; padding: 2rem; color: var(--muted); }

/* Money direction: green = money coming to AyeSay, amber = AyeSay has to pay out. */
.owe-in { color: var(--ok); font-weight: 600; }
.owe-out { color: var(--warn); font-weight: 600; }
td.num.in { color: var(--ok); }
td.num.out { color: var(--warn); }
.subnav { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stat-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stages { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; margin-top: .35rem; }
.stages .step { padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.stages .step.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.stages .step.now { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); font-weight: 600; }
.stages .arrow { color: var(--muted); font-size: .8rem; }
.badge.incomplete, .badge.unsettled { background: var(--warn-soft); color: var(--warn); }
.badge.settled { background: var(--ok-soft); color: var(--ok); }
.badge.scheduled, .badge.on_request { background: var(--brand-soft); color: var(--brand); }
.badge.paused { background: var(--warn-soft); color: var(--warn); }
.badge.ended { background: var(--bg); color: var(--muted); }
.monthly-message h3 { font-size: 1.1rem; margin: 0 0 .5rem; }
.monthly-message h4 { font-size: 1rem; margin: 1rem 0 .25rem; }
.monthly-message img { max-width: 100%; height: auto; }
.monthly-message ul { padding-left: 1.2rem; }

/* Booking history */
.history li { display: grid; gap: .15rem; }
.history .h-head { display: flex; gap: .6rem; flex-wrap: wrap; font-size: .82rem; }
.history .h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history .h-who { font-weight: 600; }
.history .h-changes { list-style: none; margin: .2rem 0 0; padding: 0 0 0 .75rem; border-left: 2px solid var(--border); font-size: .88rem; }
.history .h-changes del { color: var(--muted); }
.history .h-message .h-what, .history .h-viewed .h-what { color: var(--muted); }

/* Team chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 360px; padding: 0; }
.chat-list { list-style: none; margin: 0; padding: 1rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .6rem; }
.chat-msg { position: relative; max-width: 75%; align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: .45rem .7rem; }
.chat-msg.mine { align-self: flex-end; background: var(--brand-soft); border-color: transparent; }
.chat-meta { display: flex; gap: .5rem; align-items: baseline; font-size: .8rem; }
.chat-body { overflow-wrap: anywhere; }
.chat-del { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }
.chat-older { align-self: center; }
.chat-picture { display: block; max-width: 260px; max-height: 260px; margin-top: .4rem; border-radius: 8px; border: 1px solid var(--border); }
.chat-file { display: block; margin-top: .4rem; overflow-wrap: anywhere; }
.chat-form { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
.chat-attach { cursor: pointer; }
.chat-status { flex-basis: 100%; color: var(--muted); overflow-wrap: anywhere; }
#chat-status.err { color: var(--err); }
.chat-form textarea { flex: 1; resize: none; width: 100%; }
.chat-compose { position: relative; flex: 1 1 0; min-width: 0; display: flex; }
.mention-menu { position: absolute; bottom: 100%; left: 0; margin: 0 0 .25rem; padding: .25rem; list-style: none; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 5; }
.mention-menu li { padding: .3rem .5rem; border-radius: 6px; cursor: pointer; }
.mention-menu li.active, .mention-menu li:hover { background: var(--brand-soft); }
.emoji-menu { position: absolute; bottom: 100%; left: 0; z-index: 10; margin-bottom: .25rem; padding: .25rem; display: grid; grid-template-columns: repeat(8, 2.1rem);
  max-width: calc(100vw - 2rem); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.emoji-menu[hidden] { display: none; }
.emoji-menu button { height: 2.1rem; border: 0; border-radius: 6px; background: none; cursor: pointer; font-size: 1.15rem; line-height: 1; }
.emoji-menu button:hover { background: var(--brand-soft); }
.chat-reactions { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-top: .3rem; }
.chat-reaction { border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: inherit; cursor: pointer;
  padding: .05rem .45rem; font-size: .85rem; line-height: 1.4; }
.chat-reaction.mine { border-color: var(--brand); background: var(--brand-soft); }
.react-pick summary { list-style: none; cursor: pointer; color: var(--muted); font-size: .95rem; padding: 0 .3rem; border-radius: 999px;
  opacity: .55; }
.react-pick summary::-webkit-details-marker { display: none; }
.chat-msg:hover .react-pick summary, .react-pick[open] summary { opacity: 1; }
.react-pick summary small { font-size: .7rem; }
.react-menu { position: absolute; top: 100%; left: .4rem; z-index: 10; margin-top: .2rem; padding: .2rem; display: flex; gap: .1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.chat-msg.mine .react-menu { left: auto; right: .4rem; }
.react-menu button { width: 2rem; height: 2rem; border: 0; border-radius: 999px; background: none; cursor: pointer; font-size: 1.15rem; line-height: 1; }
.react-menu button:hover { background: var(--brand-soft); }
.chat-reply { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .95rem; line-height: 1; padding: 0 .2rem; }
.chat-meta > button { margin-left: 0; }
.chat-meta > button:first-of-type { margin-left: auto; }
.chat-quote { display: block; margin: .25rem 0; padding: .15rem .5rem; border-left: 3px solid var(--brand); border-radius: 4px;
  background: var(--surface); color: inherit; font-size: .85rem; text-decoration: none; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.chat-quote strong { margin-right: .25rem; }
.chat-replying { flex-basis: 100%; display: flex; gap: .5rem; align-items: center; padding: .3rem .5rem; border-left: 3px solid var(--brand);
  background: var(--brand-soft); border-radius: 4px; }
.chat-replying > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat.drop-here { outline: 2px dashed var(--brand); outline-offset: -6px; }
.chat-msg.flash { box-shadow: 0 0 0 3px var(--brand); transition: box-shadow .3s; }
.chat-msg.editing { width: min(100%, 520px); }
.chat-edit textarea { width: 100%; resize: vertical; }
.chat-edit-actions { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; margin-top: .3rem; }
.chat-edit-actions .btn:first-of-type { margin-left: auto; }
.chat-body .mention { color: var(--brand); }
.chat-msg.mentions-me { border-color: var(--brand); }
.nav .mention-badge { background: var(--brand); }
.nav .n-badge { background: var(--err); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; margin-left: .25rem; }

/* Phones and small tablets */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .4rem .75rem; }
  .brand img { height: 36px; }
  .bell { margin-left: auto; }
  .menu-toggle { display: inline-flex; }
  .nav, .account { display: none; order: 10; flex: 0 0 100%; }
  .topbar.menu-open .nav { display: flex; flex-direction: column; gap: .15rem; overflow: visible; padding-top: .25rem; }
  .topbar.menu-open .nav a { padding: .65rem .75rem; font-size: 1rem; }
  .topbar.menu-open .account { display: flex; padding: .25rem 0 .5rem; border-top: 1px solid var(--border); }
  main { padding: 1rem .75rem 2.5rem; }
  .page-head h1 { font-size: 1.35rem; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .search { width: 100%; }
  .search input { width: auto; flex: 1; }
  .page-head .actions { width: 100%; }
  th, td { padding: .45rem .5rem; }
  table { font-size: .9rem; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .6rem .75rem; }
  .stat .value { font-size: 1.1rem; overflow-wrap: anywhere; }
  .chat { height: calc(100dvh - 150px); }
  .chat-msg { max-width: 92%; }
  .chat-list { padding: .6rem; }
  /* iPhones zoom into inputs smaller than 16px */
  input, select, textarea { font-size: 16px; }
}
.phone-label, .phone-sort { display: none; }
/* Phones: list rows become cards (two columns of details, no header row). */
@media (max-width: 700px) {
  .phone-label { display: inline; color: var(--muted); }
  .phone-sort { display: block; margin-bottom: .75rem; }
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .2rem .75rem;
    padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
  table.cards td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  table.cards td.num { text-align: left; }
  table.cards td:empty { display: none; }
}
@media (max-width: 520px) {
  dl.fields { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  dl.fields dt { margin-top: .5rem; }
  .card { padding: .8rem; }
}
