:root {
  color-scheme: dark;
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", sans-serif;
  --bg: #0a1016;
  --surface: #111a23;
  --surface-highlight: #16232e;
  --border: #263544;
  --text: #edf4f6;
  --muted: #9bafbd;
  --mint: #a4fac8;
  --gold: #ffd489;
  --red: #ff9ca9;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--mint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: #1a2632; border: 1px solid #344658; border-radius: 7px; padding: 7px 13px; white-space: nowrap; cursor: pointer; color: var(--text); }
button:hover, .button:hover { background: #27384a; }
button:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
.primary { background: var(--mint); border-color: var(--mint); color: #10251b; font-weight: 650; }
.primary:not(:disabled):hover { background: #c5ffdd; }
.danger { color: var(--red); border-color: #69424a; background: #31202a; }
.small { padding: 5px 10px; font-size: .9em; }
.icon { width: 17px; height: 17px; vertical-align: middle; flex: none; }
.muted { color: var(--muted); }
.amount { color: var(--gold); font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-unit { font-size: .8em; font-weight: 500; }
.mono, code { font: .9em/1.55 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.copyable { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.break { overflow-wrap: anywhere; white-space: pre-wrap; }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 45% 15%, #173637, transparent 58%); }
.gate-card { width: min(460px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: 14px; background: #101b24; }
.gate-card h1 { margin-top: 26px; }
.layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }
.side { align-self: stretch; background: #0d151d; border-right: 1px solid var(--border); }
.side-inner { position: sticky; top: 0; padding: 24px 14px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand img { width: 38px; height: 38px; }
.brand strong { display: block; font-size: 20px; line-height: 1.2; }
.brand small { display: block; color: var(--muted); margin-top: 3px; }
.side .brand { margin: 0 7px 28px; }
.side nav { display: grid; gap: 6px; }
.side nav a { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 10px 12px; border: 1px solid transparent; border-radius: 8px; white-space: nowrap; }
.side nav a:hover { background: var(--surface); color: var(--text); }
.side nav a[aria-current="page"] { border-color: #375749; color: var(--mint); background: #1a302b; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px clamp(16px, 3vw, 44px); background: #0d151d; border-bottom: 1px solid var(--border); }
.topbar .row-actions { justify-content: flex-end; }
.staff-name { overflow-wrap: anywhere; }
.workspace { min-width: 0; }
main { max-width: 1600px; margin: auto; padding: 26px clamp(16px, 3vw, 44px) 56px; }
.page-head, .panel-head, .dialog-head, .room-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head { margin-bottom: 20px; flex-wrap: wrap; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p + p { margin-top: 8px; }
.gate-card p { margin: 10px 0 20px; }
.panel, .metric { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.panel + .panel { margin-top: 16px; }
.section-filters { padding: 13px 14px 0; }
.panel-head { padding: 14px 17px; border-bottom: 1px solid var(--border); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { display: grid; gap: 8px; padding: 15px 17px; color: var(--text); background: linear-gradient(120deg, #162630, #111a23 70%); }
a.metric:hover { border-color: var(--mint); }
.metric small { color: var(--muted); }
.metric strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.user-balance-overview dl { display: flex; flex-wrap: wrap; gap: 15px 30px; margin: 0; padding: 17px; }
.user-balance-overview dl > div { flex: 1 1 190px; min-width: 0; }
.user-balance-overview dt { color: var(--muted); }
.user-balance-overview dd { margin: 4px 0 0; font-size: clamp(17px, 2.3vw, 25px); }
.user-balance-overview dd .amount { white-space: normal; overflow-wrap: anywhere; }
.filters { container-type: inline-size; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0 0 14px; }
.filters .field { flex: 1 1 110px; min-width: min(110px, 100%); max-width: 142px; }
.filters .search { flex-basis: 150px; min-width: min(150px, 100%); max-width: 360px; }
.filters > .date-range { display: contents; container-type: normal; }
.filters .date-range-control { flex: 0 1 220px; min-width: min(218px, 100%); display: grid; gap: 6px; }
.filters .date-range-label { margin: 0; color: #bbcad4; font: inherit; font-weight: 550; }
.filters .date-range-trigger {
  width: 100%; flex-wrap: nowrap; gap: 6px; padding: 6px 9px; border-color: #384b5b;
  border-radius: 6px; background: #0b141c; line-height: 1.4; white-space: nowrap;
}
.filters .date-range-icon { flex: 0 0 16px; margin-inline-start: auto; }
.filters .date-range-panel { flex: 0 0 min(100%, 760px); order: 1; margin-top: 0; }
.filter-buttons { display: flex; gap: 6px; }
.filter-buttons button { padding-inline: 9px; }
.filters input, .filters select, .filters .date-range-trigger, .filter-buttons button { height: 36px; min-height: 36px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, legend { color: #bbcad4; font-weight: 550; }
.required { color: var(--red); margin-left: 4px; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid #384b5b; border-radius: 6px; background: #0b141c; }
textarea { min-height: 78px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #879cae; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 14px; vertical-align: middle; }
th { background: #151f29; color: #b1c1cc; white-space: nowrap; font-size: .92em; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #15212b; }
td:first-child { min-width: 140px; }
td .row-actions { flex-wrap: nowrap; }
td details { min-width: 135px; }
td small { display: block; color: var(--muted); }
.table-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); }
.badge { display: inline-flex; align-items: center; border-radius: 5px; padding: 3px 8px; color: #c1d2dc; background: #263340; font-size: .88em; white-space: nowrap; }
.badge.active, .badge.confirmed, .badge.completed { color: var(--mint); background: #1e392f; }
.badge.refunded { color: #b8ddff; background: #223c55; }
.badge.pending, .badge.disputed, .badge.manual_review, .badge.reserved, .badge.funded, .badge.delivered { color: var(--gold); background: #3b3023; }
.badge.failed, .badge.disabled, .badge.deleted { color: var(--red); background: #412933; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.error { color: var(--red); }
.notice { padding: 12px 14px; border: 1px solid #775f38; border-radius: 7px; background: #33291d; color: var(--gold); }
dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; border: 1px solid #40566a; border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 18px 80px #000a; }
dialog::backdrop { background: #04070ccc; }
.dialog-head { position: sticky; top: 0; padding: 13px 18px; border-bottom: 1px solid var(--border); background: var(--surface); z-index: 1; }
.dialog-body { padding: 18px; }
.form-stack { display: grid; gap: 13px; }
.form-stack > .row-actions { justify-content: flex-end; }
.form-error:empty { display: none; }
.datum { display: grid; grid-template-columns: minmax(90px, 145px) minmax(0, 1fr); gap: 9px 12px; margin: 0; }
.datum dt { color: var(--muted); }
.datum dd { margin: 0; overflow-wrap: anywhere; }
.dialog-body .datum { margin-bottom: 14px; }
.form-section { border: 1px solid var(--border); border-radius: 7px; padding: 15px; margin: 0; }
.form-section legend { padding: 0 7px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 960px; }
.settings-grid > .settings-footer { grid-column: 1 / -1; }
.toggle { display: flex; align-items: center; gap: 10px; }
.toggle input { width: 17px; height: 17px; accent-color: var(--mint); margin: 0; }
.rooms { display: grid; grid-template-columns: minmax(183px, 270px) minmax(0, 1fr); min-height: 482px; }
.room-list { border-right: 1px solid var(--border); padding: 10px; max-height: 680px; overflow: auto; }
.room-choice { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; white-space: normal; justify-content: initial; text-align: left; background: transparent; border-color: transparent; margin-bottom: 5px; }
.room-choice[aria-current="true"] { background: #1b3530; border-color: #3e6154; }
.room-choice strong, .room-choice small { display: block; overflow-wrap: anywhere; }
.room-choice small { margin-top: 3px; color: var(--muted); }
.room-pane { display: grid; grid-template-rows: auto minmax(240px, 1fr) auto; min-width: 0; }
.room-pane > .empty { align-self: center; grid-row: 1 / -1; }
.room-head { padding: 12px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.room-head div { min-width: 0; overflow-wrap: anywhere; }
.room-head small { color: var(--muted); }
.messages { height: clamp(250px, 46vh, 565px); overflow: auto; padding: 15px; }
.messages > .row-actions { justify-content: center; }
.message { margin: 0 0 12px; width: fit-content; max-width: min(92%, 560px); }
.message.own { margin-left: auto; }
.message b { display: block; font-weight: 500; color: var(--muted); margin-bottom: 4px; font-size: .9em; }
.message-box { padding: 8px 11px; background: #1e2d3b; border-radius: 7px; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.own .message-box { background: #1e3931; }
.message-box:has(> .shared-order) { padding: 0; background: transparent; }
.shared-order { display: grid; gap: 6px; text-align: left; white-space: normal; border-color: #716143; background: #262921; }
.shared-order > span, .shared-order > small { color: var(--muted); }
.shared-order .icon { vertical-align: middle; }
.preserve-lines { white-space: pre-wrap; }
.bug-screenshots > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin-top: 8px; }
.bug-screenshot { padding: 2px; cursor: zoom-in; }
.bug-screenshot img { display: block; width: 100%; height: 100px; object-fit: contain; }
.message .thumb { display: block; margin-top: 7px; padding: 3px; background: #141d27; }
.thumb img { display: block; max-height: 130px; max-width: 100%; object-fit: contain; }
.composer { padding: 12px 16px; display: grid; gap: 8px; border-top: 1px solid var(--border); }
.composer .row-actions { justify-content: space-between; }
.file-picker { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; background: #1b2b39; border: 1px dashed #527184; border-radius: 7px; cursor: pointer; }
.file-picker:focus-within { outline: 2px solid var(--mint); }
.file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.attachment { display: flex; align-items: center; gap: 10px; color: var(--muted); overflow-wrap: anywhere; }
.attachment img { max-width: 68px; max-height: 54px; border-radius: 5px; }
.verdict { padding: 13px 17px; border-top: 1px solid var(--border); background: #20251f; }
#admin-image { width: min(1020px, calc(100% - 24px)); }
.image-stage { display: grid; place-items: center; padding: 16px; }
.image-stage img { display: block; max-width: 100%; max-height: 75dvh; object-fit: contain; }
#alerts { position: fixed; bottom: 16px; right: 16px; z-index: 4; max-width: min(410px, calc(100% - 32px)); }
.toast { padding: 11px 14px; margin-top: 8px; border: 1px solid #527362; border-radius: 8px; background: #1c3429; box-shadow: 0 6px 16px #0008; }
.toast.error { border-color: #88434f; background: #39232c; }
@media (max-width: 860px) {
  .layout { display: block; }
  .side { border-right: 0; border-bottom: 1px solid var(--border); }
  .side-inner { position: static; padding: 12px 14px 8px; }
  .side .brand { margin: 0 0 8px; }
  .side nav { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .side nav a { padding: 7px 10px; }
}
@media (max-width: 590px) {
  .rooms, .settings-grid { grid-template-columns: 1fr; }
  .room-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 170px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric strong { font-size: 20px; }
  .topbar { font-size: 12px; }
  .topbar .button, .topbar button { padding: 4px 8px; }
  .message { max-width: 96%; }
}
