/* StarShield Voice Agents portal.
   Tokens first (light, then dark), then layout, then components. Templates rely on these class names. */

:root {
  --bg: #f4f6f8; --panel: #ffffff; --panel-2: #f8fafb; --text: #16212b; --muted: #64707d; --line: #e3e8ec; --line-2: #eef1f4;
  --brand: #0e6b6f; --brand-2: #0a5357; --brand-soft: #e3f2f1; --accent: #0e6b6f; --accent-text: #ffffff;
  --side: #0d2b2f; --side-text: #c7d6d7; --side-muted: #7f9799; --side-hover: #143a3f; --side-on: #1b4b51;
  --pos: #12804a; --neu: #7b8794; --mix: #a86a00; --neg: #c8312b;
  --pos-bg: #e1f5ea; --neu-bg: #edf0f3; --mix-bg: #fff3d6; --neg-bg: #fde8e7;
  --chat-agent: #e9f4f3; --chat-user: #f1f3f5;
  --shadow: 0 1px 2px rgba(16, 33, 43, .05), 0 1px 3px rgba(16, 33, 43, .06);
  --shadow-lg: 0 10px 30px rgba(16, 33, 43, .12);
  --radius: 12px; --radius-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1417; --panel: #111d21; --panel-2: #0f1a1e; --text: #e4ecee; --muted: #8fa0a5; --line: #22333a; --line-2: #1a2a30;
    --brand: #3fb7b0; --brand-2: #5cc8c1; --brand-soft: #123236; --accent: #45bdb6; --accent-text: #05211f;
    --side: #08110f; --side-text: #b8cbcc; --side-muted: #6d8588; --side-hover: #11231f; --side-on: #173431;
    --pos: #45c47f; --neu: #8d9aa3; --mix: #e0a63a; --neg: #f0675f;
    --pos-bg: #10291d; --neu-bg: #1a262b; --mix-bg: #2a2212; --neg-bg: #2e1514;
    --chat-agent: #12302f; --chat-user: #1a262b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1417; --panel: #111d21; --panel-2: #0f1a1e; --text: #e4ecee; --muted: #8fa0a5; --line: #22333a; --line-2: #1a2a30;
  --brand: #3fb7b0; --brand-2: #5cc8c1; --brand-soft: #123236; --accent: #45bdb6; --accent-text: #05211f;
  --side: #08110f; --side-text: #b8cbcc; --side-muted: #6d8588; --side-hover: #11231f; --side-on: #173431;
  --pos: #45c47f; --neu: #8d9aa3; --mix: #e0a63a; --neg: #f0675f;
  --pos-bg: #10291d; --neu-bg: #1a262b; --mix-bg: #2a2212; --neg-bg: #2e1514;
  --chat-agent: #12302f; --chat-user: #1a262b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ------------------------------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 11.5px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
h1 .muted { font-weight: 500; font-size: 16px; }
ul { padding-left: 18px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------------------------------- layout */
body.app { display: flex; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; width: 236px; flex: 0 0 236px; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; z-index: 30; }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 28px 56px; }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 15px; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--side-muted); letter-spacing: .02em; }
.logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 16px;
  color: #fff; background: linear-gradient(135deg, #18a39b, #0e6b6f); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); flex: none; }

.logo.img { background: none; box-shadow: none; border-radius: 0; object-fit: contain; }

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.navgroup { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; font-weight: 650; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.sidenav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.sidenav a.on { background: var(--side-on); color: #fff; box-shadow: inset 3px 0 0 #3fc1b8; }
.sidenav a span { flex: 1; }
.ico { width: 18px; height: 18px; flex: none; }
.count { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(63, 193, 184, .18); color: #7fe0d8; }
.count.low { background: rgba(240, 103, 95, .2); color: #ff9c95; }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: var(--side-text); }
.me:hover, .me.on { background: var(--side-hover); text-decoration: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #1d5d61; color: #fff; flex: none; }
.me-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.me-text b { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text .pill { align-self: flex-start; font-size: 10.5px; padding: 0 7px; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.side .theme-switch { border-color: rgba(255, 255, 255, .12); }
.side .theme-switch button { color: var(--side-muted); }
.side .theme-switch button[aria-pressed="true"] { background: var(--side-on); color: #fff; }
.iconbtn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: transparent; border: 0;
  color: inherit; padding: 0; margin: 0; cursor: pointer; }
.side .iconbtn { color: var(--side-muted); }
.side .iconbtn:hover { background: var(--side-hover); color: #fff; }

.mobilebar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(5, 15, 18, .45); z-index: 25; }

@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; visibility: hidden; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); visibility: visible; }
  .mobilebar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; padding: 8px 12px;
    background: var(--side); color: #fff; }
  .mobilebar .brand { padding: 0; font-size: 15px; }
  .mobilebar .logo { width: 28px; height: 28px; font-size: 14px; }
  main { padding: 18px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* ----------------------------------------------------------------------------------------- pages */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head > h1, .head > h2 { margin: 0; }
.card > .head { margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
  min-width: 0; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid2 > .card, .grid3 > .card, .grid2 > div > .card:last-child { margin-bottom: 0; }
.grid2 > div > .card + .card { margin-top: 18px; }
@media (max-width: 420px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card .tiles { margin-bottom: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); opacity: .55; }
.card .tile { box-shadow: none; background: var(--panel-2); }
.tile .k { color: var(--muted); font-size: 12px; font-weight: 550; }
.tile .v { font-size: 26px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; }
.tile .v a { color: inherit; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.small-v, .tile .v.small-v { font-size: 15px; font-weight: 650; letter-spacing: 0; }

/* Tables */
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
thead th { color: var(--muted); font-weight: 650; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  background: var(--panel-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; }
thead th:first-child { border-top-left-radius: 8px; } thead th:last-child { border-top-right-radius: 8px; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tbody tr:hover td { background: var(--panel-2); }
tr.muted td { color: var(--muted); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; } .nowrap { white-space: nowrap; }
td.center.muted, p.muted.center { padding: 22px 12px; }
.err { color: var(--neg); }
.ok-note { color: var(--pos); }
.bad-text { color: var(--neg); }

/* Alerts: messages shown as their own card (or .alert) become banners */
.card.err, .card.ok-note, .alert { border-radius: var(--radius-sm); padding: 11px 14px; font-weight: 550; box-shadow: none; margin-bottom: 16px; }
.card.err, .alert.err { background: var(--neg-bg); border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent); color: var(--neg); }
.card.ok-note, .alert.ok { background: var(--pos-bg); border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); color: var(--pos); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--neu-bg); color: var(--text); white-space: nowrap; line-height: 1.6; }
.pill.s-positive, .pill.ok, .pill.i-hot { background: var(--pos-bg); color: var(--pos); }
.pill.s-negative, .pill.bad { background: var(--neg-bg); color: var(--neg); }
.pill.s-mixed, .pill.warn, .pill.i-warm { background: var(--mix-bg); color: var(--mix); }
.pill.role-superadmin { background: #f6e6fb; color: #8a2bb0; }
.pill.role-admin { background: #e3eefc; color: #1f5fbf; }
.pill.role-caller { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill.role-superadmin { background: #2c1836; color: #d39bf0; }
  :root:not([data-theme="light"]) .pill.role-admin { background: #142540; color: #8db8f5; }
}
:root[data-theme="dark"] .pill.role-superadmin { background: #2c1836; color: #d39bf0; }
:root[data-theme="dark"] .pill.role-admin { background: #142540; color: #8db8f5; }
.side .pill.role-superadmin { background: rgba(211, 155, 240, .18); color: #e2b8f7; }
.side .pill.role-admin { background: rgba(141, 184, 245, .18); color: #b4d0fa; }
.side .pill.role-caller { background: rgba(63, 193, 184, .18); color: #8fe3dc; }

/* Bars */
.barrow { display: grid; grid-template-columns: minmax(110px, 40%) 1fr 44px; align-items: center; gap: 12px; margin: 8px 0; }
.barrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.barrow b { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar i.s-positive { background: var(--pos); } .bar i.s-neutral { background: var(--neu); } .bar i.s-mixed { background: var(--mix); } .bar i.s-negative { background: var(--neg); }
.barrow.funnel { grid-template-columns: minmax(150px, 38%) 1fr 44px 48px; }
.barrow em { font-style: normal; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Forms */
label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
  color: var(--text); max-width: 100%; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
label input, label select { display: block; width: 100%; margin-top: 5px; color: var(--text); font-weight: 400; }
input[type="file"] { padding: 6px; background: var(--panel-2); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-text);
  border: 1px solid var(--accent); cursor: pointer; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; line-height: 1.3;
  transition: background .15s, box-shadow .15s, transform .05s; text-decoration: none; }
button:hover, .btn:hover { background: var(--brand-2); border-color: var(--brand-2); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary { background: var(--panel); color: var(--accent); border-color: var(--line); }
button.secondary:hover { background: var(--panel-2); border-color: var(--accent); }
button.danger { color: var(--neg); }
button.danger:hover { border-color: var(--neg); background: var(--neg-bg); }
button.wide { width: 100%; padding: 10px 16px; }
button[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.card button { margin-top: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters button, .filters .btn { margin-top: 0; }
.filters label { margin-bottom: 0; }
.card.filters { padding: 12px 14px; }
.head .filters label { margin-bottom: 0; display: flex; align-items: center; gap: 6px; }
.head .filters label input { margin-top: 0; width: auto; }
form.inline { margin: 0; }
button.linkish { background: none; border: 0; color: var(--accent); padding: 0 4px; margin: 0; font-size: 12px; font-weight: 600; }
button.linkish:hover { background: none; text-decoration: underline; }

fieldset.agents-pick { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 4px 0 12px; background: var(--panel-2); }
.agents-pick legend { font-size: 12px; color: var(--muted); padding: 0 6px; font-weight: 600; }
.agents-pick .checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 14px; max-height: 260px; overflow: auto; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin: 5px 0; font-weight: 400; }
label.check input { width: 16px; margin: 0; }

details.credit-actions summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; list-style: none; }
details.credit-actions summary::-webkit-details-marker { display: none; }
details.credit-actions summary::after { content: " ▾"; font-size: 11px; }
details.credit-actions[open] summary::after { content: " ▴"; }
details.credit-actions form { margin-top: 8px; }
details.credit-actions input { width: 110px; }
details.credit-actions input[name=note] { width: 180px; }

details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 12px; }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; padding-top: 14px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* Conversation */
.chat { display: flex; flex-direction: column; gap: 10px; max-width: 840px; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 85%; }
.msg.agent { background: var(--chat-agent); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--chat-user); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .who { font-size: 11.5px; font-weight: 700; margin-bottom: 2px; color: var(--muted); }
.talk .filters label { margin-bottom: 0; }
.talk .chat { margin-top: 14px; max-height: 380px; overflow: auto; }
.player { width: 100%; max-width: 560px; }
pre.script { white-space: pre-wrap; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--panel-2);
  border: 1px solid var(--line-2); padding: 14px; border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; }
#flt { min-width: 240px; }

/* Theme switch */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.theme-switch button { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 5px 9px; font-size: 11.5px;
  margin: 0; font-weight: 600; }
.theme-switch button:hover { background: transparent; color: var(--text); }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }
.side .theme-switch button + button { border-left-color: rgba(255, 255, 255, .12); }

/* Reports */
.filters .quick { display: flex; gap: 6px; }
.filters .quick button { margin-top: 0; }
.chartwrap { position: relative; }
.daychart { width: 100%; height: auto; display: block; }
.daychart .grid { stroke: var(--line); stroke-width: 1; }
.daychart .axis { fill: var(--muted); font-size: 11px; }
.daychart .col { fill: var(--brand); }
.daychart .hit { fill: transparent; }
.daychart .day.on .hit { fill: var(--panel-2); }
.charttip { position: absolute; pointer-events: none; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-lg); }

/* Error page */
.narrow-wide { max-width: 560px; }

/* ----------------------------------------------------------------------------------------- login */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(24, 163, 155, .18), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(14, 107, 111, .16), transparent 60%), var(--bg); }
.login-theme { position: fixed; top: 14px; right: 14px; }
.login-wrap { width: 100%; max-width: 880px; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); }
.login-intro { background: linear-gradient(160deg, #0d2b2f, #0e4d50 70%, #12706f); color: #d8e7e7; padding: 36px 34px; display: flex; flex-direction: column; gap: 18px; }
.login-intro h2 { font-size: 22px; line-height: 1.3; color: #fff; margin: 12px 0 0; font-weight: 700; }
.login-intro ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.login-intro li { padding-left: 26px; position: relative; }
.login-intro li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; display: grid;
  place-items: center; font-size: 11px; background: rgba(63, 193, 184, .25); color: #9ff0e8; }
.brand.big { padding: 0; font-size: 17px; }
.brand.big small { color: #9cb7b8; }
.logo-plate { align-self: flex-start; background: #fff; border-radius: 12px; padding: 10px 14px; }
.logo-plate img { display: block; height: 52px; width: auto; }
.login-card { margin: 0; border: 0; border-radius: 0; box-shadow: none; padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card > p.muted { margin: 0 0 20px; }
@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-intro { padding: 26px 24px; }
  .login-intro ul { display: none; }
  .login-card { padding: 28px 24px; }
}
.btn.secondary { background: var(--panel); color: var(--accent); border-color: var(--line); }
.btn.secondary:hover { background: var(--panel-2); border-color: var(--accent); }
.login-intro h2, h1 { text-wrap: balance; }

/* Login details */
code { font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px; }
.creds dd code { font-size: 14px; }
textarea.cred-text { width: 100%; margin: 14px 0 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; }
.sendopts { margin: 2px 0 6px; gap: 18px; }
.sendopts label.check { margin: 0; }
.alert.info { background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand); }

/* One credit box: action, amount, note, apply */
form.credit-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
form.credit-box select { width: auto; }
form.credit-box input[name=amount] { width: 96px; }
form.credit-box input[name=note] { flex: 1 1 160px; min-width: 140px; }
form.credit-box button { margin-top: 0; }
td form.credit-box { min-width: 380px; }

/* Account, 2FA, tickets */
.sub-h { margin: 4px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
textarea { width: 100%; display: block; margin-top: 5px; resize: vertical; font: inherit; }
ol.steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; }
.tfa-setup { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.tfa-setup .qr { background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); line-height: 0; }
code.key { display: inline-block; margin-top: 4px; font-size: 14px; letter-spacing: .04em; word-break: break-all; }
.grid3.tight { gap: 12px; margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.thread { display: flex; flex-direction: column; gap: 10px; }
.thread .msg { max-width: 92%; }
.thread .msg .text { white-space: pre-wrap; }
.sysmsg { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 3px 12px; text-align: center; }
.pill.big { font-size: 13px; padding: 3px 12px; }
.ticket-grid { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 900px) { .ticket-grid { grid-template-columns: 1fr; } }
details summary { cursor: pointer; }

/* Credit usage */
.credit-hint { margin: 4px 0 2px; }
.credit-rules table.compact { max-width: 420px; margin: 6px 0 10px; }
.credit-rules table.compact th, .credit-rules table.compact td { padding: 6px 10px; }
.credit-rules ul { margin: 0; }

.grid2.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid2.two { grid-template-columns: 1fr; } }
.alert ul { margin: 6px 0 0; }

/* WhatsApp */
tr.unread td { font-weight: 600; }
.wa-thread .thread { max-height: 62vh; overflow-y: auto; padding: 4px 2px 8px; }
.msg.wa .text { white-space: pre-wrap; }
.msg.wa .meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }
.msg.user.wa { background: #dcf8c6; color: #10221a; }
:root[data-theme="dark"] .msg.user.wa { background: #144d37; color: #e4f5ec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg.user.wa { background: #144d37; color: #e4f5ec; } }
.tick { font-size: 11px; color: var(--muted); }
.tick-read { color: #34b7f1; } .tick-failed { color: var(--neg); font-weight: 700; }
.wa-compose { margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.tpl-preview { white-space: pre-wrap; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; margin: 6px 0 10px; min-height: 40px; }
.tpl-preview:empty { display: none; }

.card .checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; }

/* Agent form and review */
.card.never { border-color: color-mix(in srgb, var(--neg) 35%, var(--line)); }
.card.never h2 { color: var(--neg); }
table.diff td { white-space: pre-wrap; vertical-align: top; font-size: 13px; }
table.diff td.was { background: var(--neg-bg); }
table.diff td.now { background: var(--pos-bg); }

/* ---------------------------------------------------------------- call page */
.call-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 22px; }
.call-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.call-id h1 { font-size: 24px; margin: 2px 0 4px; }
.call-id .sub-h { gap: 6px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.avatar.big { width: 52px; height: 52px; font-size: 21px; background: var(--brand); flex: none; }
.avatar.big.in { background: #6a4bc4; }
.call-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.call-actions form { margin: 0; }
.call-actions button { margin-top: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .95em; }
.pill .dot, .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px;
  animation: pulse 1.4s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.call-tiles .tile .v .pill { font-size: 14px; padding: 2px 12px; }
.call-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.call-main .card:last-child, .call-side .card:last-child { margin-bottom: 0; }
@media (max-width: 1000px) { .call-grid { grid-template-columns: 1fr; } }
p.summary { font-size: 15px; line-height: 1.6; margin: 0 0 12px; }
.next-step { background: var(--brand-soft); border-left: 3px solid var(--brand); border-radius: 8px; padding: 10px 14px; margin: 4px 0 6px; }
.next-step .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; margin-bottom: 2px; }
ul.points { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.chat.transcript { max-height: 560px; overflow-y: auto; padding-right: 4px; max-width: none; }
.kv.compact { grid-template-columns: 96px 1fr; gap: 7px 10px; font-size: 13px; }
.hist { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2);
  color: var(--text); font-size: 13px; }
.hist:first-of-type { border-top: 0; }
.hist:hover { text-decoration: none; color: var(--accent); }

/* -------------------------------------------------------------- agents page */
details.campaign summary { list-style: none; cursor: pointer; }
details.campaign summary::-webkit-details-marker { display: none; }
details.campaign summary::before { content: "+ "; color: var(--accent); font-weight: 700; }
details.campaign[open] summary::before { content: "− "; }
.agent-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.agent-toolbar #flt { flex: 1 1 260px; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
button.chip { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 500; margin: 0; }
button.chip b { color: var(--muted); font-weight: 600; margin-left: 2px; }
button.chip:hover { background: var(--panel-2); border-color: var(--accent); }
button.chip.on { background: var(--brand); color: var(--accent-text); border-color: var(--brand); }
button.chip.on b { color: inherit; opacity: .8; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.agent-card { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .15s; }
.agent-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.agent-card.is-off { opacity: .8; }
.agent-card[hidden] { display: none; }
.ac-top { display: flex; gap: 12px; align-items: flex-start; }
.ac-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none;
  color: hsl(var(--h) 55% 30%); background: hsl(var(--h) 60% 92%); }
:root[data-theme="dark"] .ac-icon { color: hsl(var(--h) 70% 78%); background: hsl(var(--h) 35% 20%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ac-icon { color: hsl(var(--h) 70% 78%); background: hsl(var(--h) 35% 20%); } }
.ac-icon svg { width: 22px; height: 22px; }
.ac-icon-sm { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.ac-icon-sm svg { width: 16px; height: 16px; }
.agent-name { display: inline-flex; align-items: center; gap: 10px; }
.ac-title { min-width: 0; }
.ac-title b { display: block; font-size: 15px; line-height: 1.3; }
.ac-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.ac-tags .pill { font-size: 11px; padding: 0 8px; }
.ac-tags .dot { width: 6px; height: 6px; margin-right: 4px; animation: none; }
.ac-industry { color: var(--brand); font-weight: 600; }
.ac-types { display: flex; flex-wrap: wrap; gap: 4px; color: var(--muted); min-height: 24px; }
.ac-types span { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 7px; }
.ac-types .more { border-style: dashed; }
.ac-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: auto; }
.ac-stats div { display: flex; flex-direction: column; }
.ac-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.ac-stats span { font-size: 11px; color: var(--muted); }
.ac-foot { display: flex; justify-content: space-between; gap: 8px; }
.card.empty { text-align: center; padding: 36px 20px; }

.side-tz { color: var(--side-muted); padding: 0 8px; font-size: 11px; }
/* Report: outgoing / incoming split */
.daychart .col.in { fill: #7c5cd6; }
.daychart .col.web { fill: #c9a227; }
.legend { display: flex; gap: 14px; margin-top: 6px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); vertical-align: middle; }
i.sw.in { background: #7c5cd6; } i.sw.web { background: #c9a227; }

.copyrow { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; flex-wrap: wrap; }
.copyrow code { word-break: break-all; }

.media-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.media-form input { flex: 1 1 260px; font-size: 12px; padding: 5px 8px; }
.media-form button { margin: 0; padding: 4px 10px; font-size: 12px; }

/* Call results */
.bar i.o-conversation { background: var(--pos); } .bar i.o-hung_up { background: var(--mix); }
.bar i.o-no_answer, .bar i.o-busy, .bar i.o-unreachable, .bar i.o-not_connected { background: var(--neg); }
form.check-now { float: right; margin: 2px 0 0 10px; }
form.check-now button { margin: 0; }

/* WhatsApp template builder */
.grid2.tight { gap: 0 14px; margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tpl-builder { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.tpl-builder .tb-side { position: sticky; top: 16px; }
@media (max-width: 900px) { .tpl-builder { grid-template-columns: 1fr; } .tpl-builder .tb-side { position: static; order: -1; } }
.tpl-builder .count { float: right; font-weight: 400; }
.tb-btn { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px 2px; margin-bottom: 10px; background: var(--panel-2); }
.tb-btn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.wa-phone { background: #e5ddd5; border-radius: 10px; padding: 14px 12px; }
:root[data-theme="dark"] .wa-phone { background: #0b141a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa-phone { background: #0b141a; } }
.wa-bubble { background: #fff; color: #111b21; border-radius: 0 8px 8px 8px; padding: 8px 10px 4px; max-width: 100%;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .12); white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; }
:root[data-theme="dark"] .wa-bubble, :root[data-theme="dark"] .wa-btn { background: #202c33; color: #e9edef; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa-bubble, :root:not([data-theme="light"]) .wa-btn { background: #202c33; color: #e9edef; } }
.wa-bubble .wa-h:empty, .wa-bubble .wa-f:empty { display: none; }
.wa-bubble .wa-h { margin-bottom: 4px; }
.wa-media { background: #cfd8dc; color: #37474f; border-radius: 6px; padding: 26px 8px; text-align: center; font-size: 13px; }
.wa-bubble .wa-f { color: #667781; font-size: 12px; margin-top: 4px; }
.wa-time { text-align: right; font-size: 10.5px; color: #667781; }
.wa-btns { display: grid; gap: 4px; margin-top: 4px; }
.wa-btn { background: #fff; color: #027eb5; text-align: center; border-radius: 8px; padding: 7px; font-size: 13px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.auto-slots .slot-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.auto-slots .slot-row input { margin-bottom: 12px; }
@media (max-width: 560px) { .auto-slots .slot-row { grid-template-columns: 1fr; } .auto-slots .slot-row input { margin-top: -8px; } }
.wa-auto-note { margin: 0; }

/* WhatsApp template builder: the # picker of call details */
.tb-varmenu { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto; margin: -6px 0 10px; padding: 4px; }
.tb-varmenu-head { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px 4px; }
.tb-varitem { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; background: none;
  border: 0; border-radius: 6px; padding: 7px 8px; color: var(--text); font: inherit; cursor: pointer; }
.tb-varitem small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tb-varitem:hover, .tb-varitem.on { background: var(--brand-soft); }
.tb-exrow { align-items: end; }

/* Tickets: who a caller sends a ticket to. Call history: bulk assign bar. */
fieldset.send-to { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
fieldset.send-to legend { padding: 0; color: var(--muted, inherit); }
.bulk-assign { margin-bottom: 10px; flex-wrap: wrap; }
.bulk-assign select { max-width: 100%; }

/* Profile */
img.avatar.photo { object-fit: cover; background: var(--panel-2); padding: 0; }
.avatar.xl { width: 72px; height: 72px; font-size: 28px; background: var(--brand); color: #fff; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head h1 { margin: 0; }
.profile-title { margin: 2px 0 0; font-weight: 600; color: var(--text); }
.profile-photo { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.profile-photo label { margin-top: 0; }
@media (max-width: 560px) { .profile-head .avatar.xl { width: 56px; height: 56px; font-size: 22px; } }

.danger-zone { border-color: color-mix(in srgb, var(--neg) 45%, var(--line)); }
.danger-zone h2 { color: var(--neg); }

/* Country code picker (app/static/phone.js) */
.phone-field { display: flex; gap: 6px; margin-top: 5px; align-items: stretch; }
label .phone-field select.cc, label .phone-field input { margin-top: 0; }
.phone-field select.cc { flex: 0 0 auto; width: auto; min-width: 92px; }
.phone-field input { flex: 1 1 auto; min-width: 0; }

/* Agent cards: the link plus a lead upload button (agents.html, _macros.html lead_upload) */
.ac-link { display: flex; flex-direction: column; gap: 10px; color: inherit; flex: 1 1 auto; }
.ac-link:hover { text-decoration: none; }
.ac-upload { margin: 0; border-top: 1px solid var(--line-2); padding-top: 10px; }
.ac-upload label.upload-btn { display: inline-flex; margin: 0; font-size: 12.5px; padding: 6px 12px; color: inherit; cursor: pointer; }
td .ac-upload { border-top: 0; padding-top: 0; }

/* Agents page list view (agents.html "List" toggle): one compact row per agent */
.view-toggle .chip { white-space: nowrap; }
.agent-grid.as-list { grid-template-columns: 1fr; gap: 8px; }
.agent-grid.as-list .agent-card { flex-direction: row; align-items: center; gap: 16px; padding: 10px 16px; }
.agent-grid.as-list .agent-card:hover { transform: none; }
.agent-grid.as-list .ac-link { flex-direction: row; align-items: center; gap: 16px; min-width: 0; }
.agent-grid.as-list .ac-top { flex: 0 0 280px; align-items: center; min-width: 0; }
.agent-grid.as-list .ac-icon { width: 32px; height: 32px; font-size: 14px; }
.agent-grid.as-list .ac-industry { flex: 0 0 140px; }
.agent-grid.as-list .ac-types { flex: 1 1 auto; min-width: 0; min-height: 0; flex-wrap: nowrap; overflow: hidden; }
.agent-grid.as-list .ac-stats { flex: 0 0 auto; border-top: 0; padding-top: 0; margin-top: 0; gap: 18px; }
.agent-grid.as-list .ac-stats b { font-size: 15px; }
.agent-grid.as-list .ac-foot { flex: 0 0 170px; flex-direction: column; gap: 0; }
.agent-grid.as-list .ac-upload { border-top: 0; padding-top: 0; flex: none; }
@media (max-width: 900px) {
  .agent-grid.as-list .agent-card, .agent-grid.as-list .ac-link { flex-wrap: wrap; }
  .agent-grid.as-list .ac-top { flex-basis: 100%; }
  .agent-grid.as-list .ac-types, .agent-grid.as-list .ac-foot { display: none; }
}

/* Daily report delivery status (_report_delivery.html) */
.report-delivery { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }

/* Daily report card: labelled rows, buttons lined up with the fields (_daily_picker.html, account.html) */
.report-block { padding: 14px 0; border-top: 1px solid var(--line-2); }
.report-block:first-of-type { border-top: 0; padding-top: 4px; }
.report-block h3 { margin: 0 0 10px; font-size: 14px; }
.filters.bottom { align-items: flex-end; }
.filters.bottom label { display: flex; flex-direction: column; gap: 5px; }
.filters.bottom label input, .filters.bottom label select { margin-top: 0; width: auto; min-width: 150px; }
.filters.bottom label.check { flex-direction: row; align-items: center; align-self: center; }
.report-row { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-end; }
.report-row form { margin: 0; }
.filters.bottom label.check input { min-width: 0; width: 16px; margin: 0; }
.filters.bottom label.check { gap: 8px; padding-bottom: 9px; align-self: flex-end; }
