/* ABOS Operator styles (from Total Recall Starter).
   Make it yours: change the accent in Settings (saved per login). Everything else reads from these variables. */
:root {
  /* ABOS brand v2.3 (abos-business/docs/brand/BRAND.md §7). */
  --accent: #14305A;      /* Navy */
  --accent-ink: #FFFFFF;
  --link: #0A74AB;        /* Cyan Deep: cyan text on light */
  --bg: #F4F7FB;          /* Mist */
  --panel: #FFFFFF;
  --sidebar: #F4F7FB;
  --ink: #1B2A3F;         /* Text */
  --muted: #5B6B82;       /* Slate */
  --line: #E3E9F1;        /* Line */
  --soft: #E6F5FC;        /* Cyan Tint */
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #0FA4E7;      /* Cyan */
  --accent-ink: #12213D;
  --link: #0FA4E7;
  --bg: #12213D;          /* Ink */
  --panel: #182A4A;
  --sidebar: #0F1C34;
  --ink: #FFFFFF;
  --muted: #A9B8CC;       /* Ink Muted */
  --line: #263A5E;
  --soft: #1D3157;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--link); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.content { flex: 1; overflow-y: auto; padding: 28px clamp(16px, 4vw, 40px); }
.content.chat-content { padding: 0; display: flex; flex-direction: column; }
.page-title { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; margin: 0 0 6px; }
.page-sub { color: var(--muted); margin: 0 0 24px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: 0.02em; }
.logo-img { display: inline-block; flex: none; }
.logo-img img { width: 100%; height: 100%; display: block; }
.logo-img .logo-dark { display: none; }
:root[data-theme="dark"] .logo-img .logo-light { display: none; }
:root[data-theme="dark"] .logo-img .logo-dark { display: block; }
.login .logo-img { margin-bottom: 14px; }
.brand-name { font-weight: 750; font-size: 15px; line-height: 1.2; }
.brand-agent { font-size: 12px; color: var(--muted); }

.new-chat { margin: 6px 8px 10px; display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; }
.new-chat:hover { border-color: var(--accent); }

.nav { padding: 2px 8px; }
.nav a, .nav button.navlink { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 500; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }
.nav a:hover, .nav button.navlink:hover { background: var(--soft); }
.nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--ink); }
.nav .ext { margin-left: auto; color: var(--muted); font-size: 12px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 14px 18px 6px; display: flex; justify-content: space-between; align-items: center; }
.section-label button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 80px; }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 9px; }
.chat-item a { flex: 1; min-width: 0; padding: 7px 34px 7px 10px; color: var(--ink); text-decoration: none; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.chat-item .slot { width: 14px; height: 14px; flex: none; display: grid; place-items: center; }
.chat-item .slot .icon { width: 14px; height: 14px; }
.chat-item a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item:hover, .chat-item.active { background: var(--soft); }
.chat-item .star { color: var(--accent); fill: var(--accent); }
.dots { position: absolute; right: 4px; width: 28px; height: 28px; border-radius: 7px; border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; display: grid; place-items: center; }
.chat-item:hover .dots, .chat-item.active .dots, .dots:focus-visible, .dots[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .dots { opacity: 0.8; } }
.dots:hover { background: var(--line); color: var(--ink); }

.menu { position: fixed; z-index: 60; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.18); padding: 5px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--soft); }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px; }

.sidebar-foot { border-top: 1px solid var(--line); padding: 8px 0; }
.sidebar-foot .account { margin: 0 8px; width: calc(100% - 16px); }
.account { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.account:hover { background: var(--soft); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; align-items: stretch; }
.dash-section { margin-top: 28px; }
.dash-section h2 { font-size: 15px; margin: 0; }
.dash-section > .row { margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; min-height: 138px; text-decoration: none; color: inherit; }
a.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card-title { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.card-value { font-size: 30px; font-weight: 760; letter-spacing: -0.02em; }
.card-detail { color: var(--muted); font-size: 13px; }
.card-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.live, .pill.connected { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.pending, .pill.needs_source, .pill.not_connected { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill.error, .pill.offline, .pill.needs_attention, .pill.needs_reconnect { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12.5px; color: var(--muted); }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
label.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
input.input, textarea.input, select.input { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 400; }
textarea.input { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
input.input:focus, textarea.input:focus, select.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }

/* ---------- chat ---------- */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px clamp(16px, 4vw, 32px); border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .dots { opacity: 0.9; }
.chat-head .title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.thread { flex: 1; overflow-y: auto; padding: 24px clamp(14px, 4vw, 32px) 12px; }
.thread-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 100%; }
.msg.user .bubble { background: var(--soft); border: 1px solid var(--line); padding: 10px 14px; border-radius: 16px 16px 4px 16px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .bubble { flex: 1; min-width: 0; }
.agent-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.md p { margin: 0 0 10px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 14px 0 6px; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md a { word-break: break-word; }
.working { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { color: var(--bad); font-size: 13px; margin-top: 6px; }
.approval { border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line)); background: color-mix(in srgb, var(--warn) 8%, var(--panel)); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.approval .row .btn { min-height: 40px; }
.approval .label { font-size: 12px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: 0.06em; }
.approval pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; margin: 6px 0 10px; max-height: 220px; overflow: auto; }

.composer-wrap { padding: 10px clamp(12px, 4vw, 32px) 14px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 14px; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; min-height: 24px; max-height: 220px; padding: 6px 0; line-height: 1.45; }
.send { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: grid; place-items: center; flex: none; }
.send:disabled { opacity: 0.4; cursor: not-allowed; }
.powered { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 10px; letter-spacing: 0.02em; padding-bottom: env(safe-area-inset-bottom); }
.powered b { font-weight: 650; color: var(--ink); }
.offline-banner { max-width: 780px; margin: 0 auto 8px; font-size: 13px; color: var(--warn); text-align: center; }
.welcome { text-align: center; margin: 12vh auto 0; max-width: 520px; }
.welcome h2 { font-size: 26px; letter-spacing: -0.02em; margin: 14px 0 6px; }
.welcome p { color: var(--muted); }

/* ---------- texts ---------- */
.texts { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: calc(100dvh - 160px); }
.texts .panel { margin: 0; overflow-y: auto; }
.sms { max-width: 75%; padding: 8px 12px; border-radius: 14px; margin: 6px 0; white-space: pre-wrap; word-wrap: break-word; }
.sms.inbound { background: var(--soft); border: 1px solid var(--line); }
.sms.outbound { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); margin-left: auto; }
.sms .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login .logo { width: 44px; height: 44px; font-size: 15px; margin-bottom: 14px; }
.login h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.login p { color: var(--muted); margin: 0 0 20px; }

.modal-back { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 420px; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 16px; }
.modal .row { justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 90; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); }
.skeleton { background: linear-gradient(90deg, var(--soft), var(--line), var(--soft)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 50; transform: translateX(-102%); transition: transform 0.2s ease; box-shadow: 0 0 40px rgb(0 0 0 / 0.3); }
  .shell.open .sidebar { transform: none; }
  .shell.open::after { content: ""; position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); z-index: 40; }
  .topbar { display: flex; }
  .texts { grid-template-columns: 1fr; height: auto; }
  .content { padding: 18px 14px; }
  .dots { width: 36px; height: 36px; }
  .approval .row .btn { flex: 1 1 100%; }
}
