/* =====================================================================
   DialSupport - console, portal and landing page styles
   (c) Dialsoft LLC. American spelling used throughout (color, gray).
   ===================================================================== */
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --side: #0b1220;
  --side-2: #131c2e;
  --side-ink: #cbd5e1;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --urgent: #dc2626;
  --high: #ea580c;
  --normal: #2563eb;
  --low: #64748b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #f8fafc; border-color: #94a3b8; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(100,116,139,.12); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.ai { background: linear-gradient(135deg,#7c3aed,#2563eb); color: #fff; border: 0; }
.btn.ai:hover { filter: brightness(1.08); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=search], input[type=url], select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { resize: vertical; min-height: 80px; }
::placeholder { color: #a3adbb; font-style: italic; }
.invalid { border-color: var(--bad) !important; background: #fef2f2 !important; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
label.field { display: block; font-weight: 550; font-size: 12.5px; color: var(--ink-2); }
label.field > input, label.field > select, label.field > textarea { display: block; margin-top: 4px; }
label.field > .row, label.field > div { margin-top: 4px; }
label.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; overflow-y: auto; }
.side > * { flex-shrink: 0; }
.brandbar { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; color: #fff; font-weight: 750; font-size: 17px; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,#3b82f6,#7c3aed); display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; }
.desk-name { padding: 0 16px 12px; font-size: 12px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 1px; }
.nav .sect { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 12px 10px 4px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 7px 10px; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav a.active { background: #1e293b; color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav .count { margin-left: auto; background: #1e293b; color: #e2e8f0; border-radius: 999px; padding: 0 7px; font-size: 11.5px; font-weight: 650; min-width: 22px; text-align: center; }
.nav .count.hot { background: var(--bad); color: #fff; }
.nav .count.warm { background: var(--warn); color: #fff; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid #1e293b; font-size: 12.5px; }
.side-foot .row.wrap { gap: 6px; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 56px; }
.topbar .search { max-width: 420px; }
.content { flex: 1; overflow-y: auto; padding: 18px; }
.menu-toggle { display: none; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel > .hd h2, .panel > .hd h3 { margin: 0; }
.panel > .bd { padding: 14px; }
.panel + .panel { margin-top: 14px; }
.grid2 > .panel, .grid3 > .panel { margin-top: 0 !important; }
.grid2, .grid3 { margin-bottom: 14px; }
#page-title { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: default; }
.stat .n { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat.link { cursor: pointer; }
.stat.link:hover { border-color: var(--brand); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- Tables ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #f8fafc; position: sticky; top: 0; z-index: 1; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f8fafc; }
table.list tr.sel td { background: var(--brand-soft); }
.tsubj { font-weight: 600; color: var(--ink); }
.tmeta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.chip.status { color: #fff; }
.chip.tag { background: #f1f5f9; color: var(--ink-2); border-color: var(--line); }
.pri { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; text-transform: capitalize; }
.pri::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pri.urgent { color: var(--urgent); } .pri.high { color: var(--high); } .pri.normal { color: var(--normal); } .pri.low { color: var(--low); }
.sla { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.sla.ok { background: #dcfce7; color: #166534; }
.sla.soon { background: #fef3c7; color: #92400e; }
.sla.late { background: #fee2e2; color: #991b1b; }
.sla.paused { background: #e2e8f0; color: #334155; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #94a3b8; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 11.5px; flex: none; }
.src { font-size: 11px; color: var(--muted); text-transform: capitalize; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 13px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 11px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- Ticket detail ---------- */
.tk-layout { display: grid; grid-template-columns: 1fr 330px; gap: 14px; align-items: start; }
.tk-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.tk-head h1 { margin: 0; font-size: 20px; }
.tk-num { color: var(--muted); font-weight: 650; font-family: var(--mono); }
.msg { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 10px; }
.msg .mh { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.msg .mb { padding: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.contact { border-left: 3px solid #0ea5e9; }
.msg.agent { border-left: 3px solid var(--brand); }
.msg.note { background: #fffbeb; border-color: #fde68a; border-left: 3px solid #f59e0b; }
.msg.system { background: #f8fafc; border-style: dashed; }
.composer { border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; overflow: hidden; }
.composer.note { border-color: #f59e0b; background: #fffbeb; }
.composer textarea { border: 0; border-radius: 0; min-height: 130px; box-shadow: none !important; background: transparent; }
.composer .bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); background: rgba(248,250,252,.8); flex-wrap: wrap; }
.side-fields { display: flex; flex-direction: column; gap: 10px; }
.side-fields label.field select, .side-fields label.field input { padding: 6px 8px; }
.tasks li { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.tasks li.done span { text-decoration: line-through; color: var(--muted); }
.tasks { list-style: none; margin: 0; padding: 0; }
.activity { font-size: 12.5px; color: var(--ink-2); max-height: 280px; overflow: auto; }
.activity div { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.summary-box { background: linear-gradient(135deg,#f5f3ff,#eff6ff); border: 1px solid #ddd6fe; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; white-space: pre-wrap; }

/* ---------- Dispatch board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.lane { background: #e9eef5; border-radius: var(--radius); width: 280px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.lane .lh { padding: 10px 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lane .lb { padding: 0 8px 8px; overflow-y: auto; min-height: 80px; flex: 1; }
.lane.drop { outline: 2px dashed var(--brand); outline-offset: -2px; background: var(--brand-soft); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 7px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .4; }
.card .cs { font-weight: 600; font-size: 13px; }
.card .cm { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; height: calc(100vh - 110px); }
.chat-list { overflow-y: auto; }
.chat-item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-item:hover { background: #f8fafc; }
.chat-item.active { background: var(--brand-soft); }
.chat-win { display: flex; flex-direction: column; min-height: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f8fafc; }
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.visitor { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.agent { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.bubble .bt { font-size: 10.5px; opacity: .7; margin-top: 2px; }

/* ---------- Bar charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 4px; }
.bars .b i { display: block; border-radius: 3px 3px 0 0; }
.hbar { height: 10px; border-radius: 5px; background: var(--brand); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--c); vertical-align: -1px; }

/* ---------- Tooltip, toast, modal ---------- */
#tip { position: fixed; z-index: 9999; max-width: 340px; background: #0f172a; color: #f8fafc; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
#tip.show { opacity: 1; transform: none; }
#tip b { color: #93c5fd; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 9998; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; animation: tin .2s ease-out; }
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 9000; display: grid; place-items: center; padding: 16px; animation: tin .15s; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.modal .mhd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .mhd h2 { margin: 0; }
.modal .mbd { padding: 18px; }
.modal .mft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #f8fafc; }
.help-ico { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e2e8f0; color: #475569; font-size: 10.5px; font-weight: 800; cursor: help; margin-left: 4px; vertical-align: 1px; }
.notice { background: var(--brand-soft); border: 1px solid #bfdbfe; color: #1e3a8a; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }
.timerbar { display: inline-flex; align-items: center; gap: 8px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 4px 6px 4px 10px; border-radius: 8px; font-weight: 650; font-size: 12.5px; }
.timerbar .pulse { width: 8px; height: 8px; border-radius: 50%; background: #dc2626; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.kb-body h1, .kb-body h2, .kb-body h3 { margin-top: 1em; }
.kb-body { line-height: 1.65; }
.kb-body pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow: auto; }

/* ---------- Auth / landing ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at -10% -10%, #3b82f6 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #7c3aed 0%, transparent 55%), #0b1220;
  color: #e2e8f0; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 40px; color: #fff; letter-spacing: -.03em; line-height: 1.05; margin-bottom: 16px; }
.auth-hero p.lead { font-size: 17px; color: #cbd5e1; max-width: 520px; }
.feat { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; margin-top: 28px; max-width: 600px; }
.feat div { font-size: 13.5px; color: #cbd5e1; }
.feat b { display: block; color: #fff; font-size: 14px; margin-bottom: 2px; }
.auth-form { display: grid; place-items: center; padding: 32px; background: #fff; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 24px; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) { .tk-layout { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 8000; transform: translateX(-105%); transition: transform .2s; }
  body.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 32px 24px; }
  .auth-hero h1 { font-size: 30px; }
  .feat { grid-template-columns: 1fr; }
  table.list .hide-sm { display: none; }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .search { max-width: none; order: 10; flex-basis: 100%; }
  #page-title { flex: 1; }
  .tk-head { flex-direction: column; }
  .tk-head h1 { font-size: 18px; }
}

/* ---------- Reports library (reports.js) ---------- */
.rep-tools { gap: 10px; margin-bottom: 12px; align-items: flex-end; }
.rep-tools label.field.inline { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12.5px; font-weight: 600; margin: 0; }
.rep-tools label.field.inline input, .rep-tools label.field.inline select { width: auto; min-width: 150px; }
.rep-title { margin: 4px 0 12px; }
table.list tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); background: #f8fafc; }
table.list tr.low td { background: #fef2f2; }
.statement h3 { margin: 18px 0 6px; }
.print-only { display: none; }
@media print {
  @page { size: letter; margin: 0.5in; }
  body { background: #fff !important; }
  .side, .topbar, .no-print, #timer-bar, .toast, .tip { display: none !important; }
  .shell { display: block !important; }
  .main, .content { height: auto !important; overflow: visible !important; padding: 0 !important; }
  .print-only { display: block !important; }
  .rep-head { font-size: 11px; border-bottom: 1px solid #999; padding-bottom: 4px; margin-bottom: 8px; }
  .rep-title { font-size: 18px; }
  .panel, .stat { box-shadow: none !important; break-inside: avoid; }
  table.list { font-size: 11px; }
  table.list tr { break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  .statement { border: 0 !important; }
}
