/* RepliMee CRM styles.
   Base template from the design handover (tokens, shell, components), followed by
   app components the handover doesn't cover yet, built from the same tokens. */

:root {
  /* Colour (RepliMee) */
  --brand-teal: #0E7C66;
  --brand-mint: #7FE0C3; /* dark backgrounds only: too light for text on white */
  --accent: var(--brand-teal);
  --on-accent: #FFFFFF;
  --on-mint: #0B3B32;
  --dot: #2FB893;
  --accent-hover: #0B6352;
  --link: #0B6352;
  --link-hover: #0B4F42;

  --ground: #F4F6F5;
  --surface: #FFFFFF;
  --text: #141C1A;
  --text-muted: #55605D;
  --border: #E1E6E4;
  --border-strong: #C7CFCC;
  --divider: #EBEFED;
  --fill-subtle: #EDF1EF;

  --sidebar-bg: #10201D;
  --sidebar-text: #C2CECB;
  --sidebar-text-muted: #AEBBB7;
  --sidebar-label: #93A29E;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.10);
  --sidebar-avatar: #24403A;

  --info-bg: #E6F5F0;
  --info-border: #BFE3D8;
  --info-text: #0B4F42;

  --priority-high-bg: #FDE2DD;
  --priority-high-text: #8A1F0F;

  /* Focus ring glow: the brand teal. */
  --focus-glow: rgba(14, 124, 102, 0.25);

  /* Not in the handover yet: status colours for badges and warning notices (AA contrast). */
  --success-bg: #DDF3E8;
  --success-text: #0B5A3A;
  --warning-bg: #FFF1D6;
  --warning-border: #F4D79A;
  --warning-text: #6B4300;

  /* Type */
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 28px;
  --text-kpi: 32px;

  /* Shape and spacing (4px base) */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-card: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-10: 40px;
  --control-height: 44px;
  --sidebar-width: 248px;
  --content-max: 1280px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2 { margin: 0; }

.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon--bold { stroke-width: 2.2; }

/* ---------- Shell ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar :focus-visible { outline-color: #FFFFFF; }

.main { flex: 1; min-width: 0; padding: 28px var(--space-10) 48px; }

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.view { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }

/* ---------- Sidebar ---------- */

.brand { display: block; padding: 4px var(--space-3) 0; }
.brand img { display: block; width: 100%; max-width: 170px; height: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
  padding: 0 var(--space-3) var(--space-2);
  font-size: var(--text-xs); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sidebar-label);
}
.nav__item + .nav__label { padding-top: var(--space-5); }
.nav__item {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-weight: 500;
  text-decoration: none;
}
.nav__item:hover { color: #FFFFFF; background: var(--sidebar-hover); }
.nav__item[aria-current="page"] { color: #FFFFFF; background: var(--sidebar-active); font-weight: 600; }
.nav__item[aria-current="page"] svg { color: var(--brand-mint); }
.nav__item svg { flex-shrink: 0; }
.nav__text { flex: 1; }
.nav__count {
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px;
  background: var(--brand-mint); color: var(--on-mint);
  font-size: var(--text-xs); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.user {
  margin-top: auto;
  position: relative;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--sidebar-hover);
}
.user__avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--sidebar-avatar); color: #FFFFFF;
  font-weight: 700; font-size: var(--text-sm);
  display: flex; align-items: center; justify-content: center;
}
.user__meta { flex: 1; min-width: 0; }
.user__name { color: #FFFFFF; font-weight: 600; font-size: var(--text-md); }
.user__role { color: var(--sidebar-text-muted); font-size: var(--text-sm); }

/* Account menu (not in the handover yet): Change password and Log out. */
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + var(--space-2));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(14, 26, 43, 0.28);
  padding: var(--space-2); display: flex; flex-direction: column; gap: 2px; z-index: 20;
}
.menu button {
  height: var(--control-height); border: 0; background: transparent; border-radius: var(--radius-md);
  text-align: left; padding: 0 var(--space-3); color: var(--text); font-weight: 500; justify-content: flex-start;
}
.menu button:hover { background: var(--ground); }
.sidebar .menu :focus-visible { outline-color: var(--link); }

/* ---------- Buttons ---------- */

.btn, button {
  height: var(--control-height);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-md); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  white-space: nowrap;
  /* Plain <button> defaults to the secondary style. */
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
button:hover { background: var(--ground); }
.btn--primary, button.primary { border: 0; background: var(--accent); color: var(--on-accent); font-size: var(--text-base); padding: 0 18px; }
.btn--primary:hover, button.primary:hover { background: var(--accent-hover); }
.btn--secondary { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.btn--secondary:hover { background: var(--ground); }
.btn--icon { width: var(--control-height); padding: 0; border: 0; background: transparent; color: var(--sidebar-text); }
.btn--icon:hover { color: #FFFFFF; background: var(--sidebar-hover); }
button.small { padding: 0 var(--space-3); }
button.danger { color: #A1200D; }
button.primary.danger { color: var(--on-accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Page header ---------- */

.page-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); }
.page-header__titles { flex: 1 1 240px; min-width: 0; }
.page-header h1 { font-size: var(--text-xl); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.page-header__sub { color: var(--text-muted); }

.search-wrap { position: relative; flex: 1 1 240px; max-width: 340px; }
.search {
  display: flex; align-items: center; gap: 10px;
  height: var(--control-height); padding: 0 14px;
  background: var(--surface);
  border: 1px solid #CFD6D3; border-radius: var(--radius-md);
  color: var(--text-muted);
}
.search:focus-within { border-color: var(--link); box-shadow: 0 0 0 3px var(--focus-glow); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); height: auto; padding: 0; }

/* Search results (not in the handover yet): a dropdown card under the field. */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 300px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(14, 26, 43, 0.14);
  padding: var(--space-2) 0; z-index: 30; max-height: 70vh; overflow-y: auto;
}
.search-results__label {
  padding: var(--space-2) var(--space-4) var(--space-1);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
}
.search-results a { display: block; padding: var(--space-2) var(--space-4); color: var(--text); text-decoration: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--ground); outline-offset: -2px; }
.search-results__meta { font-size: var(--text-sm); color: var(--text-muted); }
.search-results__empty { padding: var(--space-3) var(--space-4); color: var(--text-muted); font-size: var(--text-md); }

/* ---------- Notice banner ---------- */

.notice, .banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  padding: 14px var(--space-4);
  background: var(--info-bg); border: 1px solid var(--info-border);
  border-radius: var(--radius-lg);
  color: var(--info-text);
}
.notice svg { flex-shrink: 0; }
.notice__body { flex: 1 1 320px; min-width: 0; }
.notice strong { font-weight: 600; }
.notice a { font-weight: 600; white-space: nowrap; }
.banner.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.notice--warning, .banner:not(.info) { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }

/* ---------- Cards ---------- */

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  min-width: 0;
}
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); }
.card__header h2 { font-size: var(--text-lg); font-weight: 700; }
.card__header a { font-size: var(--text-md); font-weight: 600; white-space: nowrap; }
.panel h2 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 var(--space-3); }
.panel h3 { font-size: var(--text-base); font-weight: 700; margin: var(--space-2) 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi__label { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.kpi__value { font-size: var(--text-kpi); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi__note { font-size: var(--text-md); color: var(--text-muted); }

.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }

/* ---------- Lists inside cards ---------- */

ul.list { list-style: none; margin: 0; padding: 0; }
ul.list > li { display: flex; align-items: flex-start; gap: var(--space-3); padding: 14px 0; border-top: 1px solid var(--divider); }
ul.list > li:last-child { padding-bottom: 0; }
.list__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.list__title { font-weight: 600; }
.list__meta { font-size: var(--text-md); color: var(--text-muted); }
.list__meta--sm { font-size: var(--text-sm); }
.list__row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.list__time { font-size: var(--text-sm); color: var(--text-muted); }
.list__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); margin-top: 8px; flex-shrink: 0; }
.list strong { font-weight: 600; }

/* Older list markup used by the other pages: rows split by a divider. */
div.list > div { padding: 14px 0; border-top: 1px solid var(--divider); }
div.list > div:first-child { border-top: 0; padding-top: var(--space-1); }

.badge, .tag {
  display: inline-block;
  padding: 2px var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 700; line-height: 1.5; white-space: nowrap;
  background: var(--fill-subtle); color: var(--text-muted);
}
.badge--high, .tag.red { background: var(--priority-high-bg); color: var(--priority-high-text); }
/* Not in the handover yet: other statuses. */
.badge--normal, .tag.blue { background: var(--info-bg); color: var(--info-text); }
.badge--low { background: var(--fill-subtle); color: var(--text-muted); }
.tag.green { background: var(--success-bg); color: var(--success-text); }
.tag.orange { background: var(--warning-bg); color: var(--warning-text); }

/* ---------- Empty state ---------- */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: 32px var(--space-4);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  text-align: center; color: var(--text-muted);
}
.empty__icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--fill-subtle); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.empty__title { font-weight: 600; color: var(--text); }
.empty__text { font-size: var(--text-md); color: var(--text-muted); }

/* ---------- Forms ---------- */

label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--text); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; min-height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid #CFD6D3; border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); font-size: var(--text-base);
}
textarea { padding: 10px var(--space-3); min-height: 96px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: var(--text-sm); min-height: 140px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--link); box-shadow: 0 0 0 3px var(--focus-glow); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--link); }
.field { margin-bottom: var(--space-4); }
.check { display: flex; gap: var(--space-2); align-items: center; font-weight: 500; font-size: var(--text-md); min-height: var(--control-height); margin: 0; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--text-sm); color: var(--text-muted); font-weight: 600; padding: 10px var(--space-3); border-bottom: 1px solid var(--border); }
td { padding: var(--space-3); border-top: 1px solid var(--divider); vertical-align: top; }
tr.clickable:hover td { background: var(--ground); cursor: pointer; }

/* ---------- Layout helpers ---------- */

.muted { color: var(--text-muted); }
.small { font-size: var(--text-md); }
.right { text-align: right; }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: var(--space-4); }
.grow { flex: 1; }
.hidden { display: none !important; }
.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* In forms, each field's own bottom margin does the vertical spacing. */
form .grid, .modal .grid { row-gap: 0; }
pre.wrap { white-space: pre-wrap; margin: 0; font-family: inherit; }
.timeline .when { color: var(--text-muted); font-size: var(--text-sm); }

/* ---------- Inbox ---------- */

.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--space-4); height: calc(100vh - 190px); min-height: 480px; }
.conv-list { overflow-y: auto; padding: 0; }
.conv-item { padding: 14px var(--space-4); border-top: 1px solid var(--divider); cursor: pointer; }
.conv-item:first-child { border-top: 0; }
.conv-item:hover { background: var(--ground); }
.conv-item.active { background: var(--info-bg); }
.conv-item .preview { color: var(--text-muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: var(--space-1); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); display: inline-block; }
.thread { display: flex; flex-direction: column; padding: 0; min-height: 0; overflow: hidden; }
.thread-head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.messages { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); background: var(--ground); min-height: 200px; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--link); color: #FFFFFF; border-bottom-right-radius: 4px; }
.bubble .subject { font-weight: 600; padding-bottom: 4px; margin-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
.bubble.out.human { background: #0F6B63; }
.bubble.out.system { background: #4A4546; }
.bubble .meta { font-size: var(--text-xs); opacity: 0.8; margin-top: var(--space-1); }
.composer { border-top: 1px solid var(--border); padding: var(--space-4) var(--space-5); }
.composer textarea { min-height: 64px; }
.typing { align-self: flex-end; color: var(--text-muted); font-size: var(--text-sm); font-style: italic; }

/* ---------- Pipeline board ---------- */

.board { display: grid; grid-template-columns: repeat(7, minmax(200px, 1fr)); gap: var(--space-3); overflow-x: auto; padding-bottom: var(--space-2); }
.column { background: var(--fill-subtle); border-radius: var(--radius-card); padding: var(--space-3); min-height: 320px; }
.column h3 { display: flex; justify-content: space-between; align-items: baseline; text-transform: capitalize; font-size: var(--text-md); margin: var(--space-1) var(--space-1) var(--space-3); }
.board .card { padding: var(--space-3); margin-bottom: var(--space-2); border-radius: var(--radius-lg); }
.board .card select { margin-top: var(--space-2); }

/* ---------- Dialogs and toasts ---------- */

.modal-back { position: fixed; inset: 0; background: rgba(35, 31, 32, 0.5); display: flex; align-items: flex-start; justify-content: center; padding: 60px var(--space-4); z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-card); padding: var(--space-6); width: 100%; max-width: 580px; box-shadow: 0 24px 60px rgba(14, 26, 43, 0.3); }
.modal h2 { font-size: 20px; margin-bottom: var(--space-4); }
.toast { position: fixed; bottom: var(--space-5); right: var(--space-5); background: var(--sidebar-bg); color: #FFFFFF; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); z-index: 100; max-width: 420px; box-shadow: 0 12px 32px rgba(14, 26, 43, 0.3); }
.toast.error { background: #A1200D; }
.slot-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-2) 0; }
.slot-list button.selected { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- Sign in ---------- */

.login { max-width: 400px; margin: 14vh auto; }
.login h1 { font-size: 24px; margin-bottom: var(--space-4); }
.login .brand { padding: 0; margin-bottom: var(--space-6); }

/* ---------- Breakpoints ---------- */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { flex-basis: auto; position: static; height: auto; }
  .main { padding: var(--space-5) var(--space-4) 32px; }
  .search-wrap { max-width: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; }
  .user .menu { bottom: auto; top: calc(100% + var(--space-2)); }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .bubble { max-width: 90%; }
}

/* AI agents (Hire page) */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-5); align-items: stretch; }
.agents-summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-5); margin-bottom: var(--space-5); font-weight: 600;
}
.agents-summary strong { font-size: var(--text-lg); }
.agents-summary small { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }

.agent-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.agent-card:hover { box-shadow: 0 8px 24px rgba(35, 31, 32, 0.08); transform: translateY(-2px); }
.agent-card--hired { border: 2px solid var(--accent); }
.agent-card__hero { position: relative; display: flex; justify-content: center; padding: var(--space-6) var(--space-4) var(--space-4); }
.agent-card__face { width: 128px; height: 128px; overflow: visible; }
.agent-card--soon .agent-card__face { opacity: 0.8; }
.agent-card__badge {
  position: absolute; top: var(--space-3); right: var(--space-3);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: var(--fill-subtle); color: var(--text-muted);
}
.agent-card__badge--hired { background: var(--accent); color: var(--on-accent); }
.agent-card__body { display: flex; flex-direction: column; flex: 1; padding: var(--space-4) var(--space-5) var(--space-5); }
.agent-card__role { font-size: var(--text-lg); font-weight: 800; margin: 0; }
.agent-card__tagline { margin: 2px 0 var(--space-4); color: var(--text-muted); font-size: var(--text-md); }
.agent-card__label { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--space-2); }
.agent-card__functions { list-style: none; margin: 0 0 var(--space-4); padding: 0; font-size: var(--text-md); }
.agent-card__functions li { position: relative; padding-left: 24px; margin: 6px 0; line-height: 1.4; }
.agent-card__functions li::before {
  content: ""; position: absolute; left: 2px; top: 4px; width: 12px; height: 7px;
  border-left: 2.5px solid var(--success-text); border-bottom: 2.5px solid var(--success-text); transform: rotate(-45deg);
}
.agent-card__price { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--divider); }
.agent-card__amount { font-size: var(--text-xl); font-weight: 800; letter-spacing: -0.02em; }
.agent-card__per { color: var(--text-muted); font-weight: 600; margin-left: 2px; }
.agent-card__terms { font-size: var(--text-sm); color: var(--text-muted); }
.agent-card__needs { margin-top: var(--space-3); font-size: var(--text-sm); background: var(--warning-bg); color: var(--warning-text); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.agent-card__action { padding-top: var(--space-4); }
.agent-card__action button { width: 100%; }

[hidden] { display: none !important; }

/* PA seats */
.agent-card__seats { margin-top: var(--space-3); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-md); }
.agent-card__seats button { margin-left: auto; }
.seat-list { max-height: 50vh; overflow: auto; }
.seat { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-2) 0; }

/* Personal Assistant panel */
.assistant-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 18px 0 6px;
  border: 0; border-radius: 999px; background: var(--sidebar-bg); color: #fff; font-weight: 700;
  box-shadow: 0 8px 24px rgba(35, 31, 32, 0.25); cursor: pointer;
}
.assistant-fab:hover { background: #1B332E; }
.assistant-fab__face svg, .assistant__face svg { width: 40px; height: 40px; display: block; overflow: visible; }
.assistant {
  position: fixed; right: 20px; bottom: 84px; z-index: 41; width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100vh - 110px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(35, 31, 32, 0.2); overflow: hidden;
}
.assistant__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--divider); background: var(--info-bg); }
.assistant__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.assistant__titles select { height: 28px; font-size: var(--text-sm); padding: 0 6px; border-radius: var(--radius-sm); max-width: 100%; }
.assistant__head .btn--icon {
  width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.assistant__head .btn--icon:hover { background: var(--fill-subtle); color: var(--text); }
.assistant__msgs { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.assistant__empty p { margin: 0 0 var(--space-3); font-size: var(--text-md); }
.assistant__suggestions { display: flex; flex-direction: column; gap: var(--space-2); }
.assistant__suggestions button { text-align: left; height: auto; padding: 10px 12px; font-size: var(--text-md); }
.assistant__form { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--divider); align-items: flex-end; }
.assistant__form textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; padding: 11px 12px; font: inherit; line-height: 1.4; }
.assistant__form button { width: 44px; padding: 0; flex-shrink: 0; }

.bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: var(--text-md); line-height: 1.45; overflow-wrap: anywhere; }
.bubble--me { align-self: flex-end; background: var(--sidebar-bg); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.bubble--ai { align-self: flex-start; background: var(--fill-subtle); border-bottom-left-radius: 4px; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 1.3em; }
.md code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 4px; font-size: 0.92em; }
.md-table { overflow-x: auto; margin: 4px 0 8px; }
.md-table table { font-size: var(--text-sm); }
.md-table th, .md-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.draft { position: relative; background: var(--surface); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0 8px; }
.draft__copy { position: absolute; top: 6px; right: 6px; height: 26px; padding: 0 8px; font-size: var(--text-xs); }
.draft__text { padding-right: 56px; white-space: normal; }
.typing { display: flex; gap: 4px; padding: 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); opacity: 0.4; animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; } .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; } .agent-card { transition: none; } }

/* Bookkeeping */
.xero-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.xero-bar svg { width: 52px; height: 52px; overflow: visible; }
.bk-ask { display: flex; flex-direction: column; }
.bk-ask__msgs { flex: 1; min-height: 160px; max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
td.right, th.right { text-align: right; }
@media (max-width: 800px) { .assistant { right: 16px; bottom: 80px; } .assistant-fab { right: 16px; bottom: 16px; } }

/* Receipts */
.snap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--space-5); align-items: start; }
.snap__intro { display: flex; gap: var(--space-3); }
.snap__intro h2 { margin-bottom: 4px; }
.snap__intro .icon { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.snap__form .row button { flex: 1; }
.receipt-list { display: flex; flex-direction: column; }
.receipt-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; gap: var(--space-3); align-items: center;
  width: 100%; height: auto; padding: var(--space-2) 0; border: 0; border-bottom: 1px solid var(--divider); border-radius: 0;
  background: none; text-align: left; font: inherit; color: inherit;
}
.receipt-row:hover { background: var(--fill-subtle); }
.receipt-row__thumb { width: 52px; height: 52px; object-fit: cover; border-radius: var(--radius-sm); background: var(--fill-subtle); }
.receipt-row__main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.receipt-row__main > * { overflow: hidden; text-overflow: ellipsis; }
.receipt-row__amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.receipt-row__warn { color: var(--warning-text); display: inline-flex; gap: 4px; align-items: center; }
.modal:has(.receipt-review) { max-width: 980px; }
.receipt-review { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: var(--space-6); }
.receipt-review__image img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--radius-md); background: var(--fill-subtle); }
.receipt-warnings { margin: 0; padding: var(--space-2) var(--space-3) var(--space-2) 2em; background: var(--warning-bg); color: var(--warning-text); border-radius: var(--radius-sm); font-size: var(--text-md); }
.receipt-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-4); margin: 0; }
.receipt-facts dt { color: var(--text-muted); font-weight: 600; }
.receipt-facts dd { margin: 0; }
.segmented { display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; cursor: pointer; font-weight: 600; font-size: var(--text-md); }
.segmented label:has(input:checked) { background: var(--sidebar-bg); color: #fff; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus-glow); }
@media (max-width: 800px) {
  .snap, .receipt-review { grid-template-columns: 1fr; }
  .receipt-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .receipt-row > span:last-child { grid-column: 2 / -1; }
}
.receipt-row__pdf { display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 800; color: var(--text-muted); }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: 0; }
.tabs button { border: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: none; height: 40px; padding: 0 var(--space-4); font-weight: 600; color: var(--text-muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom-color: var(--surface); margin-bottom: -1px; }

/* Notifications */
.bell-wrap { position: relative; }
.bell {
  position: relative; width: var(--control-height); height: var(--control-height); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--text);
}
.bell:hover { background: var(--fill-subtle); }
.bell__count {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; line-height: 20px; text-align: center;
}
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 45; width: min(400px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: 0 16px 48px rgba(35, 31, 32, 0.18);
  overflow: hidden;
}
.bell-panel__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--divider); }
.bell-panel__list { max-height: min(480px, 70vh); overflow-y: auto; }
.notif {
  display: flex; justify-content: flex-start; align-items: flex-start; gap: var(--space-3); width: 100%; height: auto;
  padding: var(--space-3) var(--space-4); text-align: left; white-space: normal; font-weight: 400;
  border: 0; border-bottom: 1px solid var(--divider); border-radius: 0; background: none; font: inherit; color: inherit;
}
.notif__main { flex: 1; overflow-wrap: anywhere; }
.bell-panel__list { overflow-x: hidden; }
.notif:hover { background: var(--fill-subtle); }
.notif--unread { background: #EEF8F4; }
.notif__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif__dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--border-strong); }
.notif__dot--urgent { background: #D2361F; }
.notif__dot--action { background: var(--accent); }
.notif__dot--info { background: var(--sidebar-label); }
.np-device { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding: var(--space-4); }
.np-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.np-group legend { font-weight: 700; margin-bottom: var(--space-2); }
.np-group .check { align-items: flex-start; }

/* Phone layout: compact top bar, menu behind a button */
.sidebar__top { display: flex; align-items: center; justify-content: space-between; }
.sidebar__body { display: flex; flex-direction: column; gap: 28px; flex: 1; }
.nav-toggle { display: none; }
@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-basis: auto; padding: 10px var(--space-4); gap: 0; overflow: visible; }
  .sidebar .brand img { width: 150px; height: auto; }
  .nav-toggle {
    display: inline-flex; position: relative; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: var(--radius-md); background: transparent; color: #FFFFFF;
  }
  .nav-toggle:hover { background: var(--sidebar-hover); }
  .nav-toggle__dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
  .sidebar__body { display: none; }
  body.nav-open .sidebar__body {
    display: flex; position: fixed; inset: 64px 0 0 0; z-index: 30; overflow-y: auto;
    background: var(--sidebar-bg); padding: var(--space-4) var(--space-4) var(--space-6);
  }
  body.nav-open { overflow: hidden; }
  .page-header { flex-wrap: wrap; }
  .bell-panel { position: fixed; left: 16px; right: 16px; top: 72px; width: auto; }
}
.np-times input { width: auto; flex: 0 0 auto; }
.np-times span { color: var(--text-muted); }
body.nav-open .assistant-fab, body.nav-open .assistant { display: none; }

/* An agent's own page */
.train { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.train-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; height: calc(100vh - 170px); min-height: 520px; position: sticky; top: 16px; }
.train-chat__head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-4) var(--space-3); border-bottom: 1px solid var(--divider); }
.train-chat__head svg { width: 52px; height: 52px; flex-shrink: 0; overflow: visible; }
.train-chat__head h2 { margin: 0; }
.train-chat__head p { margin: 2px 0 0; }
.train-chat__head > div { flex: 1; }
.train-chat__msgs { flex: 1; }
.train-change { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: 8px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info-text); font-size: var(--text-sm); }
.train-coaching { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); margin: 0 var(--space-3); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warning-bg); color: var(--warning-text); font-size: var(--text-sm); }
.instr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.instr { padding: var(--space-3) 0; border-bottom: 1px solid var(--divider); display: grid; grid-template-columns: 1fr auto; gap: 4px var(--space-3); }
.instr__text { font-size: var(--text-md); }
.instr__meta { grid-column: 1; }
.instr__actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: var(--space-2); align-items: flex-start; }
.instr--off .instr__text { color: var(--text-muted); text-decoration: line-through; }
.work-list { display: flex; flex-direction: column; }
.work-row { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--divider); }
.work-row .row { flex-shrink: 0; align-items: flex-start; }
.agent-card__action .row .btn { justify-content: center; }
.assistant__head a.btn--icon { color: var(--text); }
@media (max-width: 1000px) {
  .train { grid-template-columns: minmax(0, 1fr); }
  .train-chat { position: static; height: 70vh; }
  .instr { grid-template-columns: 1fr; }
  .instr__actions { grid-row: auto; grid-column: 1; }
}

/* ---------- Support tickets ---------- */
.support-link { margin-bottom: var(--space-4); }
.conv-filter { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--divider); position: sticky; top: 0; background: var(--surface); }
.ticket-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2) var(--space-3); }
.ticket-controls label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.ticket-controls select { width: 100%; min-height: 36px; padding: 4px 8px; }
/* A ticket scrolls as one page, so the reply box is always reachable on smaller screens. */
.thread.ticket-view { overflow-y: auto; }
.ticket-view .messages { flex: none; overflow: visible; min-height: 120px; }
.bubble.note { align-self: stretch; max-width: none; background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
