:root {
  --bg: #FBF8F3; --panel: #FFFFFF; --soft: #F4EFE6; --ink: #0F1B2D; --muted: #4A5466; --faint: #7A8396; --line: #E6E0D4;
  --accent: #F2A93B; --accent-ink: #1A1206; --amber: #B86E0A; --ok: #1E7A46; --ok-bg: #E4F4EA; --warn: #8A5A00; --warn-bg: #FFF1D6;
  --bad: #B42318; --bad-bg: #FDE8E6; --info: #2B4C8C; --info-bg: #E6EDFA; --side: #0F1B2D; --side-ink: #E9E4DA;
  --r: 14px; --shadow: 0 1px 2px rgba(15,27,45,.06), 0 4px 16px rgba(15,27,45,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
.brand { font-family: 'Bricolage Grotesque', 'DM Sans', sans-serif; font-weight: 800; letter-spacing: -.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { font: inherit; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---------- sign-in pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-side { background: var(--side); color: var(--side-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { font-size: 28px; color: #fff; }
.auth-side .brand span { color: var(--accent); }
.auth-side h2 { font-size: 34px; line-height: 1.15; color: #fff; margin: 0 0 18px; letter-spacing: -.6px; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; }
.auth-side ul { padding: 0; margin: 0; list-style: none; display: grid; gap: 14px; }
.auth-side li { display: flex; gap: 12px; align-items: flex-start; color: #CFC8BB; }
.auth-side li b { color: #fff; font-weight: 600; }
.auth-side li i { flex: none; width: 26px; height: 26px; border-radius: 8px; background: rgba(242,169,59,.16); color: var(--accent); display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 13px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }
.auth-foot { margin-top: 18px; display: flex; gap: 6px; flex-wrap: wrap; color: var(--muted); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { padding: 28px 20px; } .auth-side h2 { font-size: 24px; } .auth-side ul { display: none; } }

/* ---------- forms ---------- */
label.f { display: block; margin: 0 0 14px; }
label.f > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
label.f > small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 5px; }
.in, select.in, textarea.in { width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid #D4CEC2; border-radius: 11px; background: #fff; color: var(--ink); font: inherit; font-size: 15.5px; }
textarea.in { min-height: 110px; resize: vertical; line-height: 1.5; }
.in:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(242,169,59,.35); }
.in[readonly] { background: var(--soft); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }
.code-in { letter-spacing: 10px; font-size: 26px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 11px; border: 0; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #1C2D45; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover { background: #E89B26; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid #CFC8BA; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #E8B4AE; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ok { background: var(--ok); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-weight: 600; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { color: #fff; font-size: 22px; padding: 4px 12px 2px; }
.side .brand span { color: var(--accent); }
.side .who { padding: 0 12px 14px; color: #A9B1BF; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.side .who b { display: block; color: #fff; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a[aria-current="page"] { background: rgba(242,169,59,.16); color: #fff; }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav a .n { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 12px; font-weight: 700; padding: 0 7px; line-height: 20px; }
.side .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head .muted { max-width: 680px; }
.topbar { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-102%); transition: transform .2s ease; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15,27,45,.45); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar .brand { font-size: 19px; } .topbar .brand span { color: var(--accent); }
  .topbar button { width: 44px; height: 44px; border: 0; background: transparent; color: #fff; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
  .main { padding: 20px 16px 60px; }
  h1 { font-size: 22px; }
}

/* ---------- cards, stats, tables ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flat { box-shadow: none; }
.card > .card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card > .card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .s { color: var(--faint); font-size: 12.5px; }
a.stat { text-decoration: none; color: inherit; transition: border-color .15s; }
a.stat:hover { border-color: var(--ink); }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #FCFAF6; }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- notices + steps ---------- */
.notice { border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; display: flex; gap: 12px; align-items: flex-start; border: 1px solid transparent; }
.notice.info { background: var(--info-bg); border-color: #C9D6F0; } .notice.warn { background: var(--warn-bg); border-color: #F2D59B; }
.notice.bad { background: var(--bad-bg); border-color: #F2C3BD; } .notice.ok { background: var(--ok-bg); border-color: #BFE3CD; }
.notice b { display: block; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 4px; counter-reset: s; }
.steps li { list-style: none; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; font-size: 13.5px; color: var(--muted); position: relative; }
.steps li b { display: block; color: var(--ink); font-size: 14px; }
.steps li.done { border-color: #BFE3CD; background: var(--ok-bg); }
.steps li.now { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(242,169,59,.25); }
.steps { padding: 0; }
@media (max-width: 700px) { .steps { grid-template-columns: 1fr 1fr; } }

/* ---------- docs list, templates ---------- */
.doc { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.doc:last-child { border-bottom: 0; }
.doc .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); flex: none; }
.doc .t { flex: 1; min-width: 0; } .doc .t b { display: block; } .doc .t span { color: var(--faint); font-size: 13px; }
.tpl { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.tpl .top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.tpl .top b { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.bubble { background: #FFF6E6; border: 1px solid #F3DDB5; border-radius: 4px 14px 14px 14px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 560px; font-size: 14.5px; }
.bubble .var { background: rgba(242,169,59,.35); border-radius: 4px; padding: 0 3px; }
.qr-btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.qr-btns span { border: 1px solid #E3D3B2; background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--amber); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

/* ---------- thread (tickets) ---------- */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.msg { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; max-width: 760px; }
.msg.staff { background: #F5F8FF; border-color: #D6E0F5; }
.msg.internal { background: #FFF8E8; border-color: #F2D59B; border-style: dashed; }
.msg .meta { font-size: 12.5px; color: var(--faint); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .meta b { color: var(--ink); }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- secret boxes ---------- */
.secret { display: flex; gap: 8px; align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.secret code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 13px; }
pre.code { background: #0F1B2D; color: #E9E4DA; padding: 14px 16px; border-radius: 12px; overflow-x: auto; font-size: 13px; line-height: 1.55; margin: 0 0 12px; }
pre.code .c { color: #8C97AA; }

/* ---------- modal + toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,27,45,.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { margin-bottom: 6px; }
.modal .acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .2s; z-index: 60; max-width: calc(100% - 32px); pointer-events: none; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.skeleton { color: var(--faint); padding: 30px 0; }
.qrbox { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qrbox > div { min-width: 0 !important; flex-basis: 220px; }
.qrbox canvas { width: 132px; height: 132px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--amber); }
