/* TicketDesk — POP Telecom brand
   Plum #2c1336 · POP Pink #EC1A61 · Editorial off-white canvas
   Display: Bricolage Grotesque · Body: Hanken Grotesk */

:root {
  --plum: #2c1336;
  --plum-soft: #3d1f4b;
  --pink: #EC1A61;
  --pink-soft: #fde8f0;
  --canvas: #faf7f2;
  --card: #ffffff;
  --ink: #241430;
  --muted: #7c6f86;
  --line: #e9e2da;
  --ok: #1d7a4f;
  --ok-soft: #e3f3ea;
  --warn: #9a6b00;
  --warn-soft: #fdf3d7;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.55 "Hanken Grotesk", system-ui, sans-serif;
}
h1, h2, h3, .brand, .stat-n {
  font-family: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
}
h1 { font-size: 1.5rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
a { color: var(--pink); }
code { background: var(--pink-soft); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; }

/* ── Top bar ─────────────────────────────────────────────────────── */
.topbar {
  background: var(--plum);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  height: 56px;
}
.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-tick { color: var(--pink); font-weight: 800; margin-right: 2px; }
.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}
.topbar nav a:hover { color: #fff; background: var(--plum-soft); }
.topbar nav a.on { color: #fff; background: var(--pink); }
.who { font-size: 0.85rem; color: rgba(255,255,255,0.85); }
.who .logout { color: #fff; opacity: 0.7; margin-left: 0.75rem; }

/* ── Layout ──────────────────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.bare-main { max-width: none; padding: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.grid-main { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.25rem; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
@media (max-width: 900px) {
  .grid-2, .grid-main, .row-2, .row-3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 0.6rem 1rem; gap: 0.5rem; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ── Stats ───────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
.stat:hover { border-color: var(--pink); }
.stat-n { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat-hot { border-color: var(--pink); background: var(--pink-soft); }
.stat-hot .stat-n { color: var(--pink); }

/* ── Tables ──────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--line); }
td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.row-off { opacity: 0.55; }
.err-text { color: var(--err); font-size: 0.8rem; }

/* Ticket-stub reference — the signature element */
.ref {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--plum);
  color: #fff;
  text-decoration: none;
  padding: 0.18rem 0.55rem 0.18rem 0.8rem;
  border-radius: 3px;
  position: relative;
  white-space: nowrap;
}
.ref::before {
  content: "";
  position: absolute;
  left: 0.28rem; top: 50%;
  transform: translateY(-50%);
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--canvas);
  box-shadow: 0 0 0 1.5px var(--pink) inset;
}
a.ref:hover { background: var(--pink); }
.ref-big { font-size: 1rem; margin-right: 0.4rem; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 0.12rem 0.55rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; }
.st-open     { background: var(--pink-soft); color: var(--pink); }
.st-pending  { background: var(--warn-soft); color: var(--warn); }
.st-resolved { background: var(--ok-soft); color: var(--ok); }
.st-closed   { background: #eee7f0; color: var(--muted); }
.pr-low      { background: #eef1f4; color: #5a6b7b; }
.pr-normal   { background: #e8effa; color: #2a5da8; }
.pr-high     { background: var(--warn-soft); color: var(--warn); }
.pr-urgent   { background: var(--err-soft); color: var(--err); }
.tk-none     { background: #eee7f0; color: var(--muted); }
.tk-queued   { background: var(--warn-soft); color: var(--warn); }
.tk-created  { background: var(--ok-soft); color: var(--ok); }
.tk-failed   { background: var(--err-soft); color: var(--err); }

/* ── Forms ───────────────────────────────────────────────────────── */
label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.8rem; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 1px;
  border-color: var(--pink);
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { width: auto; margin: 0; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; }
.inline-form input { margin: 0; }
.filter-bar { display: flex; gap: 0.6rem; align-items: center; padding: 0.8rem 1rem; }
.filter-bar input, .filter-bar select { margin: 0; width: auto; flex: 1; }
.filter-bar input[name="q"] { flex: 2; }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--plum); }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:hover { background: #d0114f; border-color: #d0114f; }
.btn-small { padding: 0.25rem 0.7rem; font-size: 0.8rem; }

/* ── Flashes ─────────────────────────────────────────────────────── */
.flash { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 600; font-size: 0.9rem; }
.flash-ok   { background: var(--ok-soft); color: var(--ok); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.flash-err  { background: var(--err-soft); color: var(--err); }

/* ── Ticket conversation ─────────────────────────────────────────── */
.msg { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 0.8rem; overflow: hidden; }
.msg-meta { padding: 0.45rem 0.8rem; font-size: 0.8rem; background: var(--canvas); border-bottom: 1px solid var(--line); }
.msg-body { padding: 0.8rem; white-space: normal; }
.msg-reply  { border-left: 3px solid var(--pink); }
.msg-note   { border-left: 3px solid var(--warn); background: #fffdf6; }
.msg-system { border-left: 3px solid var(--muted); }
.mail-sent   { color: var(--ok); font-weight: 700; }
.mail-queued { color: var(--warn); font-weight: 700; }
.mail-failed { color: var(--err); font-weight: 700; }

.picked { background: var(--ok-soft); color: var(--ok); padding: 0.6rem 0.9rem; border-radius: 8px; margin-top: 0.8rem; font-size: 0.9rem; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.88rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

.muted { color: var(--muted); }

/* ── Auth screens ────────────────────────────────────────────────── */
.bare { background: var(--plum); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; margin: 0; }
.auth-brand { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.2rem; margin-bottom: 0.75rem; }
.auth-card h1 { font-size: 1.2rem; margin-bottom: 1rem; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .stat, .topbar nav a { transition: background 0.15s, border-color 0.15s, color 0.15s; }
}

/* ── Affinity console ──────────────────────────────────────────────── */
.api-group summary { cursor: pointer; list-style: none; }
.api-group summary::-webkit-details-marker { display: none; }
.api-group summary::before { content: "▸ "; color: var(--pink); }
.api-group[open] summary::before { content: "▾ "; }
.api-action {
  border-top: 1px solid rgba(44, 19, 54, 0.1);
  padding: 1rem 0 1.1rem;
  margin-top: 0.9rem;
}
.api-action h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.api-action form { margin-top: 0.5rem; }
.api-param { display: block; margin: 0.45rem 0; font-size: 0.85rem; font-weight: 600; }
.api-param input[type=text], .api-param textarea {
  display: block; width: 100%; max-width: 560px; margin-top: 0.2rem;
  font-weight: 400; font-family: inherit;
  padding: 0.45rem 0.6rem; border: 1.5px solid rgba(44,19,54,0.25); border-radius: 8px;
  background: #fff;
}
.api-param textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.api-confirm { display: block; margin: 0.5rem 0; font-size: 0.85rem; color: #8a1c1c; font-weight: 600; }
.badge-ok    { background: #e2f5e9; color: #1c6b3c; }
.badge-danger{ background: #fbe3e3; color: #8a1c1c; }
.btn-ghost   { background: transparent; color: var(--plum); border: 1.5px solid rgba(44,19,54,0.3); }
.codeblock {
  background: #2c1336; color: #f5edf8; border-radius: 10px;
  padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.78rem; max-height: 420px;
}
.table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; }
.table th, .table td { text-align: left; padding: 0.35rem 0.6rem; border-bottom: 1px solid rgba(44,19,54,0.08); font-size: 0.85rem; }
.table th { color: var(--plum); }

/* ── Customer verification ─────────────────────────────────────────── */
.verify-box {
  margin-top: 1rem; padding: 1rem 1.1rem; border-radius: 12px;
  background: var(--pink-soft); border: 1.5px solid rgba(236, 26, 97, 0.25);
}
.verify-box h3 { margin: 0 0 0.3rem; }
.row-on td { background: var(--pink-soft); }
.perm-table .perm-col { width: 110px; text-align: center; }
.perm-table input[type=checkbox] { width: 18px; height: 18px; }

/* System43 cross-app switcher */
.s43-switch{display:flex;align-items:center;gap:4px;margin-right:18px;padding-right:18px;border-right:1px solid rgba(255,255,255,.18)}
.s43-switch .s43-label{font-size:11px;letter-spacing:.1em;text-transform:uppercase;opacity:.6;margin-right:6px}
.s43-switch a{font-size:13px;padding:4px 10px;border-radius:999px;color:inherit;text-decoration:none;opacity:.8}
.s43-switch a:hover{opacity:1;background:rgba(255,255,255,.12)}
.s43-switch a.on{background:#EC1A61;color:#fff;opacity:1}
