/* Themes: data-theme on <html> = dark (default) | qsc | light | auto (follow the device) */
:root {
  --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;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1218;
  --panel: #171b23;
  --panel-2: #1c212b;
  --border: #2a303c;
  --text: #e6e9ef;
  --muted: #98a2b3;
  --accent: #8b85ff;
  --accent-soft: #252a45;
  --primary: #6d64f5;
  --on-primary: #ffffff;
  --danger: #f97066;
  --ok: #32d583;
  --warn: #fdb022;
  --pill-l: 24%;
  --pill-text-l: 82%;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0f1218;
    --panel: #171b23;
    --panel-2: #1c212b;
    --border: #2a303c;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --accent: #8b85ff;
    --accent-soft: #252a45;
    --primary: #6d64f5;
    --on-primary: #ffffff;
    --danger: #f97066;
    --ok: #32d583;
    --warn: #fdb022;
    --pill-l: 24%;
    --pill-text-l: 82%;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    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="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; color: var(--muted); padding: 16px; 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; padding: 16px; }
.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: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; 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: 12px; right: 12px; }
.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; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.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: 600; }
.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; 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); }
.att img, .att-icon { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); display: grid; place-items: center; font-size: 26px; }
.att-name { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 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); 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); }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 13, 20, .5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); 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; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; 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 16px 16px 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; }
.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 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { --tone: var(--muted); position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); overflow: hidden; transition: transform .12s, box-shadow .12s; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tone); }
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat.active { border-color: var(--tone); }
.stat.accent { --tone: var(--accent); }
.stat.warn { --tone: var(--warn); }
.stat.danger { --tone: var(--danger); }
.stat.ok { --tone: var(--ok); }
.stat-n { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.hotspots { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.hotspots summary { padding: 10px 16px; cursor: pointer; font-weight: 650; list-style: none; }
.hotspots summary::-webkit-details-marker { display: none; }
.hotspots summary::before { content: "▸"; display: inline-block; width: 16px; color: var(--muted); transition: transform .15s; }
.hotspots[open] summary::before { transform: rotate(90deg); }
.hotspot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 28px; padding: 0 16px 14px; }
.hs-title { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 6px; }
.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)); }

.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: 1fr; }
  .convo { position: static; height: 70vh; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-n { font-size: 22px; }
  .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: 56px; bottom: 0; left: 0; width: 260px; 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; }
  .topbar { gap: 8px; padding: 0 10px; }
  .search { margin-left: 0; }
  #new-ticket-btn { padding: 0 10px; }
  .main { padding: 14px 16px; }
  .fields { grid-template-columns: 1fr; }
  .call { inset: 0; border-radius: 0; }
  .call.minimized { inset: auto 8px 8px auto; width: 220px; height: 180px; border-radius: 12px; }
  .ctl { min-width: 0; }
}
