/* Themes: data-theme on <html> = dark (default) | qsc | light | auto (follow the device) */
:root {
  /* iPhone notch / Dynamic Island / home indicator */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --topbar-h: calc(56px + var(--sat));
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --border: #e4e7ec;
  --text: #1d2433;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --primary: #4f46e5;
  --on-primary: #ffffff;
  --topbar: var(--panel);
  --danger: #d92d20;
  --ok: #079455;
  --warn: #dc6803;
  --pill-l: 90%;
  --pill-text-l: 28%;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --c-open: var(--accent);
  --c-closed: var(--ok);
  --c1: var(--accent); --c2: var(--ok); --c3: var(--danger); --c4: var(--warn);
  --card-sheen: none;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a0d13;
  --panel: #121722;
  --panel-2: #1a2130;
  --border: #242c3c;
  --text: #e9ecf3;
  --muted: #8f99ad;
  --accent: #8f89ff;
  --accent-soft: rgba(143, 137, 255, .14);
  --primary: #6c63ff;
  --on-primary: #ffffff;
  --topbar: #0e121b;
  --danger: #fb7185;
  --ok: #34d399;
  --warn: #fbbf24;
  --pill-l: 22%;
  --pill-text-l: 82%;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
  --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 60%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0a0d13;
    --panel: #121722;
    --panel-2: #1a2130;
    --border: #242c3c;
    --text: #e9ecf3;
    --muted: #8f99ad;
    --accent: #8f89ff;
    --accent-soft: rgba(143, 137, 255, .14);
    --primary: #6c63ff;
    --on-primary: #ffffff;
    --topbar: #0e121b;
    --danger: #fb7185;
    --ok: #34d399;
    --warn: #fbbf24;
    --pill-l: 22%;
    --pill-text-l: 82%;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
    --card-sheen: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, 0) 60%);
    color-scheme: dark;
  }
}
/* Company colors: black, red (#DA291C) and yellow (#FFC72C) */
:root[data-theme="qsc"] {
  --bg: #0d0d0c;
  --panel: #1a1917;
  --panel-2: #22211e;
  --border: #34322d;
  --text: #f7f5f0;
  --muted: #b3ada1;
  --accent: #ffc72c;
  --accent-soft: #3a2f10;
  --primary: #da291c;
  --on-primary: #ffffff;
  --topbar: #000000;
  --danger: #ff5a4e;
  --ok: #3ccf7a;
  --warn: #ffc72c;
  --pill-l: 24%;
  --pill-text-l: 84%;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
:root[data-theme="fresh"] {
  --bg: #f2f5f8;
  --panel: #ffffff;
  --panel-2: #f5f8fb;
  --border: #e2e8ef;
  --text: #1c2a4a;
  --muted: #7a849a;
  --accent: #3fa62a;
  --accent-soft: #e8f7e2;
  --primary: #4cb832;
  --on-primary: #ffffff;
  --topbar: #ffffff;
  --danger: #ef3e6d;
  --ok: #3fa62a;
  --warn: #f2a900;
  --pill-l: 92%;
  --pill-text-l: 30%;
  --c-open: #1c2a4a;
  --c-closed: #4cb832;
  --c1: #1c2a4a; --c2: #4cb832; --c3: #ef3e6d; --c4: #8a94a8;
  --shadow: 0 1px 2px rgba(28, 42, 74, .05), 0 6px 18px rgba(28, 42, 74, .06);
  --shadow-lg: 0 14px 36px rgba(28, 42, 74, .16);
  color-scheme: light;
}
:root[data-theme="qsc"] .topbar { border-bottom: 3px solid #da291c; }
:root[data-theme="qsc"] .logo { background: #ffc72c; }
:root[data-theme="qsc"] .logo::after { background: #da291c; }
:root[data-theme="qsc"] .brand { color: #ffc72c; }
:root[data-theme="qsc"] .nav-item.active { color: #ffc72c; box-shadow: inset 3px 0 #da291c; }
:root[data-theme="qsc"] .bar > span { background: linear-gradient(90deg, #da291c, #ffc72c); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 17px; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.live { background: var(--ok); border-color: var(--ok); color: #fff; animation: pulse 1.6s infinite; }
.btn.ghost { background: transparent; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: transparent; color: inherit; font-size: 16px; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.small { width: 24px; height: 24px; font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 550; margin-bottom: 4px; }
.field summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }

/* ---------- boot / login ---------- */
.boot { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; color: var(--muted); padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); text-align: center; }
.waiting { max-width: 460px; }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 18px 0 14px; }
.role-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.role-toggle input { position: absolute; opacity: 0; }
.role-toggle span { display: block; text-align: center; padding: 7px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--muted); }
.role-toggle input:checked + span { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.role-toggle input:focus-visible + span { outline: 2px solid var(--accent); }

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-lg { font-size: 18px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 8px 6px 6px; border-radius: 3px; background: #fff; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 216px 1fr; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: var(--sat) calc(16px + var(--sar)) 0 calc(16px + var(--sal)); background: var(--topbar); border-bottom: 1px solid var(--border); }
.search { flex: 1; max-width: 520px; margin-left: 12px; }
.search input { background: var(--panel-2); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.theme-select { width: auto; height: 30px; padding: 2px 6px; font-size: 12px; background: var(--panel-2); }
.login-theme { position: fixed; top: calc(12px + var(--sat)); right: calc(12px + var(--sar)); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-name em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 99px; margin-left: 4px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: 11px; font-weight: 700; color: #fff; background: hsl(var(--h, 240) 55% 48%); }

.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; justify-content: space-between; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; margin: 14px 8px 6px; }
.nav-label:first-child { margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-ic { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.nav-dot { width: 10px; height: 10px; margin: 0 4px; border-radius: 50%; background: hsl(var(--h) 65% 55%); opacity: 1; }
.nav-item.active .nav-ic { opacity: 1; }
.count.hot { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-weight: 700; display: inline-grid; place-items: center; }
.nav-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; box-shadow: inset 3px 0 var(--primary); }
.count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.nocodb-link { display: block; margin-top: 16px; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; text-decoration: none; font-weight: 550; }
.nocodb-link small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

.main { overflow: auto; padding: 20px calc(20px + var(--sar)) calc(20px + var(--sab)) 20px; min-width: 0; }
.list-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty.small { padding: 24px 8px; }
.empty-icon { font-size: 36px; }

/* ---------- grid ---------- */
.grid-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); margin-bottom: 12px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; white-space: nowrap; user-select: none; z-index: 1; }
.grid td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--panel-2); }
.grid tr.is-overdue td:first-child { box-shadow: inset 3px 0 var(--danger); }
.col-id { width: 56px; font-variant-numeric: tabular-nums; }
.col-subject { min-width: 200px; }
.col-subject .subject, .col-subject .sub-meta { max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.grid .pill.status { max-width: 150px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.grid .store-chip { max-width: 125px; }
.store-chip { overflow: hidden; text-overflow: ellipsis; }
.store-chip b { flex: none; }
.grid .device { max-width: 125px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.subject { overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.in-call { color: var(--ok); font-size: 11px; font-weight: 700; margin-right: 6px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 550; white-space: nowrap; background: hsl(var(--h) 70% var(--pill-l)); color: hsl(var(--h) 60% var(--pill-text-l)); }
.pill.soft { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.pill.status.closed { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.due.soon { color: var(--warn); font-weight: 600; }
.due.overdue { color: var(--danger); font-weight: 650; }

/* ---------- ticket ---------- */
.ticket { max-width: 1400px; margin: 0 auto; }
.ticket-head { margin-bottom: 16px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; color: var(--muted); }
.ticket-title { display: flex; gap: 10px; align-items: baseline; }
.ticket-title h1 { overflow-wrap: anywhere; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.ticket-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-label { font-weight: 650; margin-bottom: 8px; }
.card-head .card-label { margin: 0; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.kv { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kv.wide { grid-column: 1 / -1; }
.kv .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv .v { overflow-wrap: anywhere; white-space: pre-wrap; }
.actions { margin-top: 14px; display: flex; gap: 8px; }
.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.att { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); background: none; border: 0; padding: 0; font: inherit; text-align: left; cursor: pointer; min-width: 0; }
.att-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--panel-2); }
.att-thumb img, .att-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.att-thumb .att-icon { width: 100%; height: 100%; display: grid; place-items: center; font-size: 26px; }
.att:hover .att-thumb, .att:focus-visible .att-thumb { border-color: var(--accent); }
.att-play { position: absolute; inset: 0; margin: auto; width: 36px; height: 36px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; font-size: 15px; padding-left: 3px; }
.live-badge { position: absolute; top: 6px; left: 6px; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.att-name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Full-screen photo / video / Live Photo viewer */
html:has(body.viewer-open), body.viewer-open { overflow: hidden; background: #000; }
.viewer { position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: 100vh; height: 100dvh; z-index: 90; background: #000; color: #fff; display: flex; flex-direction: column; --viewer-bar: 60px; }
.viewer-bar { position: relative; z-index: 3; flex-shrink: 0; min-height: var(--viewer-bar); box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 8px calc(12px + var(--sal)); background: #000; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.viewer-close { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: rgba(255, 255, 255, .18); color: #fff; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.viewer-close:hover { background: rgba(255, 255, 255, .28); }
.viewer-title { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.viewer-title small { display: block; opacity: .7; font-size: 11px; }
.viewer-tools { flex-shrink: 0; display: flex; gap: 6px; }
.viewer-tools .btn { height: 44px; padding: 0 14px; font-size: 14px; background: rgba(255, 255, 255, .18); color: #fff; border-color: transparent; touch-action: manipulation; }
/* The photo/video is sized to fit the space under the bar, so the phone's own video controls stay on the video. */
.viewer-stage { position: relative; z-index: 1; flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 16px calc(8px + var(--sar)) calc(16px + var(--sab)) calc(8px + var(--sal)); }
.viewer-media { display: block; max-width: calc(100vw - 16px - var(--sal) - var(--sar)); max-height: calc(100dvh - var(--viewer-bar) - var(--sat) - var(--sab) - 40px); width: auto; height: auto; object-fit: contain; }
.viewer-stage > video.viewer-media { background: #000; }
.viewer-live { position: relative; display: inline-block; line-height: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.viewer-live .motion { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; opacity: 0; transition: opacity .15s; pointer-events: none; }
.viewer-live.playing .motion { opacity: 1; }
.viewer-file { text-align: center; }
.viewer-file .att-icon.big { font-size: 64px; }
.viewer-nav { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .12); color: #fff; font-size: 34px; cursor: pointer; }
.viewer-nav.prev { left: calc(8px + var(--sal)); }
.viewer-nav.next { right: calc(8px + var(--sar)); }
@media (max-width: 700px) { .viewer-nav { display: none; } }

/* ---------- conversation ---------- */
.convo { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; height: calc(100vh - 180px); height: calc(100dvh - 180px - var(--sat)); min-height: 460px; position: sticky; top: 0; }
.convo-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble-wrap { min-width: 0; }
.msg-meta { font-size: 11px; color: var(--muted); margin: 0 4px 2px; display: flex; gap: 6px; align-items: center; }
.msg.mine .msg-meta { justify-content: flex-end; }
.role { background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 0 5px; border-radius: 4px; }
.bubble { background: var(--panel-2); border: 1px solid var(--border); padding: 8px 11px; border-radius: 14px 14px 14px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--primary); border-color: var(--primary); color: var(--on-primary); border-radius: 14px 14px 4px 14px; }
.msg.mine .bubble a { color: var(--on-primary); }
.msg-event { align-self: center; text-align: center; font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.msg-event.is-call { color: var(--ok); }
.quick-replies { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 0; border-top: 1px solid var(--border); scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.quick-replies::-webkit-scrollbar { display: none; }
.quick-replies + .composer { border-top: 0; }
.chip { flex-shrink: 0; height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 10px 10px calc(10px + var(--composer-sab, 0px)); border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 140px; border-radius: 21px; padding: 10px 16px; resize: none; background: var(--panel-2); line-height: 1.35; }
.composer-send { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); cursor: pointer; box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent); }
.composer-send svg { width: 20px; height: 20px; fill: currentColor; margin-left: 2px; }
.composer-send:active { transform: scale(.94); }
.composer-attach { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); cursor: pointer; font-size: 18px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 20, .5); display: grid; place-items: center; padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - var(--sat) - var(--sab)); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-foot { border-top: 1px solid var(--border); justify-content: flex-end; gap: 8px; }
.modal-body { padding: 16px 18px; overflow-y: auto; min-height: 0; flex: 1 1 auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.modal { overflow: hidden; }
.modal-head, .modal-foot { flex: none; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: calc(16px + var(--sar)); bottom: calc(16px + var(--sab)); display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out; }
.toast > span { flex: 1; overflow-wrap: anywhere; }
.toast.error { border-color: var(--danger); }

/* ---------- call ---------- */
.call { position: fixed; inset: 24px; z-index: 60; background: #0b0d12; color: #fff; border-radius: 16px; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; }
.call.minimized { inset: auto calc(16px + var(--sar)) calc(16px + var(--sab)) auto; width: 340px; height: 250px; }
.call-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; gap: 8px; }
.call-title { display: flex; align-items: center; gap: 8px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.call-title span:last-child { overflow: hidden; text-overflow: ellipsis; }
.call-head-actions { display: flex; flex: none; }
.call .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #f04438; flex: none; animation: pulse 1.6s infinite; }
.call-grid { flex: 1; display: grid; gap: 8px; padding: 0 12px; min-height: 0; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.call-grid[data-count="1"], .call-grid[data-count="2"] { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tile { position: relative; background: #1a1e27; border-radius: 12px; overflow: hidden; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.tile video.mirror { transform: scaleX(-1); }
.tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.call-controls { display: flex; justify-content: center; gap: 10px; padding: 12px; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 76px; padding: 8px 10px; border-radius: 12px; border: 0; background: #262b36; color: #fff; font: inherit; font-size: 18px; cursor: pointer; }
.ctl span { font-size: 11px; }
.ctl:hover { background: #313746; }
.ctl.off { background: #4a2126; }
.ctl.on { background: var(--ok); }
.ctl.danger { background: #d92d20; }
.ctl:disabled { opacity: .45; cursor: default; }
.ctl[hidden] { display: none; }
.call.minimized .call-grid { grid-template-columns: 1fr 1fr; padding: 0 6px; gap: 4px; }
.call.minimized .call-grid[data-count="1"] { grid-template-columns: 1fr; }
.call.minimized .call-controls { padding: 6px; gap: 6px; }
.call.minimized .ctl { min-width: 0; padding: 6px 10px; font-size: 14px; }
.call.minimized .ctl span, .call.minimized .tile-name { display: none; }

/* ---------- dashboard ---------- */
.bar-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) 34px; align-items: center; gap: 10px; width: 100%; padding: 4px 6px; margin: 0 -6px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.bar-row:hover { background: var(--panel-2); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee)); }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }

/* ---------- list toolbar ---------- */
.list-head { justify-content: space-between; align-items: center; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; }
.tool span { padding: 0 8px 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tool select { border: 0; border-left: 1px solid var(--border); border-radius: 0; width: auto; max-width: 200px; padding: 6px 8px; height: 32px; background: var(--panel); }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.search-note { margin: -6px 0 10px; }
.center { text-align: center; }

/* ---------- grid cells ---------- */
.grid th .sort { margin-left: 4px; color: var(--accent); }
.sub-meta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); margin-top: 1px; }
.sub-meta:empty { display: none; }
.store-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 3px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
.store-chip b { padding: 1px 6px; border-radius: 99px; font-size: 11px; background: hsl(var(--h) 70% var(--pill-l)); color: hsl(var(--h) 60% var(--pill-text-l)); }
.device { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.person { display: inline-flex; align-items: center; gap: 6px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.grid tr.is-closed td { color: var(--muted); }
.grid tr.is-closed .subject { font-weight: 450; }
.group-row td { background: var(--panel-2); cursor: pointer; font-size: 13px; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.group-row:hover td { background: var(--accent-soft); }
.group-row .caret { display: inline-block; width: 16px; color: var(--muted); }
.group-n { margin-left: 8px; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel); border: 1px solid var(--border); padding: 0 7px; border-radius: 99px; }

/* ---------- board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.kcol { flex: 0 0 290px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 170px); transition: background .12s, border-color .12s; }
.kcol.is-closed { opacity: .8; }
.kcol.drop { border-color: var(--accent); background: var(--accent-soft); }
.kcol header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; position: sticky; top: 0; }
.kcol-body { padding: 0 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 11px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: transform .1s, box-shadow .1s; }
.kcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kcard.is-overdue { box-shadow: inset 3px 0 var(--danger), var(--shadow); }
.kcard.dragging { opacity: .45; }
.kcard[draggable] { cursor: grab; }
.kc-top { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.kc-due { margin-left: auto; }
.kc-subject { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.kc-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.kc-meta:empty { display: none; }
.kc-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.kc-foot .avatar { margin-left: auto; }

/* ---------- store form & QR codes ---------- */
.store-banner { display: flex; align-items: center; gap: 12px; font-size: 24px; padding: 12px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--border); }
.store-banner strong { display: block; font-size: 15px; }
.store-banner small { display: block; font-size: 12px; color: var(--muted); }
.qr-intro { max-width: 760px; margin: -4px 0 14px; }
.notice { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); padding: 10px 14px; border-radius: 10px; max-width: 760px; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.qr-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.qr-img { width: 150px; background: #fff; padding: 8px; border-radius: 8px; }
.qr-img svg, .poster-qr svg { display: block; width: 100%; height: auto; }
.qr-label { font-weight: 650; }
.qr-url { font-size: 11px; color: var(--muted); word-break: break-all; }
.qr-actions { display: flex; gap: 6px; }
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
}
.modal.modal-wide { max-width: min(640px, calc(100vw - 32px)); }

/* ---------- notifications ---------- */
.push-btn { font-size: 17px; opacity: .75; }
.push-btn.on { opacity: 1; }
.steps-list { margin: 8px 0 0; padding-left: 20px; line-height: 1.7; }
.btn.big { height: 50px; font-size: 17px; }
.side-signout { display: none; width: 100%; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; text-align: left; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 12px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 12px; }
.side-signout small { font-size: 11px; }

.only-mobile { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .ticket-body { grid-template-columns: minmax(0, 1fr); }
  .convo { position: static; height: 70vh; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .toolbar { width: 100%; }
  .tool { flex: 1 1 140px; }
  .tool select { flex: 1; max-width: none; }
  .kcol { flex-basis: 82vw; }
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: calc(260px + var(--sal)); padding-left: calc(10px + var(--sal)); padding-bottom: calc(12px + var(--sab)); z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.menu-open .sidebar { transform: none; }
  .brand-text, .user-name, #logout-btn, .topbar .theme-select { display: none; }
  .push-btn { width: 36px; height: 36px; }
  .side-signout { display: flex; }
  .topbar { gap: 8px; padding: var(--sat) calc(10px + var(--sar)) 0 calc(10px + var(--sal)); }
  .search { margin-left: 0; }
  #new-ticket-btn { padding: 0 10px; }
  .main { padding: 14px calc(16px + var(--sar)) calc(24px + var(--sab)) calc(16px + var(--sal)); }
  .fields { grid-template-columns: 1fr; }
  .call { inset: 0; border-radius: 0; padding: var(--sat) var(--sar) var(--sab) var(--sal); }
  .call.minimized { inset: auto calc(8px + var(--sar)) calc(8px + var(--sab)) auto; width: 220px; height: 180px; border-radius: 12px; padding: 0; }
  .ctl { min-width: 0; }
}


/* ---------- dashboard cards (phone home + desktop dashboard) ---------- */
.m-card { position: relative; background: var(--card-sheen), var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.m-title { font-size: 17px; font-weight: 700; margin: 20px 2px 10px; letter-spacing: -.01em; }
.m-card .m-title { margin: 0; }
.m-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 10px; flex-wrap: wrap; }
.m-card > .m-head, .m-rings > .m-head { margin: 0 0 12px; }
.m-head .m-title { margin: 0; }
.m-none { padding: 18px 4px; }
.m-more { display: block; text-align: right; font-weight: 600; font-size: 13px; text-decoration: none; margin: -4px 4px 8px; }

.m-hello { overflow: hidden; }
.m-hello::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; height: 140%; background: radial-gradient(closest-side, color-mix(in srgb, var(--primary) 22%, transparent), transparent); pointer-events: none; }
.m-hello-top { display: flex; align-items: center; gap: 12px; position: relative; }
.m-hello h2 { font-size: 20px; line-height: 1.2; letter-spacing: -.01em; }
.m-hello p { margin: 10px 0 14px; position: relative; }
.m-date { color: var(--muted); font-size: 12px; font-weight: 600; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px color-mix(in srgb, var(--primary) 45%, transparent); }
.m-cta { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 12px 0 10px; border: 0; border-radius: 14px; background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent); }
.m-cta:hover { filter: brightness(1.06); }
.m-cta-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, .2); }
.m-cta-arrow { margin-left: auto; font-size: 18px; }
.m-cta-badge { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 7px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.m-cta.calm { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.m-cta.calm .m-cta-icon { background: var(--accent-soft); }

.m-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.m-stat { --tone: var(--accent); display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 92px; background: var(--card-sheen), var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); color: var(--text); text-decoration: none; min-width: 0; transition: transform .12s, border-color .12s; }
.m-stat:hover { transform: translateY(-1px); border-color: var(--tone); }
.m-stat.accent { --tone: var(--primary); }
.m-stat.danger { --tone: var(--danger); }
.m-stat.warn { --tone: var(--warn); }
.m-stat.ok { --tone: var(--ok); }
.m-stat-icon { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 64px; height: 64px; border-radius: 14px; background: color-mix(in srgb, var(--tone) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent); font-size: 22px; line-height: 1; }
.m-stat-icon small { font-size: 9px; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.15; padding: 0 3px; }
.m-stat.danger .m-stat-icon, .m-stat.accent .m-stat-icon { background: var(--tone); border-color: var(--tone); }
.m-stat.danger .m-stat-icon small, .m-stat.accent .m-stat-icon small { color: rgba(255, 255, 255, .9); }
.m-stat-body { display: flex; flex-direction: column; min-width: 0; }
.m-stat-n { font-size: 28px; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.m-trend { font-size: 11px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-trend small { font-weight: 500; color: var(--muted); font-size: 11px; }
.m-trend.good { color: var(--ok); }
.m-trend.bad { color: var(--danger); }
.m-trend.flat { color: var(--muted); font-weight: 500; }

.m-seg { display: flex; gap: 6px; }
.m-seg button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.m-seg button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ticket cards */
.tcards { display: grid; gap: 16px; padding-top: 8px; }
.tcard { position: relative; display: block; padding: 18px 14px 12px; background: var(--card-sheen), var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); color: var(--text); text-decoration: none; --tone: var(--primary); }
.tcard:hover { border-color: var(--tone); }
.tcard.is-closed { --tone: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--card-sheen), color-mix(in srgb, var(--ok) 7%, var(--panel)); }
.tcard.is-overdue { --tone: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); background: var(--card-sheen), color-mix(in srgb, var(--danger) 7%, var(--panel)); }
.tcard.is-live { --tone: var(--ok); }
.tcard-tag { position: absolute; top: -10px; left: 12px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 650; background: var(--panel); border: 1px solid hsl(var(--h) 65% 55%); color: hsl(var(--h) 60% var(--pill-text-l)); }
.tcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tcard-title { font-size: 15px; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tcard-top .pill { flex: none; max-width: 42%; overflow: hidden; text-overflow: ellipsis; }
.tcard-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 10px; margin-top: 12px; }
.tcard-id { padding: 6px 9px; border-radius: 10px; border: 1.5px solid color-mix(in srgb, var(--tone) 60%, var(--border)); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.tcard-who { display: flex; flex-direction: column; min-width: 0; }
.tcard-who b, .tcard-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-who b { font-size: 13px; }
.tcard-who small, .tcard-when small { color: var(--muted); font-size: 11px; }
.tcard-when { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tcard-go { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--tone); color: #fff; font-weight: 700; }
.card-group { display: flex; align-items: center; gap: 8px; padding: 8px 4px 0; cursor: pointer; font-size: 14px; }
.card-group .group-n { margin-left: auto; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.axis { fill: var(--muted); font-size: 9px; font-family: inherit; }
.line { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.line.opened { stroke: var(--c-open); filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--c-open) 35%, transparent)); }
.line.closed { stroke: var(--c-closed); }
.area-top { stop-color: var(--c-open); stop-opacity: .3; }
.area-bottom { stop-color: var(--c-open); stop-opacity: 0; }
.cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-lg); }
.chart-tip[hidden] { display: none; }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.legend { display: flex; justify-content: center; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.m-head .legend { margin: 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.opened { background: var(--c-open); }
.dot.closed { background: var(--c-closed); }
.dot.c1, .dot.t-accent { background: var(--c1); }
.dot.c2, .dot.t-ok { background: var(--c2); }
.dot.c3, .dot.t-danger { background: var(--c3); }
.dot.c4, .dot.t-warn { background: var(--c4); }
.dot.t-muted { background: var(--muted); }

/* device rings */
.rings { position: relative; width: min(240px, 80%); margin: 4px auto 16px; }
.rings svg { display: block; width: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--panel-2); stroke-width: 11; }
.ring { fill: none; stroke-width: 11; stroke-linecap: round; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.ring.c1 { stroke: var(--c1); } .ring.c2 { stroke: var(--c2); } .ring.c3 { stroke: var(--c3); } .ring.c4 { stroke: var(--c4); }
.rings-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.rings-center b { font-size: 26px; letter-spacing: -.02em; }
.rings-center span { color: var(--muted); font-size: 12px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-rows { display: grid; gap: 8px; }
.ring-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.ring-row:hover { border-color: var(--accent); }
.ring-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* priority gauge */
.gauge { position: relative; width: min(280px, 100%); margin: 6px auto 8px; }
.gauge svg { display: block; width: 100%; }
.gauge-track { fill: none; stroke: var(--panel-2); stroke-width: 14; stroke-linecap: round; }
.gauge-arc { fill: none; stroke-width: 14; stroke-linecap: round; }
.gauge-arc.t-danger { stroke: var(--c3); } .gauge-arc.t-warn { stroke: var(--c4); } .gauge-arc.t-accent { stroke: var(--c1); } .gauge-arc.t-ok { stroke: var(--c2); } .gauge-arc.t-muted { stroke: var(--muted); }
.gauge-center { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; }
.gauge-center small { display: block; color: var(--muted); font-size: 12px; }
.gauge-center b { font-size: 30px; letter-spacing: -.02em; }
.gauge-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; font-size: 12px; color: var(--muted); }
.gauge-legend span { display: flex; align-items: center; gap: 7px; }
.gauge-legend b { margin-left: auto; color: var(--text); }

/* this week bars */
.d-bignums { display: flex; gap: 28px; margin-bottom: 12px; }
.d-bignums small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.d-bignums b, .d-big { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.d-big { font-size: 26px; line-height: 1.2; }
.wbars { display: flex; gap: 10px; height: 170px; align-items: stretch; }
.wbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.wbar small { color: var(--muted); font-size: 11px; }
.wbar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--border); }
.wbar-track span { width: min(18px, 40%); min-height: 2px; border-radius: 6px 6px 2px 2px; }
.wbar-open { background: color-mix(in srgb, var(--c-open) 75%, transparent); }
.wbar-closed { background: var(--c-closed); }

/* recent tickets rows */
.d-rows { display: grid; gap: 4px; }
.d-row { display: grid; grid-template-columns: 5px 96px minmax(0, 1fr) auto 24px; align-items: center; gap: 14px; padding: 10px 10px; border-radius: 12px; color: var(--text); text-decoration: none; border: 1px solid transparent; }
.d-row:hover { background: var(--panel-2); border-color: var(--border); box-shadow: var(--shadow); }
.d-row-bar { width: 5px; height: 38px; border-radius: 3px; background: hsl(var(--h) 70% 60%); }
.d-row-date, .d-row-text { display: flex; flex-direction: column; min-width: 0; }
.d-row-date b { font-size: 13px; }
.d-row-date small, .d-row-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-row-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-row-status .pill { max-width: 150px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.d-row-go { opacity: 0; color: var(--muted); font-weight: 700; }
.d-row:hover .d-row-go { opacity: 1; }
.overdue-pill { background: color-mix(in srgb, var(--danger) 18%, var(--panel)); color: var(--danger); }

/* desktop dashboard grid */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash .m-card { margin: 0; }
.dash .m-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash .m-stat { min-height: 0; }
.d-hello { grid-column: span 4; display: flex; }
.d-hello .m-card { flex: 1; margin: 0; display: flex; flex-direction: column; justify-content: space-between; }
.d-stats { grid-column: span 8; }
.d-chart { grid-column: span 8; }
.d-gauge { grid-column: span 4; }
.d-bars { grid-column: span 5; }
.d-recent { grid-column: span 7; }
.d-rings { grid-column: span 4; }
.d-stores { grid-column: span 8; }
.dash-store { grid-template-columns: minmax(0, 520px); }
.dash-store .m-card { margin: 0; }
@media (max-width: 1250px) {
  .d-hello, .d-stats, .d-chart, .d-recent { grid-column: span 12; }
  .dash .d-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .d-gauge, .d-bars, .d-rings, .d-stores { grid-column: span 6; }
}
@media (max-width: 1000px) {
  .dash .d-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* side menu theme picker */
.side-theme { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 0 10px; font-size: 12px; color: var(--muted); }
.side-theme select { flex: 1; }
@media (min-width: 761px) { .side-theme { display: none; } }

/* ---------- Database section ---------- */
.data-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumb { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.data-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.data-tools input[type=search] { width: min(320px, 60vw); }
.data-cards { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.data-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-bottom: 16px; }
.data-grid .m-card { margin: 0; }
.data-card .m-stat-n small { font-size: 16px; font-weight: 600; }
.pbar { display: block; height: 7px; border-radius: 99px; background: var(--panel-2); overflow: hidden; margin: 4px 0 3px; min-width: 80px; }
.pbar > span { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.pbar.big { height: 12px; margin: 8px 0 4px; }
.pbar.c1 > span { background: var(--c1); } .pbar.c2 > span { background: var(--c2); } .pbar.c3 > span { background: var(--c3); } .pbar.c4 > span { background: var(--c4); }
.plist { display: grid; gap: 10px; }
.prow { display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.prow:hover { border-color: var(--accent); }
.prow-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.prow-top span { color: var(--muted); }
.prow-top span b { color: var(--text); font-size: 16px; }
.pie { position: relative; width: min(190px, 70%); margin: 0 auto 14px; }
.pie svg { display: block; width: 100%; transform: rotate(-90deg); }
.pie-track { fill: none; stroke: var(--panel-2); stroke-width: 26; }
.pie-seg { fill: none; stroke-width: 26; }
.pie-seg.c1 { stroke: var(--c1); } .pie-seg.c2 { stroke: var(--c2); } .pie-seg.c3 { stroke: var(--c3); } .pie-seg.c4 { stroke: var(--c4); }
.pie-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pie-center b { font-size: 26px; letter-spacing: -.02em; }
.pie-center span { color: var(--muted); font-size: 12px; }
.chip.on { border-color: var(--primary); background: var(--accent-soft); color: var(--text); font-weight: 600; height: 30px; }
.data-rows .d-row { grid-template-columns: 5px 110px minmax(0, 1fr) auto 24px; background: var(--panel); border-color: var(--border); margin-bottom: 6px; }
.data-rows .d-row-status { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.dm-group { margin-bottom: 16px; }
.dm-group .card-label { margin-bottom: 8px; }
.data-modal .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.data-modal .kv { display: flex; flex-direction: column; gap: 4px; }
.data-modal .kv .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.data-modal .kv.wide { grid-column: 1 / -1; }
.data-modal .saved { outline: 2px solid var(--ok); outline-offset: 1px; transition: outline-color .6s; }
.modal.modal-wide.data-modal { max-width: min(760px, calc(100vw - 32px)); }
@media (max-width: 760px) {
  .data-rows .d-row { grid-template-columns: 5px 64px minmax(0, 1fr); gap: 10px; }
  .data-rows .d-row-status { grid-column: 3; justify-content: flex-start; }
  .data-rows .d-row-go { display: none; }
  .data-tools input[type=search] { width: 100%; flex: 1; }
  .data-head .data-tools { width: 100%; }
  .data-modal .fields { grid-template-columns: 1fr; }
  .modal-backdrop:has(.data-modal) { padding: 0; }
  .modal.modal-wide.data-modal { max-width: none; height: 100%; max-height: none; border-radius: 0; padding-top: var(--sat); padding-bottom: var(--sab); }
}

/* ---------- search results ---------- */
.s-sec { margin-bottom: 22px; }
.s-sec > .m-title { margin-top: 0; }
.s-pages { display: flex; flex-wrap: wrap; gap: 8px; }
.s-page { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); text-decoration: none; font-weight: 600; }
.s-page:hover { border-color: var(--accent); }
.s-stores { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.s-store { margin: 0; }
.s-store-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.s-store-top > div { display: flex; flex-direction: column; min-width: 0; }
.s-store-top small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-store-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (min-width: 761px) { .s-tickets, .main > .tcards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }
.data-progress .plist { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.data-pies { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- chat polish ---------- */
.msg-day { align-self: center; display: flex; align-items: center; gap: 10px; width: 100%; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 2px; }
.msg-day::before, .msg-day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg-event span { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border); }
.msg-event time { color: var(--muted); }
.msg { max-width: 82%; }
.msg.cont { margin-top: -6px; }
.msg.cont .avatar { visibility: hidden; }
.msg .avatar { width: 26px; height: 26px; font-size: 10px; }
.bubble { border-radius: 18px 18px 18px 6px; padding: 9px 13px; line-height: 1.4; }
.msg.mine .bubble { border-radius: 18px 18px 6px 18px; box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 25%, transparent); }
.msg.cont .bubble { border-top-left-radius: 6px; }
.msg.mine.cont .bubble { border-top-left-radius: 18px; border-top-right-radius: 6px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.chat-empty p { margin: 4px 0; }
.ticket-tabs { display: none; }
.tab-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel-2); color: var(--text); font-size: 11px; margin-left: 2px; }
.m-seg button.on .tab-n { background: rgba(255, 255, 255, .25); color: inherit; }

/* ---------- video call polish ---------- */
.call { background: radial-gradient(120% 80% at 50% 0%, #1b2030, #07080c); }
.tile { background: #141824; border-radius: 16px; }
.tile video { object-fit: cover; }
.tile.is-me video { object-fit: cover; }
.tile-name { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 99px; padding: 3px 10px; }
.call-controls { gap: 14px; padding: 14px 12px calc(14px + var(--sab)); }
.ctl { border-radius: 16px; background: rgba(255, 255, 255, .1); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .1s, background .15s; }
.ctl:active { transform: scale(.94); }
.ctl:hover { background: rgba(255, 255, 255, .18); }
.ctl.off { background: rgba(249, 112, 102, .3); }

@media (max-width: 760px) {
  /* ticket page: tabs instead of stacking chat under the details */
  .ticket-head { margin-bottom: 10px; }
  .ticket-head h1 { font-size: 18px; }
  .ticket-tabs { display: flex; position: sticky; top: -14px; z-index: 5; padding: 8px 0; margin: 0 0 8px; background: var(--bg); }
  .ticket-tabs button { flex: 1; height: 36px; font-size: 13px; }
  .ticket.tab-chat .details, .ticket.tab-files .details > :not(.att-card), .ticket.tab-details .att-card, .ticket.tab-details .convo, .ticket.tab-files .convo { display: none; }
  .ticket.tab-chat .convo { height: calc(100dvh - var(--topbar-h) - 150px); min-height: 360px; border-radius: 18px; }
  .ticket.tab-chat .main, .ticket.tab-chat { padding-bottom: 0; }
  .convo-head { padding: 10px 12px; }
  .convo-head #call-btn { height: 38px; border-radius: 19px; padding: 0 14px; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 88%; }
  .composer { padding: 8px; }
  .quick-replies { padding: 8px 8px 0; }

  /* video call: remote person full screen, you in a small corner window, round buttons */
  .call-head { position: absolute; top: 0; left: 0; right: 0; z-index: 3; padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 24px calc(12px + var(--sal)); background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
  .call:not(.minimized) { padding: 0; }
  .call:not(.minimized) .call-grid { padding: 0; gap: 4px; grid-template-columns: 1fr; }
  .call:not(.minimized) .call-grid[data-count="2"] .tile:not(.is-me) { border-radius: 0; }
  .call:not(.minimized) .call-grid[data-count="2"] .tile.is-me { position: absolute; z-index: 2; top: calc(64px + var(--sat)); right: calc(12px + var(--sar)); width: 104px; height: 148px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .25); }
  .call:not(.minimized) .call-grid[data-count="2"] .tile.is-me .tile-name { display: none; }
  .call:not(.minimized) .call-grid[data-count="3"], .call:not(.minimized) .call-grid[data-count="4"] { grid-template-columns: 1fr 1fr; }
  .call:not(.minimized) .call-controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 28px 12px calc(18px + var(--sab)); gap: 16px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
  .call:not(.minimized) .ctl { width: 58px; height: 58px; min-width: 0; padding: 0; border-radius: 50%; font-size: 22px; justify-content: center; }
  .call:not(.minimized) .ctl span { display: none; }
  .call:not(.minimized) .call-grid { position: absolute; inset: 0; }
  .call:not(.minimized) .tile-name { bottom: calc(110px + var(--sab)); left: 12px; }
}

/* ---------- ticket page polish ---------- */
.ticket-topline { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ticket-topline .back { margin: 0; }
.ticket-no { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticket-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.detail-card .card-label { margin-bottom: 10px; }
.details .card { border-radius: 16px; }
@media (max-width: 760px) {
  .main:has(.ticket) { overflow-x: hidden; }
  .ticket { max-width: 100%; }
  .ticket-head { background: var(--card-sheen), var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
  .ticket-topline .back { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13px; }
  .ticket-title h1 { font-size: 20px; line-height: 1.25; }
  .ticket-facts { font-size: 12px; }
  .details .card { padding: 12px 14px; margin-bottom: 12px; }
  /* iPhone Settings-style rows: label left, value right */
  .details .fields { display: block; }
  .details .kv { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 6px 0; border-bottom: 1px solid var(--border); margin: 0; }
  .details .kv:last-child { border-bottom: 0; }
  .details .kv .k { flex: none; max-width: 45%; font-size: 14px; color: var(--muted); font-weight: 500; margin: 0; }
  .details .kv .v { flex: 1; min-width: 0; display: flex; justify-content: flex-end; text-align: right; }
  .details .kv .v select, .details .kv .v input:not([type=checkbox]) { border: 0; background: transparent; text-align: right; text-align-last: right; padding: 6px 0; width: 100%; font-size: 15px; color: var(--text); }
  .details .kv .v select { appearance: none; -webkit-appearance: none; padding-right: 16px; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 6px center / 5px 5px no-repeat, linear-gradient(-45deg, transparent 50%, var(--muted) 50%) right 1px center / 5px 5px no-repeat; }
  .details .kv.wide { flex-direction: column; align-items: stretch; }
  .details .kv.wide .k { max-width: none; }
  .details .kv.wide .v { justify-content: flex-start; text-align: left; }
  .details .kv.wide textarea { width: 100%; }
  .details .kv .v input[type=datetime-local], .details .kv .v input[type=date] { text-align: right; }
}
.more-fields { margin-top: 6px; }
.more-fields > summary { cursor: pointer; list-style: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 6px 0; }
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields > summary::after { content: " ▾"; }
.more-fields[open] > summary::after { content: " ▴"; }
.more-fields > summary.card-label { color: var(--muted); margin: 0; }
.cs-btn { margin-top: 10px; }
.cs-hint { margin: 6px 2px 4px; }
.cs-copy { display: flex; gap: 8px; }
.cs-copy input { font-size: 12px; }
.linkish { border: 0; background: none; color: var(--accent); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }

/* ---------- phones (iPhone + Android) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, .btn, a, label, summary, .tab { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.main, .modal-body, .messages, .sidebar { overscroll-behavior: contain; }
.tabbar { display: none; }

/* new-ticket form: device tiles, priority chips, photo drop zone */
.pick-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.pick-tile, .pick-chip { position: relative; cursor: pointer; }
.pick-tile input, .pick-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pick-tile span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 76px; padding: 8px 6px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--panel-2); text-align: center; font-size: 12px; font-weight: 600; line-height: 1.2; transition: border-color .12s, background .12s, transform .1s; }
.pick-tile i { font-style: normal; font-size: 22px; }
.pick-tile input:checked + span { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 16%, var(--panel)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.pick-tile input:focus-visible + span, .pick-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-tile:active span, .pick-chip:active span { transform: scale(.97); }
.pick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-chip { --tone: var(--accent); }
.pick-chip.t-danger { --tone: var(--danger); } .pick-chip.t-warn { --tone: var(--warn); } .pick-chip.t-ok { --tone: var(--ok); }
.pick-chip span { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1.5px solid var(--border); border-radius: 20px; background: var(--panel-2); font-weight: 600; }
.pick-chip input:checked + span { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 18%, var(--panel)); color: var(--text); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 12px; border: 2px dashed var(--border); border-radius: 16px; background: var(--panel-2); text-align: center; cursor: pointer; }
.dropzone:hover { border-color: var(--accent); }
.dz-icon { font-size: 26px; }
.dropzone small { color: var(--muted); font-size: 12px; }
.dz-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 8px; }
.dz-previews:empty { display: none; }
.dz-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dz-item img, .dz-item span { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; font-size: 24px; border: 1px solid var(--border); }
.dz-item small { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* store (end user) home */
.m-tips .m-title { margin: 0 0 10px; }
.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; }
.tips li > span { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); font-size: 18px; }
.tips li div { display: flex; flex-direction: column; }
.tips small { color: var(--muted); }
.store-stats { margin-bottom: 16px; }
.dash-store { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; max-width: 1100px; }
.dash-store .m-card { margin-bottom: 16px; }

@media (max-width: 760px) {
  /* 16px text in fields stops iPhones from zooming in when you tap one */
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  .dash-store { grid-template-columns: 1fr; }

  /* bottom tab bar */
  #new-ticket-btn { display: none; }
  .search { flex: 1; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; align-items: stretch; justify-content: space-around; height: calc(60px + var(--sab)); padding: 0 calc(6px + var(--sar)) var(--sab) calc(6px + var(--sal)); background: color-mix(in srgb, var(--topbar) 88%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border-top: 1px solid var(--border); }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer; min-width: 0; }
  .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab.on { color: var(--accent); }
  .tab-new { flex: none; align-self: center; width: 52px; height: 52px; margin-top: -18px; border-radius: 18px; background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 45%, transparent); }
  .tab-new span { font-size: 28px; font-weight: 400; line-height: 1; }
  .tab-new.wide { width: auto; flex-direction: row; gap: 8px; padding: 0 22px; border-radius: 26px; }
  .tab-new.wide b { font-size: 15px; }
  .main { padding-bottom: calc(84px + var(--sab)); }
  .sidebar { bottom: calc(60px + var(--sab)); }
  body.in-ticket .tabbar { display: none; }
  body.in-ticket .main { padding-bottom: calc(16px + var(--sab)); }
  .toasts { bottom: calc(76px + var(--sab)); }
  body.in-ticket .toasts { bottom: calc(16px + var(--sab)); }

  /* forms/popups fill the phone screen, buttons stay reachable at the bottom */
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: calc(100dvh - var(--sat) - 12px); padding-bottom: var(--sab); animation: sheet-up .22s ease-out; }
  .modal-foot { position: sticky; bottom: 0; background: var(--panel); }
  .modal-foot .btn { flex: 1; min-height: 46px; }
  .pick-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* tap-to-call / email / directions */
.qa-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.qa-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 16px; background: var(--card-sheen), var(--panel-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; text-align: center; min-width: 0; }
.qa-btn:hover { border-color: var(--accent); }
.qa-btn:active { transform: scale(.97); }
.qa-btn span { font-size: 22px; }
.qa-btn b { font-size: 13px; }
.qa-btn small { font-size: 11px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-modal .kv .v:has(.field-act) { display: flex; gap: 8px; align-items: center; }
.data-modal .kv .v:has(.field-act) > input { flex: 1; min-width: 0; }
.field-act { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--border); text-decoration: none; font-size: 18px; }

/* switch between Database tables without the menu */
.data-switch { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -4px 0 14px; padding: 2px 0; }
.data-switch::-webkit-scrollbar { display: none; }
.data-switch a { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.data-switch a .nav-ic { width: 16px; height: 16px; }
.data-switch a.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (max-width: 760px) {
  #menu-btn { display: none; } /* the bottom tab bar has Menu */
  .topbar { padding-left: calc(12px + var(--sal)); }
  .data-switch { margin-left: -16px; margin-right: -16px; padding: 2px 16px; }
  .data-switch a { flex: 1 0 auto; justify-content: center; }
}

/* ---------- viewer: photos/videos use the whole screen ---------- */
.viewer-stage .viewer-media.fill { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; }
.viewer.is-image, .viewer.is-live { background: #000; }
.viewer.is-image .viewer-bar, .viewer.is-live .viewer-bar { position: absolute; top: 0; left: 0; right: 0; background: linear-gradient(rgba(0, 0, 0, .7), rgba(0, 0, 0, 0)); border-bottom: 0; transition: opacity .2s; padding-bottom: 20px; }
.viewer.chrome-off .viewer-bar, .viewer.chrome-off .viewer-nav { opacity: 0; pointer-events: none; }
.viewer.is-image .viewer-stage, .viewer.is-live .viewer-stage { position: absolute; inset: 0; padding: 0; overflow: hidden; }
.viewer.is-image .viewer-live, .viewer.is-live .viewer-live { width: 100%; height: 100%; display: block; }
.viewer.is-image .viewer-live img, .viewer.is-live .viewer-live img { touch-action: none; transform-origin: center center; will-change: transform; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.viewer.is-live .viewer-live .motion { position: absolute; inset: 0; }
.viewer.is-video .viewer-stage { padding: 0 0 var(--sab); }
.viewer.is-video .viewer-stage > video.fill { background: #000; }
.viewer-tools .btn[data-v="fullscreen"] { font-size: 18px; padding: 0 12px; }

/* instant tap feedback */
.tab { transition: color .12s, transform .08s; }
.tab:active { transform: scale(.92); }
.tab-new:active { transform: scale(.92); filter: brightness(1.1); }
.nav-item:active, .d-row:active, .tcard:active, .m-stat:active, .ring-row:active, .bar-row:active, .s-page:active, .data-switch a:active, .btn:active { transform: scale(.98); }

/* ---------- priority colors ---------- */
:root { --p-low: #22c55e; --p-med: #3b82f6; --p-high: #f59e0b; --p-crit: #ef4444; --p-none: var(--muted); }
.prio-low { --pc: var(--p-low); } .prio-med { --pc: var(--p-med); } .prio-high { --pc: var(--p-high); } .prio-crit { --pc: var(--p-crit); } .prio-none { --pc: var(--p-none); }
.pill.prio { background: color-mix(in srgb, var(--pc) 16%, var(--panel)); color: color-mix(in srgb, var(--pc) 78%, var(--text)); border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent); font-weight: 650; }
.pill.prio::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pc); margin-right: 5px; vertical-align: 1px; }
.pill.prio.prio-crit { background: var(--p-crit); color: #fff; border-color: var(--p-crit); }
.pill.prio.prio-crit::before { background: #fff; }
.dot.prio-low, .dot.prio-med, .dot.prio-high, .dot.prio-crit, .dot.prio-none { background: var(--pc); }
.gauge-arc.prio-low, .gauge-arc.prio-med, .gauge-arc.prio-high, .gauge-arc.prio-crit, .gauge-arc.prio-none { stroke: var(--pc); }
.pick-chip span { gap: 7px; }
.pick-chip[class*="prio-"] span { border-color: color-mix(in srgb, var(--pc) 50%, var(--border)); background: color-mix(in srgb, var(--pc) 10%, var(--panel-2)); }
.pick-chip[class*="prio-"] span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pc); }
.pick-chip[class*="prio-"] input:checked + span { background: var(--pc); border-color: var(--pc); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--pc) 40%, transparent); }
.pick-chip[class*="prio-"] input:checked + span::before { background: #fff; }
.tcard-prio { position: absolute; top: -10px; right: 12px; }
.tcard-prio .pill { font-size: 11px; padding: 2px 8px; }
.kc-top .pill.prio { font-size: 10px; padding: 1px 7px; }
select[data-prio] { font-weight: 650; }
select[data-prio="low"] { color: var(--p-low); } select[data-prio="med"] { color: var(--p-med); } select[data-prio="high"] { color: var(--p-high); } select[data-prio="crit"] { color: var(--p-crit); }

/* supervisors */
.role.sup { background: color-mix(in srgb, var(--warn) 22%, var(--panel)); color: var(--text); }
.ys-rows { display: grid; gap: 6px; }
.ys-row.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 64px); gap: 8px; align-items: center; padding: 10px 12px; margin: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.ys-name b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.ys-n { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ys-n b { font-size: 17px; font-variant-numeric: tabular-nums; }
.ys-n small { font-size: 10px; color: var(--muted); }
.ys-n.bad b { color: var(--danger); }
.ok-pill { background: color-mix(in srgb, var(--ok) 18%, var(--panel)); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
@media (max-width: 760px) { .ys-row.bar-row { grid-template-columns: minmax(0, 1fr) repeat(3, 52px); } }

/* chat: scroll inside the box; closed tickets end the chat */
.messages { min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-closed { display: flex; align-items: center; gap: 12px; margin: 10px; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--border); }
.chat-closed > span { font-size: 20px; }
.chat-closed > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-closed small { color: var(--muted); }
@media (max-width: 760px) {
  .ticket.tab-chat .convo { height: auto; min-height: 0; }
  body.in-ticket:has(.ticket.tab-chat) .main { overflow: hidden; }
}

.tip-call-btn { align-self: flex-start; margin-top: 6px; background: var(--accent-soft); border-color: var(--border); color: var(--text); text-decoration: none; }

/* "Add to Home Screen" card */
.install-card { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.ic-top { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ic-top > div { display: flex; flex-direction: column; min-width: 0; }
.ic-top small { color: var(--muted); }
.ic-icon { width: 48px; height: 48px; border-radius: 12px; flex: none; box-shadow: var(--shadow); }
.ic-steps { margin: 0 0 6px; padding-left: 22px; display: grid; gap: 6px; }
.ic-steps li { line-height: 1.4; }
.ic-glyph { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-later { display: block; margin: 8px auto 0; color: var(--muted); }

.dup-box { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--border)); color: var(--text); font-weight: 400; }
.dup-box p { margin: 0; font-size: 14px; line-height: 1.45; }
.dup-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.dup-ticket { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); }
.dup-ticket small { color: var(--muted); }
.dup-box small { color: var(--muted); }
.dup-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* shipments: one compact row per package; tap for details */
.ship-card { overflow: hidden; }
.ship-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.ship-row { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.ship-row > summary { display: flex; align-items: center; gap: 10px; padding: 9px 10px; list-style: none; cursor: pointer; min-width: 0; }
.ship-row > summary::-webkit-details-marker { display: none; }
.ship-row.done { opacity: .75; }
.ship-row.problem { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.ship-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); font-size: 16px; }
.ship-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ship-main b, .ship-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ship-main b { font-size: 14px; }
.ship-main small { color: var(--muted); font-size: 12px; }
.ship-when { color: var(--text); font-weight: 600; }
.ship-row.out .ship-when, .ship-row.done .ship-when { color: var(--ok); }
.ship-row.problem .ship-when { color: var(--danger); }
.ship-count { display: inline-block; margin-left: 2px; padding: 0 6px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; }
.ship-bar { display: block; height: 4px; margin-top: 3px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.ship-bar i { display: block; height: 100%; border-radius: 2px; background: var(--ok); }
.ship-track { flex: none; }
.ship-detail { padding: 0 12px 10px 52px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.ship-detail p { margin: 0 0 2px; color: var(--muted); line-height: 1.4; }
.ship-detail a { overflow-wrap: anywhere; }
.ship-rest > summary { cursor: pointer; list-style: none; padding: 8px; text-align: center; border: 1px dashed var(--border); border-radius: 12px; color: var(--accent); font-weight: 600; font-size: 13px; }
.ship-rest > summary::-webkit-details-marker { display: none; }
.ship-rest[open] > summary { display: none; }
.d-ship { grid-column: 1 / -1; }
.d-ship .m-card { margin: 0; }
@media (min-width: 761px) { .d-ship .ship-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
#ticket-ship .m-card { margin-bottom: 12px; }

.imp-example { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; white-space: pre-wrap; color: var(--muted); }
.imp-done { display: flex; flex-direction: column; gap: 3px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--border)); }
.imp-done small { color: var(--muted); }
.imp-skip { margin-top: 6px; color: var(--warn); }

/* test copy (SANDBOX=1) */
.sandbox .topbar { box-shadow: inset 0 -3px 0 #facc15; }
.sandbox-tag { display: inline-block; margin-left: 8px; padding: 2px 7px; border-radius: 6px; background: #facc15; color: #111; font-size: 11px; font-weight: 800; letter-spacing: .04em; vertical-align: middle; white-space: nowrap; }
.sandbox-note { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #facc15 16%, var(--panel)); border: 1px solid #facc15; font-size: 13px; }

.demo-add { display: grid; grid-template-columns: 1fr 1fr 140px auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.demo-add .field { margin: 0; }
@media (max-width: 760px) { .demo-add { grid-template-columns: 1fr; } }
.demo-list { display: grid; gap: 8px; margin-bottom: 14px; }
.demo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.demo-row.ended { opacity: .65; }
.demo-who { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.demo-who small, .demo-when small { color: var(--muted); overflow-wrap: anywhere; }
.demo-act { display: flex; gap: 6px; margin-left: auto; }
.demo-sub { font-size: 14px; color: var(--muted); margin: 18px 0 8px; }


/* scheduled installs (reuses the shipment rows) */
.inst-close { color: var(--warn) !important; font-weight: 600; }
.inst-detail div { line-height: 1.45; }
.inst-act { margin-top: 6px; }
.inst-rescheduled, .inst-inprogress { color: var(--warn); }
.inst-cancelled { color: var(--danger); }
.inst-completed { color: var(--ok); }
.inst-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.inst-grid .field { margin: 0; }
.inst-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .inst-grid { grid-template-columns: 1fr; } }
.btn.danger { color: var(--danger); }
.inst-foot { flex-wrap: wrap; }
.inst-foot .inst-test { flex: 1 1 100%; }
@media (min-width: 761px) { .inst-foot .inst-test { flex: 0 0 auto; margin-right: auto; } .inst-foot { flex-wrap: nowrap; } }
.inst-grid [hidden], .inst-grid .req[hidden] { display: none !important; }
