/* iQonsey CRM: Apple-style design (SF system font, translucent chrome, inset grouped lists, light + dark) */
:root {
  --accent: #a3173f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(163, 23, 63, .10);
  --brand: #511428;
  --brand-2: var(--accent);
  --brand-soft: var(--accent-soft);
  --bg: #f5f5f7;
  --bg-2: #ececf0;
  --card: #ffffff;
  --card-2: #fafafc;
  --ink: #1d1d1f;
  --ink-2: #3a3a3c;
  --muted: #6e6e73;
  --faint: #aeaeb2;
  --line: rgba(60, 60, 67, .14);
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .08);
  --chrome: rgba(250, 250, 252, .78);
  --ok: #1f8a4c;      --ok-soft: rgba(52, 199, 89, .14);
  --warn: #a05a00;    --warn-soft: rgba(255, 149, 0, .15);
  --danger: #d70015;  --danger-soft: rgba(255, 59, 48, .12);
  --info: #0066cc;    --info-soft: rgba(0, 122, 255, .12);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 1px rgba(0, 0, 0, .02), 0 4px 18px rgba(0, 0, 0, .05);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .22);
  --s-new: #5856d6; --s-docs: #c26b00; --s-consilium: #0a84a8; --s-opinion: #c2185b; --s-report_sent: #248a3d; --s-followup: #636e7a; --s-closed: #98989d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff4f7b;
    --accent-ink: #ffffff;
    --accent-soft: rgba(255, 79, 123, .16);
    --bg: #000000;
    --bg-2: #1c1c1e;
    --card: #1c1c1e;
    --card-2: #232325;
    --ink: #f5f5f7;
    --ink-2: #d1d1d6;
    --muted: #98989d;
    --faint: #636366;
    --line: rgba(84, 84, 88, .55);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .16);
    --chrome: rgba(28, 28, 30, .72);
    --ok: #30d158;      --ok-soft: rgba(48, 209, 88, .16);
    --warn: #ffb340;    --warn-soft: rgba(255, 159, 10, .16);
    --danger: #ff6961;  --danger-soft: rgba(255, 69, 58, .16);
    --info: #64d2ff;    --info-soft: rgba(100, 210, 255, .14);
    --shadow: 0 0 0 .5px rgba(255, 255, 255, .06);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
    --s-new: #7d7aff; --s-docs: #ffb340; --s-consilium: #5ac8f5; --s-opinion: #ff6fa0; --s-report_sent: #30d158; --s-followup: #a0aab4; --s-closed: #8e8e93;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.app { overflow-x: clip; }
body {
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  letter-spacing: -.01em; background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.022em; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px 14px;
  background: var(--chrome); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-right: .5px solid var(--line); overflow-y: auto;
}
.side .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 2px 10px 16px; color: var(--ink); }
.side .logo img { width: 30px; height: 30px; border-radius: 8px; background: #fff; padding: 3px; box-shadow: 0 0 0 .5px var(--line); }
.side-sec { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 4px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--ink-2); padding: 7px 10px; border-radius: 9px; font-weight: 500; font-size: 14px; text-decoration: none; }
.nav a:hover { background: var(--fill-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .n { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.nav svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--accent); opacity: .9; }
.nav a.on svg { opacity: 1; }
.side .me { margin-top: auto; padding: 12px 8px 2px; border-top: .5px solid var(--line); font-size: 13px; }
.side .me b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .me span { color: var(--muted); }
.side .me .actions-row { display: flex; gap: 6px; margin-top: 10px; }
.side .me button.plain { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font-size: 13px; font-weight: 500; }
.main { padding: 34px 40px 72px; min-width: 0; max-width: 1360px; width: 100%; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.top .sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 16px 104px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--chrome); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
    border-top: .5px solid var(--line); padding: 6px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 500; color: var(--faint); padding: 3px 0; text-decoration: none; background: none; border: 0; cursor: pointer; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 25px; height: 25px; }
  h1 { font-size: 30px; }
  .top { margin-bottom: 18px; }
}

/* ---------- Building blocks ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card.flat { box-shadow: none; background: var(--fill-2); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; background: var(--accent); color: var(--accent-ink);
  padding: 9px 18px; border-radius: 980px; font-weight: 590; font-size: 14px; cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: transform .12s ease, filter .15s ease, background .15s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: var(--fill); color: var(--accent); }
.btn.ghost:hover { background: var(--fill); filter: brightness(.97); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 6px 13px; font-size: 13px; }
.btn.lg { padding: 12px 22px; font-size: 16px; }
.btn svg { width: 17px; height: 17px; }
.btn.ai { background: linear-gradient(135deg, #7b5cff, #d4387a); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }

label.f { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px 2px; }
.field { margin-bottom: 14px; }
input.i, select.i, textarea.i {
  width: 100%; padding: 10px 13px; border: 0; border-radius: 11px; background: var(--fill-2);
  box-shadow: inset 0 0 0 .5px var(--line); transition: box-shadow .15s ease, background .15s ease;
}
input.i:focus, select.i:focus, textarea.i:focus { outline: none; background: var(--card); box-shadow: 0 0 0 3.5px var(--accent-soft), inset 0 0 0 1px var(--accent); }
select.i { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; }
textarea.i { resize: vertical; min-height: 88px; line-height: 1.5; }
.field.ai-filled input.i, .field.ai-filled select.i, .field.ai-filled textarea.i { box-shadow: inset 0 0 0 1.5px #8e6bff; background: rgba(142, 107, 255, .08); }
.field.ai-filled label.f::after { content: " ✨"; }
/* One height for every single-line control; iOS date fields otherwise collapse and centre their text */
input.i, select.i { height: 42px; line-height: 1.25; }
input.i[type=date] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; text-align: left; }
input.i[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.i[type=date]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
/* Button choices for fields with only a few options */
.choice { display: grid; grid-template-columns: repeat(var(--c), minmax(0, 1fr)); gap: 6px; }
.choice .opt { position: relative; display: block; cursor: pointer; }
.choice .opt input { position: absolute; opacity: 0; inset: 0; margin: 0; pointer-events: none; }
.choice .opt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 42px; padding: 6px 8px; border-radius: 11px;
  background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--line); font-weight: 500; line-height: 1.2; color: var(--ink); transition: background .15s, box-shadow .15s, color .15s; user-select: none; -webkit-user-select: none; }
.choice .opt:hover span { background: var(--fill); }
.choice .opt input:checked + span { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }
.choice .opt-urgent input:checked + span, .choice .opt-emergency input:checked + span { background: rgba(255, 59, 48, .12); color: #ff3b30; box-shadow: inset 0 0 0 1.5px #ff3b30; }
.choice .opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice.num .opt span { font-variant-numeric: tabular-nums; font-weight: 600; }
.field.ai-filled .choice .opt input:checked + span { box-shadow: inset 0 0 0 1.5px #8e6bff; background: rgba(142, 107, 255, .1); color: #8e6bff; }
@media (max-width: 700px) { .choice.wrap2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .choice.wrap4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid.g2.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Settings-style switch row: text on the left, switch on the right */
.toggle.tbox { justify-content: space-between; padding: 12px 14px; margin: 8px 0 14px; border-radius: 12px; background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--line); }
.toggle.tbox > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.err { background: var(--danger-soft); color: var(--danger); padding: 10px 13px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }
.okmsg { background: var(--ok-soft); color: var(--ok); padding: 10px 13px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }
.warnmsg { background: var(--warn-soft); color: var(--warn); padding: 10px 13px; border-radius: 11px; font-size: 14px; margin-bottom: 12px; }
.infomsg { background: var(--info-soft); color: var(--info); padding: 10px 13px; border-radius: 11px; font-size: 14px; margin-bottom: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--muted); white-space: nowrap; }
.badge.urgent, .badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stage { color: var(--sc, var(--muted)); background: color-mix(in srgb, var(--sc, #999) 14%, transparent); }

/* Segmented control */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: nowrap; transition: background .15s ease; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.page-tabs { margin: -6px 0 22px; }

/* ---------- Inset grouped lists ---------- */
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group + .group, .group + .card, .card + .group { margin-top: 16px; }
.group-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 8px; }
.group-h h2 { font-size: 17px; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--ink); text-decoration: none !important; position: relative; min-height: 52px; }
.lrow + .lrow::before { content: ""; position: absolute; top: 0; right: 0; left: 20px; border-top: .5px solid var(--line); }
.lrow.has-av + .lrow.has-av::before { left: 68px; }
a.lrow:hover, button.lrow:hover, .lrow.click:hover { background: var(--fill-2); }
button.lrow { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; }
.lrow .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .chev { color: var(--faint); flex: 0 0 auto; }
.lrow .val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.group .empty { padding: 22px 20px 26px; }
.group-f { padding: 10px 20px 14px; border-top: .5px solid var(--line); }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 12px; border-bottom: .5px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: .5px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--fill-2); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 10px; }
@media (max-width: 700px) {
  .tbl.stack thead { display: none; }
  .tbl.stack tr { display: block; padding: 12px 12px; border-bottom: .5px solid var(--line); }
  .tbl.stack td { display: block; border: 0; padding: 2px 0; }
  .tbl.stack td.r { text-align: left; }
}

/* ---------- KPI tiles + charts ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 15px 16px; text-decoration: none !important; color: var(--ink); position: relative; }
.tile::before { content: ""; position: absolute; left: 16px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--sc, var(--accent)); }
.tile b { display: block; font-size: 28px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 16px; letter-spacing: -.03em; }
.tile span { color: var(--muted); font-size: 13px; }
a.tile:hover { box-shadow: var(--shadow), 0 0 0 1.5px var(--sc, var(--accent)); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; color: var(--ink); text-decoration: none !important; display: block; min-width: 0; }
.kpi .l { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .l .ic { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--kc, var(--accent)); color: #fff; font-size: 12px; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 8px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .v small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .d { font-size: 12.5px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.kpi:hover { box-shadow: var(--shadow), 0 0 0 1.5px var(--kc, var(--accent)); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; min-width: 0; }
.bars .b i { display: block; width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: var(--bc, var(--accent)); min-height: 2px; }
.bars .b i.alt { background: var(--danger); opacity: .8; }
.bars .b span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars .b em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--fill); gap: 2px; }
.stack-bar i { display: block; background: var(--sc); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 13px; }
.legend a, .legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.legend b { font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: var(--fill); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--mc, var(--ok)); border-radius: 99px; }
.status { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; box-shadow: 0 0 0 3px var(--ok-soft); }
.status.warn { background: #ff9f0a; box-shadow: 0 0 0 3px var(--warn-soft); }
.status.bad { background: #ff3b30; box-shadow: 0 0 0 3px var(--danger-soft); }
.list-item { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: .5px solid var(--line); color: var(--ink); text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-weight: 600; }
.log { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 11.5px; background: var(--fill-2); border-radius: 12px; padding: 12px 14px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; line-height: 1.55; }

/* ---------- Board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.col { background: var(--fill-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 650; font-size: 13px; }
.col-head .n { background: var(--card); border-radius: 99px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.kcard { display: block; background: var(--card); border-radius: 13px; padding: 12px 13px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); color: var(--ink); text-decoration: none !important; cursor: pointer; position: relative; }
.kcard::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sc); }
.kcard[draggable="true"] { cursor: grab; }
.kcard.dragging { opacity: .4; }
.kcard .code { font-size: 12px; color: var(--muted); font-family: "SF Mono", ui-monospace, Menlo, monospace; }
.kcard .t { font-weight: 600; margin: 2px 0 4px; line-height: 1.35; }
.kcard .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }

/* ---------- Case + patient pages ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 4px 12px; font-size: 13px; font-weight: 600; }
.checklist { max-height: 300px; overflow: auto; border-radius: 13px; background: var(--fill-2); }
.checklist label { display: flex; gap: 10px; align-items: center; padding: 10px 13px; border-bottom: .5px solid var(--line); cursor: pointer; }
.checklist label:last-child { border-bottom: 0; }
.checklist input, .check input, input[type=checkbox] { accent-color: var(--accent); }

.drop-zone { display: block; border: 1.5px dashed var(--faint); border-radius: 14px; padding: 20px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.drop-zone.over, .drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: .5px solid var(--line); }
.doc:last-child { border-bottom: 0; }
.doc .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10.5px; font-weight: 700; flex: 0 0 auto; text-transform: uppercase; }
.doc .n { font-weight: 600; overflow-wrap: anywhere; }

.timeline { position: relative; }
.ev { display: flex; gap: 12px; padding: 10px 0; }
.ev .av { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: 0 0 auto; }
.ev .av.sys { background: var(--fill); color: var(--muted); }
.ev .b { flex: 1; min-width: 0; }
.ev .who { font-size: 13px; color: var(--muted); }
.ev .who b { color: var(--ink); }
.ev .note { background: var(--fill-2); border-radius: 4px 14px 14px 14px; padding: 10px 13px; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }

.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; color: var(--ink); text-decoration: none !important; display: flex; flex-direction: column; gap: 10px; }
.pcard:hover { box-shadow: var(--shadow), 0 0 0 1.5px var(--accent); }
.pcard .head { display: flex; align-items: center; gap: 11px; min-width: 0; }
.pcard .nm { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.hero-act { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); border: 0; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.hero-act .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--accent); flex: 0 0 auto; }
.hero-act .ic svg { width: 22px; height: 22px; }
.hero-act.ai .ic { background: linear-gradient(135deg, #7b5cff, #d4387a); }
.hero-act b { display: block; }
.hero-act span { font-size: 13px; color: var(--muted); }
.hero-act:hover { box-shadow: var(--shadow), 0 0 0 1.5px var(--accent); }
@media (max-width: 600px) { .hero-actions { grid-template-columns: 1fr; } }

/* ---------- Modal (sheet) + toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .32); z-index: 100; display: grid; place-items: center; padding: 16px; overflow-y: auto; animation: fade .18s ease; }
.modal { background: var(--card); border-radius: 22px; width: 100%; max-width: 560px; padding: 24px 24px 22px; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2, .9, .3, 1.15); }
.modal h2 { margin-bottom: 16px; font-size: 21px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal.wide { max-width: 780px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@media (max-width: 600px) {
  .modal-bg { place-items: end stretch; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-width: none; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 94vh; overflow-y: auto; overscroll-behavior: contain; animation: up .28s cubic-bezier(.2, .9, .3, 1); }
  .modal::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--fill); margin: -10px auto 14px; }
  @keyframes up { from { transform: translateY(100%); } }
}
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: rgba(30, 30, 32, .92); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); color: #fff; padding: 11px 18px; border-radius: 14px; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px); animation: pop .22s ease; }
@media (max-width: 860px) { .toast { bottom: 96px; } }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(900px 520px at 15% -10%, rgba(163, 23, 63, .22), transparent 60%), radial-gradient(800px 500px at 110% 110%, rgba(123, 92, 255, .14), transparent 60%), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 30px; border-radius: 24px; box-shadow: var(--shadow-lg); }
.auth .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--ink); font-weight: 700; font-size: 20px; }
.auth .brand img { width: 36px; height: 36px; border-radius: 9px; background: #fff; padding: 3px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 14px; margin: 12px 0; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 24px !important; font-variant-numeric: tabular-nums; }
.spin { width: 26px; height: 26px; border: 2.5px solid var(--fill); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; margin: 60px auto; }
.spin.sm { width: 18px; height: 18px; margin: 0; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Misc components ---------- */
.sub-h { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 20px 0 10px 2px; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 650; object-fit: cover; flex: 0 0 auto; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: .5px solid var(--line); }
.person:last-child { border-bottom: 0; }
.badge.urg-routine { background: var(--ok-soft); color: var(--ok); }
.badge.urg-soon { background: var(--warn-soft); color: var(--warn); }
.badge.urg-urgent, .badge.urg-emergency { background: var(--danger-soft); color: var(--danger); }
.card.hl { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.hint-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 10px 13px; font-size: 14px; margin-bottom: 14px; }
details.opinion { background: var(--fill-2); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
details.opinion summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
details.more { border-radius: 14px; background: var(--fill-2); padding: 12px 14px; margin-bottom: 14px; }
details.more summary { cursor: pointer; font-weight: 600; }
.op-sec { margin-top: 12px; }
.op-sec .f { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--line); border-radius: 99px; padding: 6px 13px; cursor: pointer; font-size: 14px; user-select: none; }
.check:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); font-weight: 600; }
.check input { margin: 0; }
.list-item.pick { width: 100%; background: none; border: 0; border-bottom: .5px solid var(--line); text-align: left; cursor: pointer; font: inherit; }
.photo-row { margin-bottom: 16px; gap: 14px; }
.lang { display: inline-flex; align-items: center; gap: 6px; border-radius: 9px; padding: 4px 9px; color: var(--muted); }
.lang select { border: 0; background: transparent; font: inherit; font-size: 13px; cursor: pointer; padding: 2px 0; color: inherit; }
.lang.light { background: var(--fill-2); }
.lang.dark { background: var(--fill-2); margin: 10px 0 2px; width: 100%; }
.lang.dark select { width: 100%; color: var(--ink); }
.toggle { display: flex; align-items: center; gap: 12px; padding: 4px 0; cursor: pointer; }
.toggle input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--fill); position: relative; cursor: pointer; flex: 0 0 auto; transition: background .2s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .2s; }
.toggle input:checked { background: #34c759; }
.toggle input:checked::after { transform: translateX(18px); }
.items-tbl { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.items-tbl td { padding: 0 4px 0 0; vertical-align: top; }
.items-tbl input.i { padding: 8px 10px; }
.totals { margin-left: auto; max-width: 300px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .big { font-size: 18px; font-weight: 700; border-top: .5px solid var(--line); padding-top: 8px; margin-top: 4px; }
.ai-sum { background: rgba(142, 107, 255, .09); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.ai-sum b { color: #7b5cff; }
.diff td { vertical-align: top; padding: 9px 8px; border-bottom: .5px solid var(--line); font-size: 14px; }
.diff .old { color: var(--muted); text-decoration: line-through; white-space: pre-wrap; }
.diff .new { white-space: pre-wrap; }
.sheet-list a, .sheet-list button { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: .5px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 500; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font: inherit; cursor: pointer; }
.sheet-list svg { width: 22px; height: 22px; color: var(--accent); }

/* ---------- Patient portal ---------- */
body.portal { background: radial-gradient(900px 420px at 50% -120px, rgba(163, 23, 63, .16), transparent 70%), var(--bg); }
.p-wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px 40px; }
.p-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 18px; color: var(--ink); font-size: 18px; }
.p-head img { width: 34px; height: 34px; border-radius: 9px; background: #fff; padding: 3px; }
.p-head .link { font-size: 14px; }
.p-hello { margin: 6px 4px 16px; }
.p-card h1 { font-size: 24px; margin-bottom: 8px; }
.p-case h2 { font-size: 18px; margin-top: 2px; }
.p-status { margin: 14px 0 6px; font-weight: 700; color: var(--accent); }
.p-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }
.consent-text { white-space: pre-wrap; background: var(--fill-2); border-radius: 14px; padding: 14px; max-height: 46vh; overflow: auto; font-size: 14px; line-height: 1.6; }
a.doc { color: var(--ink); text-decoration: none !important; }
.stepper { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stepper li { text-align: center; font-size: 11px; color: var(--muted); }
.stepper li span { display: block; height: 6px; border-radius: 3px; background: var(--fill); margin-bottom: 6px; }
.stepper li.done span { background: var(--accent); }
.stepper li.cur span { background: linear-gradient(90deg, var(--accent) 50%, var(--fill) 50%); }
.stepper li.cur { color: var(--accent); font-weight: 700; }
.stepper em { font-style: normal; display: block; line-height: 1.25; }
.p-report { width: 100%; margin-top: 10px; flex-direction: column; gap: 2px; white-space: normal; text-align: center; padding: 12px 16px; border-radius: 14px; }
.p-report small { font-weight: 500; opacity: .85; font-size: 12px; }
.p-head .lang select { max-width: 110px; }

/* Install app */
.install-btn { width: 100%; margin: 8px 0 2px; border: 0; background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.install-hint { font-size: 12px; color: var(--muted); margin: 8px 0 2px; line-height: 1.4; }
.card .install-btn { background: var(--accent); color: var(--accent-ink); width: auto; padding: 9px 18px; border-radius: 980px; }
@media (max-width: 860px) { .tabbar button.on { color: var(--accent); } }
.grid > .group, .grid > .card, .grid > div > .group:first-child, .grid > div > .card:first-child, .split > div > .group:first-child, .split > div > .card:first-child { margin-top: 0; }

/* Doctor rows: patient name first, case title second */
.drow .t { font-size: 16px; display: flex; align-items: center; gap: 7px; }
.drow .s { font-size: 14px; }
.drow-r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; }
.drow .due { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.drow .due.late { color: var(--danger); font-weight: 600; }
.dot-urgent { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; flex: 0 0 auto; box-shadow: 0 0 0 3px var(--danger-soft); }
.demo-tag { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--fill); border-radius: 6px; padding: 1px 6px; }
.count { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }

/* Phones: larger text and touch targets, compact dashboard blocks */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .top .sub { font-size: 15px; }
  .group-h { padding: 16px 16px 6px; }
  .group-h h2 { font-size: 19px; }
  .lrow { padding: 13px 16px; min-height: 64px; }
  .lrow + .lrow::before { left: 16px; }
  .lrow.has-av + .lrow.has-av::before { left: 72px; }
  .lrow .s { font-size: 14px; }
  .drow .t { font-size: 17px; }
  .drow .s { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
  .hero-actions.doc { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .hero-actions.doc .hero-act { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .hero-actions.doc .hero-act b { font-size: 16px; }
  .hero-actions.doc .hero-act span { display: none; }
  .kpis.mini { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .kpis.mini .kpi { padding: 11px 10px; border-radius: 14px; }
  .kpis.mini .kpi .l { font-size: 11.5px; line-height: 1.25; align-items: flex-start; flex-direction: column; gap: 6px; }
  .kpis.mini .kpi .v { font-size: 24px; margin-top: 4px; }
  .tabbar a, .tabbar button { font-size: 11px; padding: 4px 0 2px; }
  .tabbar svg { width: 27px; height: 27px; }
  .btn { padding: 11px 18px; font-size: 15px; }
  .btn.sm { padding: 8px 14px; font-size: 14px; }
  input.i, select.i, textarea.i { font-size: 16px; padding: 12px 14px; }
  input.i, select.i { height: 48px; }
  .choice .opt span { min-height: 48px; font-size: 16px; }
  .seg button { padding: 8px 14px; font-size: 14px; }
}
.drow .t .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.drow .t .demo-tag, .dot-urgent { flex: 0 0 auto; }
.drow .stg { color: var(--sc); font-weight: 600; }
.pcard .nm .demo-tag { margin-left: 4px; }
@media (max-width: 860px) { .pcards .pcard:nth-child(n+5) { display: none; } }
.toggle.tbox.remember { margin: 2px 0 16px; }

/* ICD-10 diagnoses */
.icd-tag { display: inline-block; font: 600 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 0 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; vertical-align: 1px; }
.kcard .meta .icd-tag { font-size: 11px; }
.dx-list .dx { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; }
.dx-list .dx + .dx { border-top: .5px solid var(--line); }
.dx-list .icd-tag { min-width: 52px; text-align: center; }
.icd-chips { display: flex; flex-direction: column; gap: 6px; }
.icd-chips:not(:empty) { margin-bottom: 8px; }
.icd-chip { display: flex; align-items: stretch; border-radius: 11px; background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--line); overflow: hidden; }
.icd-chip.primary { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.icd-main { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; text-align: left; border: 0; background: none; padding: 9px 4px 9px 12px; cursor: pointer; color: var(--ink); font: inherit; }
.icd-main b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--accent); flex: 0 0 auto; min-width: 46px; }
.icd-main .nm { flex: 1; min-width: 0; line-height: 1.3; }
.icd-main .pr { flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }
.icd-x { border: 0; background: none; width: 40px; flex: 0 0 auto; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.icd-x:hover { color: var(--danger); }
.icd-box { position: relative; }
.icd-res { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--card); border-radius: 12px; box-shadow: var(--shadow-lg), 0 0 0 .5px var(--line); max-height: 300px; overflow-y: auto; padding: 4px; }
.icd-opt { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit; line-height: 1.3; }
.icd-opt b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--accent); min-width: 46px; flex: 0 0 auto; }
.icd-opt.on, .icd-opt:hover { background: var(--fill); }
.icd-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.field.ai-filled .icd-chip { box-shadow: inset 0 0 0 1.5px #8e6bff; }
@media (max-width: 860px) { .icd-res { max-height: 240px; } .icd-opt { padding: 11px 10px; } .icd-main { padding: 11px 4px 11px 12px; } }

/* Voice dictation */
.btn.voice { background: #ff3b30; color: #fff; }
.btn.voice.ghost, .btn.ghost.voice { background: var(--fill); color: var(--ink); }
.hero-act.voice .ic { background: #ff3b30; }
.hero-actions.doc.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fill-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.voice-panel { margin-bottom: 14px; }
.voice-rec { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: rgba(255, 59, 48, .08); box-shadow: inset 0 0 0 1px rgba(255, 59, 48, .35); }
.voice-dot { width: 14px; height: 14px; border-radius: 50%; background: #ff3b30; flex: 0 0 auto; animation: vpulse 1.2s ease-in-out infinite; }
@keyframes vpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .55); } 50% { box-shadow: 0 0 0 9px rgba(255, 59, 48, 0); } }
.voice-time { font: 600 17px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #ff3b30; }
.voice-tx { margin-top: 10px; font-size: 14px; }
.voice-tx summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.voice-tx p { margin: 8px 0 0; white-space: pre-wrap; color: var(--ink-2); }
.voice-panel .row .grow { flex: 1; }
@media (max-width: 860px) {
  .hero-actions.doc.three { grid-template-columns: 1fr 1fr; }
  .hero-actions.doc.three .hero-act.voice { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .hero-actions.doc.three .hero-act.voice span { display: block; }
  .fill-btns .btn { flex: 1; justify-content: center; }
}
.hero-actions.doc.three { align-items: stretch; }
@media (max-width: 860px) { .hero-actions.doc .hero-act span.ic { display: grid; width: 34px; height: 34px; border-radius: 10px; } .hero-actions.doc .hero-act span.ic svg { width: 19px; height: 19px; } }

/* Password show/hide eye */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > input { width: 100%; padding-right: 48px !important; }
.pw-eye { position: absolute; top: 0; right: 0; bottom: 0; width: 46px; display: flex; align-items: center; justify-content: center; padding: 0; margin: 0; border: 0; background: none; box-shadow: none; color: var(--muted); cursor: pointer; border-radius: 0 12px 12px 0; -webkit-tap-highlight-color: transparent; }
.pw-eye:hover { color: var(--ink); }
.pw-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -6px; border-radius: 10px; }
.pw-eye svg { width: 20px; height: 20px; display: block; }
input::-ms-reveal, input::-ms-clear { display: none; }

/* ===== WhatsApp inbox ===== */
.wa-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.wa-list-col .page-tabs { margin-bottom: 10px; }
.wa-list { max-height: calc(100vh - 250px); overflow-y: auto; }
.wa-row.on { background: var(--accent-soft); }
.wa-prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-unread { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #25d366; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav a .wa-n:empty { display: none; }
.nav a .wa-n { background: #25d366; color: #fff; border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; }
.wa-thread-col { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; align-items: start; min-width: 0; }
.wa-thread-col > .card.empty { grid-column: 1 / -1; }
.wa-thread { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; overflow: hidden; }
.wa-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: .5px solid var(--line); flex-wrap: wrap; }
.wa-head .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-back { display: inline-flex; color: var(--accent); }
.wa-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: var(--fill-2); }
.wa-msg { max-width: min(78%, 560px); padding: 7px 11px 5px; border-radius: 14px; background: var(--card); box-shadow: 0 1px 1px rgba(0, 0, 0, .06); align-self: flex-start; overflow-wrap: anywhere; }
.wa-msg.out { align-self: flex-end; }
.wa-msg.out.agent { background: #dcf8c6; color: #111; }
.wa-msg.out.staff { background: #d6ebff; color: #111; }
.wa-who { font-size: 11px; font-weight: 700; color: #128c7e; margin-bottom: 2px; }
.wa-msg.staff .wa-who { color: #0066cc; }
.wa-text { font-size: 14.5px; line-height: 1.4; }
.wa-meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.wa-msg.out .wa-meta { color: #667; }
.wa-tick.read { color: #34b7f1; }
.wa-tick.bad, .wa-err { color: var(--danger); }
.wa-err { font-size: 12px; }
.wa-img { display: block; max-width: 260px; max-height: 260px; border-radius: 10px; margin-bottom: 4px; }
.wa-file { display: block; padding: 8px 10px; border-radius: 10px; background: var(--fill); margin-bottom: 4px; color: var(--ink); }
.wa-msg audio { max-width: 260px; }
.wa-sys { align-self: center; font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 4px 10px; border-radius: 10px; max-width: 90%; text-align: center; }
.wa-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--card); padding: 2px 10px; border-radius: 8px; margin: 6px 0; }
.wa-typing { align-self: flex-start; background: var(--card); border-radius: 14px; padding: 10px 14px; display: flex; gap: 4px; }
.wa-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: wa-dot 1.2s infinite ease-in-out; }
.wa-typing span:nth-child(2) { animation-delay: .15s; }
.wa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes wa-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.wa-composer { padding: 10px 12px 12px; border-top: .5px solid var(--line); }
.wa-composer textarea { resize: none; min-height: 40px; max-height: 160px; }
.wa-composer .warnmsg { margin-bottom: 8px; }
.wa-attach { cursor: pointer; }
.wa-thread-col > .wa-side { margin-top: 0; }
.wa-head .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-side h3 { font-size: 15px; margin: 4px 0 8px; }
.wa-side .okmsg, .wa-side .infomsg, .wa-side .warnmsg { text-decoration: none; }
.wa-f { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: .5px solid var(--line); font-size: 13px; }
.wa-f .k { color: var(--muted); flex: 0 0 auto; max-width: 48%; }
.wa-f .v { text-align: right; overflow-wrap: anywhere; }
.wa-f .req { color: var(--danger); font-weight: 600; }
.wa-copy { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.wa-copy .mono { overflow-wrap: anywhere; font-size: 13px; }
.wa-q-row { flex-wrap: wrap; }
.ok-t { color: var(--ok); }
.bad-t { color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .wa-msg.out.agent { background: #005c4b; color: #e9edef; }
  .wa-msg.out.staff { background: #0b3b66; color: #e9edef; }
  .wa-msg.out .wa-meta { color: #a8b3ba; }
  .wa-who { color: #53bdeb; }
  .wa-msg.staff .wa-who { color: #8cc8ff; }
}
@media (max-width: 1250px) { .wa-thread-col { grid-template-columns: minmax(0, 1fr); } .wa-side { order: 2; } }
@media (max-width: 860px) {
  .wa-layout { grid-template-columns: minmax(0, 1fr); }
  .wa-layout.has-thread .wa-list-col { display: none; }
  .wa-layout:not(.has-thread) .wa-thread-col { display: none; }
  .wa-list { max-height: none; }
  .wa-thread { height: calc(100dvh - 200px); }
  .wa-msg { max-width: 88%; }
  .wa-head .wa-chip { display: none; }
  .wa-q-row > div[style] { min-width: 0 !important; width: 100%; }
}
