/* Ticket desk — one stylesheet for both the public portal and the agent UI.
   Colours come from custom properties so a per-site accent is a one-line
   override. Light and dark both defined; dark follows the OS. */

:root {
  --accent: #2f6df6;
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f5f6f8;
  --surface: #fff;
  --surface-2: #fafbfc;
  --ink: #161b26;
  --ink-2: #4a5265;
  --ink-3: #7a8194;
  --line: #e3e6ec;
  --line-2: #eef0f4;
  --ok: #17794a; --ok-bg: #e7f6ee;
  --warn: #8a5a08; --warn-bg: #fdf3e0;
  --danger: #b3261e; --danger-bg: #fdecea;
  --info: #1c5b9c; --info-bg: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow-lg: 0 4px 16px rgba(16,24,40,.10);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10131a; --surface: #171b24; --surface-2: #1c212c;
    --ink: #e8eaf0; --ink-2: #a9b0c0; --ink-3: #7b8296;
    --line: #262c39; --line-2: #1f2530;
    --ok: #6ede9f; --ok-bg: #12301f;
    --warn: #f0c069; --warn-bg: #31240d;
    --danger: #f79e96; --danger-bg: #3a1512;
    --info: #86b8ee; --info-bg: #11263a;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 6px 20px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---- layout ------------------------------------------------------------- */
.wrap { max-width: 44rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.wrap-wide { max-width: 78rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
}
.card + .card { margin-top: 1rem; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); font-size: .875rem; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- brand header ------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; }
.brand img { max-height: 38px; width: auto; }
.brand-name { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }
.brand a { color: inherit; }

/* ---- forms -------------------------------------------------------------- */
label { display: block; font-weight: 560; font-size: .9rem; margin-bottom: .35rem; }
.field { margin-bottom: 1.15rem; }
.field .hint { font-size: .84rem; color: var(--ink-3); margin-top: .35rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .7rem; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 8.5rem; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
  linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: right 1rem center, right .72rem center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }

/* The honeypot. Hidden from people, present in the DOM for bots. */
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px;
      overflow: hidden; opacity: 0; pointer-events: none; }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 560; line-height: 1.2;
  padding: .62rem 1.05rem; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer; transition: filter .12s, box-shadow .12s;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { filter: brightness(.95); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: transparent; padding: .4rem .6rem; }
.btn-quiet:hover { background: var(--line-2); filter: none; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-danger { background: var(--danger); color: #fff; }

/* ---- notices ------------------------------------------------------------ */
.notice { padding: .8rem 1rem; border-radius: 8px; font-size: .93rem; margin-bottom: 1rem;
          border: 1px solid transparent; }
.notice-ok     { background: var(--ok-bg);     color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.notice-warn   { background: var(--warn-bg);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice-info   { background: var(--info-bg);   color: var(--info);   border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.notice ul { margin: .4rem 0 0; padding-left: 1.1rem; }

/* ---- pills -------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; letter-spacing: .01em;
  padding: .18rem .55rem; border-radius: 100px; white-space: nowrap;
  background: var(--line-2); color: var(--ink-2);
}
.pill-new      { background: var(--info-bg);   color: var(--info); }
.pill-open     { background: var(--warn-bg);   color: var(--warn); }
.pill-pending  { background: var(--line-2);    color: var(--ink-2); }
.pill-resolved { background: var(--ok-bg);     color: var(--ok); }
.pill-closed   { background: var(--line-2);    color: var(--ink-3); }
.pill-urgent, .pill-high { background: var(--danger-bg); color: var(--danger); }
.pill-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
                    background: currentColor; display: inline-block; }
.ref { font-family: var(--mono); font-size: .82rem; color: var(--ink-3); letter-spacing: -.02em; }

/* ---- thread ------------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 1rem; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.msg-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
            padding: .6rem .95rem; border-bottom: 1px solid var(--line-2);
            background: var(--surface-2); font-size: .85rem; }
.msg-who { font-weight: 600; color: var(--ink); }
.msg-body { padding: .95rem; overflow-wrap: anywhere; }
.msg-agent { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.msg-agent .msg-head { background: var(--accent-soft); }
.msg-internal { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.msg-internal .msg-head { background: var(--warn-bg); color: var(--warn); }
.msg-system { border-style: dashed; background: transparent; }
.msg-system .msg-body { color: var(--ink-3); font-size: .88rem; }
.attach-list { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .95rem .95rem; }
.attach {
  display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: .3rem .6rem; color: var(--ink-2);
}
.attach:hover { border-color: var(--accent); text-decoration: none; }

/* ---- agent shell -------------------------------------------------------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand-name { font-size: .98rem; }
.topbar nav { display: flex; gap: .3rem; margin-left: auto; align-items: center; }
.topbar nav a { color: var(--ink-2); font-size: .9rem; padding: .35rem .65rem; border-radius: 6px; }
.topbar nav a:hover { background: var(--line-2); text-decoration: none; }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 560; }

.shell { display: grid; grid-template-columns: 15rem 1fr; gap: 1.25rem;
         max-width: 84rem; margin: 0 auto; padding: 1.25rem; align-items: start; }
@media (max-width: 62rem) { .shell { grid-template-columns: 1fr; } .side { order: 2; } }

.side { position: sticky; top: 4.2rem; }
.side-group { margin-bottom: 1.25rem; }
.side-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
              color: var(--ink-3); font-weight: 650; margin: 0 0 .45rem .6rem; }
.side a {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .42rem .6rem; border-radius: 7px; color: var(--ink-2); font-size: .92rem;
}
.side a:hover { background: var(--line-2); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .n { font-size: .78rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.side a.on .n { color: inherit; }

/* ---- queue -------------------------------------------------------------- */
.queue { background: var(--surface); border: 1px solid var(--line);
         border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.qrow { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--line-2); color: inherit; }
.qrow:last-child { border-bottom: 0; }
.qrow:hover { background: var(--surface-2); text-decoration: none; }
.qrow-unanswered { box-shadow: inset 3px 0 0 var(--accent); }
.qrow-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.qrow-subject { font-weight: 600; }
.qrow-meta { font-size: .84rem; color: var(--ink-3); display: flex; gap: .5rem; flex-wrap: wrap; }
.qrow-preview { font-size: .88rem; color: var(--ink-2); margin-top: .25rem; }
.empty { padding: 3.5rem 1.5rem; text-align: center; color: var(--ink-3); }

/* ---- ticket detail ------------------------------------------------------ */
.detail { display: grid; grid-template-columns: 1fr 17rem; gap: 1.25rem; align-items: start; }
@media (max-width: 68rem) { .detail { grid-template-columns: 1fr; } }
.meta-box { background: var(--surface); border: 1px solid var(--line);
            border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.meta-box + .meta-box { margin-top: 1rem; }
.meta-row { display: flex; justify-content: space-between; gap: .6rem;
            padding: .35rem 0; font-size: .88rem; border-bottom: 1px solid var(--line-2); }
.meta-row:last-child { border-bottom: 0; }
.meta-row .k { color: var(--ink-3); }
.meta-row .v { text-align: right; overflow-wrap: anywhere; }

.composer { margin-top: 1.25rem; }
.composer-tabs { display: flex; gap: .3rem; margin-bottom: .6rem; }
.composer-tabs button { font: inherit; font-size: .88rem; font-weight: 560; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink-3);
  padding: .35rem .75rem; border-radius: 7px; }
.composer-tabs button.on { background: var(--surface); border-color: var(--line); color: var(--ink); }

table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th { text-align: left; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-3); padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
table.grid td { padding: .55rem .6rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }

.pager { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; }
footer.desk-foot { text-align: center; padding: 2rem 1rem; color: var(--ink-3); font-size: .83rem; }
