/* ria-kyron-calls: shell and shared components. Plain CSS (no nesting) for iOS 16 Safari.
   Phone first; the desktop layout starts at 1024px. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--fs-14)/1.45 var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--accent-soft-ink); }
input, select, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 0.2em; }
@media (hover: hover) and (pointer: fine) { a:hover { color: var(--accent-hover); } }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; line-height: 1.2; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
html { scrollbar-color: var(--line-2) transparent; }
textarea { caret-color: var(--accent); }
input { caret-color: var(--accent); }

/* ------------------------------------------------------------------ shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.view {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 10px;
}
.view--wide { max-width: none; }

.page-head {
  padding: 18px 4px 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.page-head__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-head__meta { font-size: var(--fs-12); color: var(--muted); }
.page-head h1 { font-size: var(--fs-24); }
.page-head__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* phone tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 4px 4px calc(8px + env(safe-area-inset-bottom, 0px));
}
.tabbar a {
  min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: var(--fs-12); color: var(--muted); text-decoration: none; border-radius: var(--r-10);
}
.tabbar a svg { width: 20px; height: 20px; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* desktop side rail */
.rail { display: none; }

@media (min-width: 1024px) {
  .shell { flex-direction: row; }
  .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh; flex: 0 0 var(--rail-w);
    background: var(--rail); color: var(--rail-ink); padding: 24px 16px;
  }
  .rail__brand { font-family: var(--font-head); font-weight: 600; font-size: var(--fs-16); padding: 0 10px 14px; color: #fff; }
  .rail__who { font-size: var(--fs-12); color: var(--rail-quiet); padding: 0 10px 12px; }
  .rail a {
    color: var(--rail-ink); text-decoration: none; padding: 10px; border-radius: var(--r-8);
    font-size: var(--fs-14); min-height: var(--tap); display: flex; align-items: center; gap: 10px;
  }
  .rail a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
  @media (hover: hover) and (pointer: fine) { .rail a:hover { background: var(--rail-active); color: #fff; } }
  .rail a[aria-current="page"] { background: var(--rail-active); color: #fff; font-weight: 600; }
  .rail__spacer { flex: 1; }
  .rail__quiet { color: var(--rail-quiet) !important; font-size: var(--fs-13) !important; }
  .rail :focus-visible { outline-color: #9FD3C1; }
  .view { max-width: 1200px; padding: 28px 32px 40px; gap: 20px; margin: 0; }
  .view--phone { max-width: 560px; }
  .page-head { padding: 0; align-items: flex-end; }
  .page-head h1 { font-size: var(--fs-30); }
}

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-12);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.panel--tight { padding: 14px; border-radius: var(--r-14); }
.panel h2 { font-size: var(--fs-18); }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.panel__note { font-size: var(--fs-12); color: var(--muted); }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-12); }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: var(--r-10);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  font-size: var(--fs-14); font-weight: 500; text-decoration: none; text-align: center;
  transition: background-color var(--dur-ui) var(--ease-out), border-color var(--dur-ui) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .btn:hover { border-color: var(--muted); color: var(--ink); } }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); } }
.btn--dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .btn--dark:hover { background: #22302A; border-color: #22302A; color: #fff; } }
.btn--quiet { border-color: transparent; background: transparent; color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .btn--quiet:hover { background: var(--panel-2); color: var(--accent-hover); } }
.btn--danger { color: var(--bad-ink); border-color: #E2BDBD; }
.btn--big { min-height: var(--btn-big); border-radius: var(--r-12); font-size: var(--fs-16); width: 100%; }
.btn--call { min-height: 54px; font-size: var(--fs-17); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--line-2); border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
}
.btn--primary.is-busy::after, .btn--dark.is-busy::after { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* choice grid (result buttons, quick picks, how/where) */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice {
  min-height: 46px; border-radius: var(--r-10); padding: 6px 10px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  font-size: var(--fs-14); font-weight: 500; text-align: center;
}
@media (hover: hover) and (pointer: fine) { .choice:hover { border-color: var(--muted); } }
.choice[aria-pressed="true"], .choice[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* segmented filter (Everyone / Ria / Kyron ...) */
.seg { display: inline-flex; background: var(--panel-2); border-radius: var(--r-10); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  min-height: var(--tap); padding: 0 14px; border: 0; border-radius: var(--r-8);
  background: transparent; color: var(--muted); font-size: var(--fs-13); font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(22,33,29,.12); font-weight: 600; }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: var(--fs-12); font-weight: 600; padding: 4px 8px; border-radius: var(--r-6);
  background: var(--chip); color: var(--ink-2);
}
.pill--round { border-radius: var(--r-pill); padding: 6px 10px; font-weight: 500; }
.pill--ria { background: var(--ria-bg); color: var(--ria-ink); }
.pill--kyron { background: var(--kyron-bg); color: var(--kyron-ink); }
.pill--tracy { background: var(--tracy-bg); color: var(--tracy-ink); }
.pill--warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill--bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill--good { background: var(--accent-soft); color: var(--accent-soft-ink); }
.zone--east { background: var(--zone-east-bg); color: var(--zone-east-ink); }
.zone--east-near { background: var(--zone-eastnear-bg); color: var(--zone-eastnear-ink); }
.zone--west { background: var(--zone-west-bg); color: var(--zone-west-ink); }
.zone--central-south { background: var(--zone-cs-bg); color: var(--zone-cs-ink); }
.zone--tobago { background: var(--zone-tobago-bg); color: var(--zone-tobago-ink); }
.zone--abroad { background: var(--zone-abroad-bg); color: var(--zone-abroad-ink); }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-13); color: var(--ink-2); font-weight: 500; }
.field__hint { font-weight: 400; color: var(--muted); font-size: var(--fs-12); }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-10); background: var(--panel);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  font-weight: 400; color: var(--ink);
}
.textarea { min-height: 64px; resize: vertical; line-height: 1.45; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2355625C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
@media (hover: hover) and (pointer: fine) { .input:hover, .select:hover, .textarea:hover { border-color: var(--muted); } }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 92, 74, 0.18); }
.input:user-invalid, .select:user-invalid { border-color: var(--bad-ink); }
.field__error { color: var(--bad-ink); font-size: var(--fs-12); font-weight: 500; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); }
.switch input { width: 44px; height: 26px; accent-color: var(--accent); }

/* a native select dressed as a small button: the "Move to…" menu */
.move-to {
  appearance: none; -webkit-appearance: none; min-height: 36px; padding: 0 28px 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-8); background-color: var(--panel);
  font-size: var(--fs-12); font-weight: 500; color: var(--ink-2); max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1.5l4 4 4-4' fill='none' stroke='%2355625C' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
@media (pointer: coarse) { .move-to { min-height: var(--tap); font-size: 16px; } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-12); background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: var(--fs-12);
  background: var(--panel-2); padding: 10px 12px; white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
@media (hover: hover) and (pointer: fine) { .table tr:hover td { background: #F9FAF8; } }
.table .num, .table th.num { text-align: right; }

/* ------------------------------------------------------------------ states */
/* Static placeholders: the brief allows no looping animation. */
.skeleton { background: var(--panel-2); border-radius: var(--r-8); min-height: 16px; }
.skeleton--card { min-height: 220px; border-radius: var(--r-14); }
.empty { padding: 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty strong { color: var(--ink); font-size: var(--fs-16); font-family: var(--font-head); }
.error-box { background: var(--bad-bg); color: var(--bad-ink); border-radius: var(--r-10); padding: 12px 14px; font-size: var(--fs-13); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-10); padding: 10px 12px; font-size: var(--fs-13); }

/* ------------------------------------------------------------------ toast (live region, not a popover: iOS 16) */
.toasts {
  position: fixed; z-index: 50; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
@media (min-width: 1024px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%;
  background: var(--ink); color: #fff; border-radius: var(--r-10); padding: 10px 10px 10px 14px;
  font-size: var(--fs-13); display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow-pop);
}
.toast__text { flex: 1; }
.toast button, .toast a { min-height: 36px; padding: 0 10px; border-radius: var(--r-8); border: 0; background: transparent; color: #9FE1CB; font-weight: 600; font-size: var(--fs-13); text-decoration: none; display: inline-flex; align-items: center; }
@media (hover: hover) and (pointer: fine) { .toast button:hover, .toast a:hover { background: #2B3A33; color: #fff; } }
.toast__close { color: #C9D6CF !important; }
.toast--error { background: var(--bad-ink); }

/* ------------------------------------------------------------------ dialog */
dialog.dlg {
  border: 0; padding: 0; border-radius: var(--r-14); background: var(--panel); color: var(--ink);
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-pop);
}
dialog.dlg:modal { overscroll-behavior: contain; }
dialog.dlg::backdrop { background: rgba(22, 33, 29, 0.45); overflow: hidden; overscroll-behavior: contain; }
.dlg__body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dlg__body h1 { font-size: var(--fs-20); }
.dlg__text { color: var(--ink-2); font-size: var(--fs-14); }
.dlg__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.dlg__actions .btn { min-width: 96px; }

/* Check boxes and radios: at least 24px to tap; their label widens the hit area. */
input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }

/* Action bar that stays in reach: inline when it fits, pinned above the tab bar when the page is
   longer than the screen (Next call: Save and next / Book meeting). */
.action-bar {
  position: sticky; z-index: 5;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
  display: flex; flex-direction: column; gap: 6px;
  background: var(--ground); padding: 8px 0 4px; margin: 0 -4px; padding-inline: 4px;
}
@media (min-width: 1024px) { .action-bar { bottom: 16px; } }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Side rail: Export to Excel as an outlined button (frame Desktop.dc.html), owner and agent only. */
@media (min-width: 1024px) {
  .rail a.rail__export { margin-top: 12px; border: 1px solid var(--rail-line); justify-content: center; color: #fff; }
}
