:root {
  --orange: #ff5a2f;
  --orange-dark: #df4420;
  --orange-soft: #fff0ea;
  --ink: #182027;
  --ink-soft: #26323a;
  --muted: #69727a;
  --faint: #979ea3;
  --line: #e7e3de;
  --paper: #ffffff;
  --canvas: #f5f3ef;
  --green: #24865a;
  --green-soft: #e9f6ef;
  --amber: #a56f11;
  --amber-soft: #fff6de;
  --red: #b93c31;
  --red-soft: #fff0ee;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
p, h1, h2, h3 { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 40px); line-height: 1.12; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.025em; }
h3 { margin-bottom: 0; font-size: 15px; }

.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; background: var(--orange); color: white; font-weight: 900; box-shadow: 0 7px 18px rgba(255,90,47,.2); }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 10px; font-weight: 850; letter-spacing: .18em; }

.login-view { min-height: 100vh; padding: 38px clamp(22px, 6vw, 84px); display: grid; grid-template-rows: auto 1fr auto; background: var(--ink); color: white; overflow: hidden; position: relative; }
.login-view::before { content: ""; position: absolute; inset: 0 0 auto auto; width: 48vw; height: 48vw; border: 1px solid rgba(255,255,255,.06); border-radius: 50%; transform: translate(28%, -34%); box-shadow: 0 0 0 80px rgba(255,255,255,.018), 0 0 0 160px rgba(255,255,255,.012); pointer-events: none; }
.login-view::after { content: "POST\A ESPORTS"; white-space: pre; position: absolute; left: 4vw; bottom: 8vh; color: rgba(255,255,255,.025); font-size: clamp(80px, 15vw, 220px); font-weight: 900; line-height: .73; letter-spacing: -.09em; pointer-events: none; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { letter-spacing: .05em; }
.login-brand small { margin-top: 4px; color: #7f8b92; font-size: 9px; letter-spacing: .13em; }
.login-card { position: relative; z-index: 1; width: min(440px, 100%); margin: auto; padding: clamp(28px, 4vw, 44px); border: 1px solid rgba(255,255,255,.12); border-radius: 22px; background: rgba(255,255,255,.06); box-shadow: 0 30px 80px rgba(0,0,0,.28); backdrop-filter: blur(18px); }
.login-card h1 { font-size: 36px; }
.login-copy { margin: 16px 0 28px; color: #aeb7bd; font-size: 13px; line-height: 1.75; }
.login-card .field > span { color: #cbd1d5; }
.login-card input { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.08); color: white; }
.login-card input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,90,47,.14); }
.login-card input::placeholder { color: #68747b; }
.login-button { width: 100%; margin-top: 7px; justify-content: space-between; }
.security-note { margin-top: 22px; padding-top: 18px; display: flex; gap: 10px; border-top: 1px solid rgba(255,255,255,.08); color: #7f8a90; }
.security-note > span { color: var(--green); }
.security-note p { margin: 0; font-size: 10px; line-height: 1.65; }
.login-footer { position: relative; z-index: 1; margin: 0; color: #606c73; font-size: 10px; letter-spacing: .05em; text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px 22px; display: flex; flex-direction: column; background: var(--ink); color: white; z-index: 10; }
.brand { margin: 0 8px 40px; display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand small { margin-top: 3px; color: #8a949a; font-size: 10px; }
nav { display: grid; gap: 6px; }
.nav-item { width: 100%; min-height: 46px; padding: 8px 10px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; border: 0; border-radius: 10px; background: transparent; color: #aeb5ba; cursor: pointer; text-align: left; transition: background .15s ease, color .15s ease; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.085); }
.nav-item.active { box-shadow: inset 3px 0 var(--orange); }
.nav-item b { font-size: 12px; font-weight: 650; }
.nav-item small { color: #657078; font-size: 9px; }
.nav-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: rgba(255,255,255,.06); font-size: 10px; font-weight: 800; }
.nav-item.active .nav-icon { background: var(--orange); }
.sidebar-note { margin-top: auto; padding: 14px; display: flex; gap: 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 11px; }
.sidebar-note small { margin-top: 4px; color: #89949a; font-size: 9px; line-height: 1.5; }
.status-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: #41c985; box-shadow: 0 0 0 4px rgba(65,201,133,.12); }

.main { min-width: 0; padding: 35px clamp(24px, 4vw, 58px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.operator { padding: 6px 10px 6px 6px; display: grid; grid-template-columns: 32px auto; column-gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; text-align: left; }
.operator span { width: 32px; height: 32px; grid-row: 1 / span 2; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; }
.operator strong { align-self: end; font-size: 11px; }
.operator small { align-self: start; color: var(--faint); font-size: 8px; }
.content { margin-top: 29px; }

.primary-button, .secondary-button, .ghost-button, .danger-button, .text-button { min-height: 38px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 9px; font-size: 11px; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease; }
.primary-button { border: 1px solid var(--orange); background: var(--orange); color: white; }
.primary-button:hover { background: var(--orange-dark); border-color: var(--orange-dark); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--ink); background: var(--ink); color: white; }
.ghost-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.ghost-button:hover { border-color: #beb8b0; }
.danger-button { border: 1px solid #e8c5c0; background: var(--red-soft); color: var(--red); }
.text-button { min-height: auto; padding: 4px; border: 0; background: transparent; color: var(--orange); }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); cursor: pointer; font-size: 22px; }
button:disabled { opacity: .55; cursor: wait; transform: none !important; }

.page-intro { margin-bottom: 17px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-intro p { max-width: 700px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.page-intro-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice { margin-bottom: 15px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 18px; border-left: 4px solid var(--orange); border-radius: 0 12px 12px 0; background: var(--orange-soft); }
.notice.success { border-color: var(--green); background: var(--green-soft); }
.notice.warning { border-color: #d0952e; background: var(--amber-soft); }
.notice strong { font-size: 13px; }
.notice p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.notice > span { padding: 5px 9px; border-radius: 999px; background: white; color: var(--orange); font-size: 9px; font-weight: 800; white-space: nowrap; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.stat-card { min-height: 128px; padding: 18px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; right: -26px; bottom: -34px; width: 74px; height: 74px; border: 14px solid #f8f6f3; border-radius: 50%; }
.stat-card p { margin-bottom: 17px; color: var(--muted); font-size: 10px; }
.stat-card strong { display: block; font-size: 27px; letter-spacing: -.04em; }
.stat-card small { color: var(--faint); font-size: 9px; }
.stat-card.accent { background: var(--orange); border-color: var(--orange); color: white; }
.stat-card.accent p, .stat-card.accent small { color: rgba(255,255,255,.72); }
.stat-card.accent::after { border-color: rgba(255,255,255,.09); }

.workspace-grid { margin-top: 13px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 13px; }
.panel { min-width: 0; padding: 21px; }
.panel-heading { margin-bottom: 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.panel-heading-actions { display: flex; gap: 7px; }
.quick-actions { display: grid; gap: 9px; }
.quick-action { width: 100%; padding: 13px; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; text-align: left; }
.quick-action:hover { border-color: #cfc9c2; }
.quick-action > span:first-child { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--orange-soft); color: var(--orange); font-size: 11px; font-weight: 900; }
.quick-action:nth-child(2) > span:first-child { background: var(--ink); color: white; }
.quick-action:nth-child(3) > span:first-child { background: var(--amber-soft); color: var(--amber); }
.quick-action:nth-child(4) > span:first-child { background: #e9f8fa; color: #197f91; }
.quick-action:nth-child(5) > span:first-child { background: #eee9ff; color: #6d4bc1; }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: 12px; }
.quick-action small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.quick-action b { color: #a0a5a8; }
.activity-list { display: grid; gap: 15px; }
.activity-item { display: grid; grid-template-columns: 9px 1fr; gap: 10px; }
.activity-item > span { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--green); }
.activity-item strong, .activity-item small { display: block; }
.activity-item strong { font-size: 11px; }
.activity-item small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.5; }

.toolbar { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toolbar-copy { color: var(--muted); font-size: 10px; }
.segmented { padding: 3px; display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: #ece9e4; }
.segmented button { padding: 7px 11px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 700; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(24,32,39,.08); }
.data-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 12px 15px; border-bottom: 1px solid var(--line); background: #faf9f7; color: var(--faint); font-size: 9px; font-weight: 750; letter-spacing: .04em; text-align: left; white-space: nowrap; }
td { padding: 14px 15px; border-bottom: 1px solid #efede9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdfcfb; }
.cell-title { max-width: 330px; }
.cell-title strong, .cell-title small { display: block; }
.cell-title strong { font-size: 11px; }
.cell-title small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; color: var(--muted); font-size: 9px; }
.legal-digest { display: block; max-width: 190px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.row-actions button { min-height: 30px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; font-size: 9px; }
.row-actions button:hover { border-color: #bdb7af; }
.row-actions button.danger { color: var(--red); }
.badge { padding: 4px 7px; display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; background: #f0efed; color: var(--muted); font-size: 9px; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.enabled, .badge.confirmed, .badge.completed, .badge.in_service { background: var(--green-soft); color: var(--green); }
.badge.disabled, .badge.cancelled, .badge.refunded { background: var(--red-soft); color: var(--red); }
.badge.pending_payment, .badge.refund_requested { background: var(--amber-soft); color: var(--amber); }
.badge.payment_review, .badge.refund_review { background: var(--red-soft); color: var(--red); }
.price-value { font-size: 12px; font-weight: 800; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { padding: 3px 6px; border-radius: 5px; background: #f2f0ed; color: var(--muted); font-size: 8px; }
.order-note { max-width: 220px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.order-note small { margin-top: 4px; display: block; color: var(--faint); }
.state-facts { margin-top: 6px; display: grid; gap: 2px; color: var(--faint); font-size: 8px; white-space: nowrap; }
.status-control { display: flex; gap: 5px; }
.status-control select { min-width: 110px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: white; font-size: 9px; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.category-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.category-card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.category-emoji { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--ink); font-size: 20px; }
.category-card h3 { margin-top: 13px; }
.category-card p { margin: 4px 0 13px; color: var(--muted); font-size: 9px; }
.category-card-footer { padding-top: 11px; display: flex; justify-content: space-between; border-top: 1px solid #efede9; color: var(--faint); font-size: 9px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.field small { color: var(--faint); font-size: 8px; }
.field input, .field textarea, .field select { width: 100%; min-height: 40px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; color: var(--ink); font-size: 11px; transition: border .12s ease, box-shadow .12s ease; }
.field textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.field textarea.legal-content-editor { min-height: 330px; font-family: "SFMono-Regular", Consolas, "PingFang SC", monospace; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.field input:disabled { background: #f1efeb; color: var(--faint); }
.switch-field { min-height: 54px; padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 9px; }
.switch-field strong, .switch-field small { display: block; }
.switch-field strong { font-size: 11px; }
.switch-field small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.switch-field input { width: 36px; height: 20px; accent-color: var(--orange); }
.form-actions { margin-top: 20px; padding-top: 17px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-error { min-height: 18px; margin: 8px 0 0; color: #e35d50; font-size: 10px; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 13px; }
.settings-aside { display: grid; align-content: start; gap: 10px; }
.settings-tip { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.settings-tip strong { font-size: 11px; }
.settings-tip p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.6; }

.modal-backdrop { position: fixed; inset: 0; padding: 28px; display: grid; place-items: center; background: rgba(15,20,24,.62); z-index: 50; backdrop-filter: blur(6px); }
.modal { width: min(720px, 100%); max-height: min(820px, calc(100vh - 56px)); overflow: auto; border-radius: 17px; background: white; box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.modal > header { position: sticky; top: 0; padding: 20px 22px 16px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); background: white; z-index: 1; }
.modal-body { padding: 22px; }
body.modal-open { overflow: hidden; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 12px 15px; border-radius: 10px; background: var(--ink); color: white; box-shadow: 0 14px 40px rgba(0,0,0,.25); font-size: 10px; line-height: 1.5; opacity: 0; transform: translateY(10px); pointer-events: none; z-index: 80; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.loading-state, .empty-state, .error-state { min-height: 260px; display: grid; place-items: center; padding: 30px; border: 1px solid var(--line); border-radius: 15px; background: white; color: var(--muted); font-size: 11px; text-align: center; }
.loading-state span { width: 24px; height: 24px; border: 2px solid #ddd8d1; border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-state div { display: grid; justify-items: center; gap: 12px; }
.empty-state strong, .error-state strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary-grid .stat-card:nth-child(4), .summary-grid .stat-card:nth-child(5) { grid-column: span 1; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { margin-inline: 6px; justify-content: center; }
  .brand > span:last-child, .nav-item b, .nav-item small, .sidebar-note div { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; }
  .sidebar-note { justify-content: center; }
  .workspace-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}

@media (max-width: 650px) {
  .login-view { padding: 24px 18px; }
  .login-card { padding: 26px 22px; }
  .app-shell { display: block; }
  .sidebar { position: sticky; width: auto; height: auto; padding: 10px 12px; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { margin: 0 10px 0 0; }
  .brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  nav { display: flex; }
  .nav-item { width: 38px; min-width: 38px; min-height: 38px; padding: 6px; }
  .sidebar-note { display: none; }
  .main { padding: 23px 15px 44px; }
  .topbar { align-items: flex-start; }
  .topbar-actions .ghost-button, .operator strong, .operator small { display: none; }
  .operator { display: block; padding: 5px; }
  .operator span { display: grid; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid .stat-card { grid-column: auto !important; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .page-intro-actions { width: 100%; }
  .page-intro-actions > * { flex: 1; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 1; white-space: nowrap; }
  .settings-aside { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 17px 17px 0 0; }
}
