:root {
  color-scheme: dark;
  --base: #050811;
  --side: #0a1220;
  --card: #0d1425;
  --card-high: #101d30;
  --border: #223851;
  --rule: #24364a;
  --text: #f3f6fc;
  --muted: #b2c0d3;
  --quiet: #8fa4be;
  --gold: #eab949;
  --gold-text: #ffd477;
  --cyan: #38bdf8;
  --cyan-text: #61e6f6;
  --danger: #ffaba8;
  --radius: 12px;
  font: 16px/1.5 "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--base);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button, a.download {
  background: #152539;
  color: var(--text);
  border: 1px solid #38516c;
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover, a.download:hover { background: #1e344e; }
button:disabled { opacity: .57; cursor: wait; }
:where(button, input, select, textarea, summary, a):focus-visible {
  outline: 2px solid var(--gold-text);
  outline-offset: 3px;
}
a.download { display: inline-block; text-decoration: none; }
.icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.workspace { min-height: 100vh; }
.workspace.signed-in { display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.workspace-main { min-width: 0; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 23px 11px 22px;
  background: linear-gradient(165deg, #0d1624, #0a1424 76%, #0d1b2e);
  border-right: 1px solid #1c2c41;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 13px; }
.sidebar .brand { padding: 0 12px; margin-bottom: 33px; }
.brand img { flex: none; object-fit: contain; }
.brand strong, .brand span { display: block; white-space: nowrap; }
.brand strong { color: var(--gold-text); font-size: 27px; font-weight: 750; letter-spacing: .06em; }
.brand span { font-size: 15px; color: var(--muted); letter-spacing: .04em; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar .nav-button {
  display: flex;
  align-items: center;
  gap: 19px;
  min-height: 56px;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 9px;
  padding: 9px 17px;
  background: transparent;
  font-weight: 570;
  font-size: 19px;
}
.sidebar .nav-button:hover { background: #17273b; }
.sidebar .nav-button[aria-current="page"] {
  border-color: var(--gold-text);
  background: linear-gradient(100deg, #735a33, #2c2824 85%);
  color: #fff8ea;
}
.sidebar .nav-button[aria-current="page"] .icon { color: #ffe8ae; }
.sidebar-profile {
  margin: auto 10px 4px;
  padding-top: 26px;
  display: flex;
  gap: 11px;
  align-items: center;
  min-width: 0;
}
.profile-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: none;
  background: #4b3b22;
  border-radius: 50%;
  color: var(--gold-text);
}
.sidebar-profile strong,.sidebar-profile div > span { display: block; overflow-wrap: anywhere; }
.sidebar-profile div > span { color: var(--muted); font-size: 13px; }
.topbar {
  min-height: 69px;
  padding: 11px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
  background: #080e19;
  border-bottom: 1px solid #1a283a;
}
.topbar .brand strong { font-size: 21px; }
.topbar .brand span { font-size: 13px; }
.topbar-date {
  margin-left: auto;
  min-width: max-content;
  padding: 0 17px;
  border-left: 1px solid #40516a;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#logout { margin-left: 0; white-space: nowrap; }
#menuToggle { display: none; }
.workspace-search {
  min-width: 0;
  width: min(592px, 100%);
  display: flex;
  align-items: stretch;
  background: #101d2e;
  border: 1px solid #405570;
  border-radius: 12px;
  overflow: hidden;
}
.workspace-search :is(select, input, button) { min-height: 38px; border: 0; background-color: transparent; border-radius: 0; margin: 0; }
.workspace-search select { flex: 0 0 68px; width: 68px; padding: 2px 7px; color: var(--muted); }
.workspace-search input { min-width: 0; padding: 3px 8px; }
.workspace-search button { border: 0; display: grid; place-items: center; padding: 3px 12px; }
.workspace-search button .icon { width: 20px; height: 20px; }
.search-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.content { margin: 0 auto; padding: 0 24px 26px; max-width: 1720px; }
#status:empty { display: none; }
#status {
  margin: 12px 0;
  padding: 9px 12px;
  background: #142738;
  border: 1px solid #284158;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
#status[aria-invalid="true"], #dialogStatus { color: var(--danger); }
#status[aria-invalid="true"] { background: #311d2a; border-color: #623c4a; }
h1 { font-size: clamp(27px, 4vw, 38px); margin: 18px 0; line-height: 1.16; }
h2 { font-size: 19px; margin: 0 0 14px; }
article, #signin, dialog {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
article { margin: 0 0 14px; min-width: 0; }
#signin { max-width: 460px; margin: 10vh auto 24px; }
#signin h1 { margin: 0 0 20px; }
#signin button, .primary-button { background: linear-gradient(180deg,#f8d78b,#e3ad41); color: #191109; border-color: #f1c765; font-weight: 700; }
#signin button:hover, .primary-button:hover { background: #ffe4a5; }
#subnav, .heading, .actions { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
#subnav { margin-top: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
#subnav button[aria-current="page"] { color: var(--gold-text); border-color: var(--gold); background: #372c21; }
.heading { justify-content: space-between; }
.heading h2 { margin: 0; }
.actions { justify-content: flex-end; margin: 18px 0; }
.grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
.form-grid,.rule-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,230px),1fr)); gap: 14px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 10px 0; padding: 4px 12px 12px; min-width: 0; }
legend { font-weight: 700; padding: 0 5px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; margin: 10px 0; }
.check { display: flex; align-items: center; }
.check input { width: auto; }
input, textarea, select { min-width: 0; padding: 9px; border: 1px solid #435a74; border-radius: 5px; width: 100%; color: var(--text); background: #0a1423; }
input::placeholder { color: #9aadc5; }
input[readonly] { background: #172739; }
textarea { resize: vertical; }
.filters { display:flex; align-items:end; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.filters label { flex:1 1 155px; margin:0; }
#finance article > label { max-width: 240px; }
.result { background: #102235; padding: 12px; margin: 14px 0; overflow-wrap: anywhere; }
.table-scroll, #paymentHistory, .result, .recent-wrap { overflow-x: auto; }
.table-scroll { margin: 12px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 12px; border: 1px solid var(--rule); text-align: left; }
th { background: #152439; white-space: nowrap; }
details { border-bottom: 1px solid var(--rule); padding: 10px 0; overflow-wrap: anywhere; }
summary { cursor: pointer; }
.line { padding: 10px 0; border-bottom: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow-wrap: anywhere; }
.line button { flex-shrink: 0; }
.record-actions { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
dialog { max-width: min(565px,96vw); width: 100%; color: var(--text); max-height: 94dvh; }
dialog::backdrop { background: #040b17ba; }
#sensitive, #summary { white-space: pre-line; overflow-wrap: anywhere; }

.overview { padding-top: 3px; font-variant-numeric: tabular-nums; }
.overview-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 10px 0 16px; }
.overview-heading h1 { margin: 0; font-size: clamp(33px,3vw,45px); font-weight: 800; letter-spacing: .015em; }
.overview-heading p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.overview-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.day-label { border: 1px solid #41536d; border-radius: 8px; padding: 7px 10px; color: var(--muted); font-size: 14px; }
.subtle-button { background: #0c1525; color: var(--text); }
.overview-status { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; color: var(--muted); }
.metric-grid, .overview-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.metric-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.metric, .overview-card {
  margin: 0;
  border: 1px solid var(--border);
  background: linear-gradient(153deg,#101e32 0%,#0d192b 48%,#0b1526 100%);
}
.metric { min-height: 132px; padding: 13px 16px 11px; position: relative; }
.metric h2 { display:flex; align-items:center; gap: 9px; margin: 0 0 7px; font-size: 17px; min-height: 26px; }
.metric .icon { color: var(--gold-text); }
.metric.cyan .icon { color: var(--cyan-text); }
.metric p { margin: 0; }
.metric-value { color: var(--gold-text); font-size: clamp(24px,2.5vw,41px); font-weight: 790; line-height: 1.07; letter-spacing: -.025em; overflow-wrap: anywhere; }
.metric.cyan .metric-value { color: var(--cyan-text); }
.metric .metric-note { color: var(--muted); margin-top: 8px; font-size: 14px; }
.metric .unknown-payments { margin-top: 2px; font-size: 12px; color: #e5c891; }
.metric-unit { margin-left: 6px; font-size: 16px; font-weight: 650; }
.metric .metric-link { position: absolute; bottom: 9px; right: 10px; }
.metric:has(.metric-link:not([hidden])) .metric-note { padding-right: 43px; }
#salesSparkline { width: 72px; height: 32px; position: absolute; right: 10px; top: 42px; }
.metric:has(#salesSparkline:not([hidden])) .metric-value { padding-right: 70px; }
.overview-middle { grid-template-columns: minmax(0,1.74fr) minmax(0,1fr); }
.overview-bottom { grid-template-columns: minmax(0,1.19fr) minmax(0,1fr); }
.overview-card { padding: 14px 17px 16px; }
.overview-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 18px; margin-bottom: 10px; }
.overview-card-heading h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.18;
  padding-left: 12px;
  border-left: 4px solid var(--gold);
}
.overview-card-heading > .text-action { margin-left: auto; }
.trend-modes { display:flex; padding: 2px; border: 1px solid #2c4058; border-radius: 8px; }
.trend-modes button { padding: 4px 12px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); background: transparent; font-size: 14px; }
.trend-modes button[aria-pressed="true"] { color: var(--gold-text); border-color: var(--gold); background: #463820; }
.trend-caption { display: flex; gap: 9px; align-items: center; justify-content: space-between; min-height: 34px; color: var(--muted); font-size: 13px; }
.trend-caption output { color: var(--gold-text); font-weight: 680; margin-left: auto; }
#trendCanvas { width: 100%; height: clamp(149px,15vw,222px); display: block; }
.trend-days { padding-left: 49px; padding-right: 10px; display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; }
.trend-days button { padding: 1px 0; border-color: transparent; border-radius: 4px; color: var(--muted); background: transparent; font-size: 13px; white-space: nowrap; }
.trend-days button[aria-pressed="true"] { color: var(--gold-text); background: #2e281f; }
.online-breakdown { min-height: 245px; display: grid; gap: 12px; grid-template-columns: minmax(105px,1.25fr) minmax(80px,1fr); align-items: center; }
.donut-wrap { position: relative; min-width: 0; width: min(100%, 230px); aspect-ratio: 1; margin-inline: auto; }
#deviceRing { display: block; width: 100%; height: 100%; }
.donut-value { position: absolute; inset: 0; display: grid; justify-items: center; align-content: center; pointer-events: none; }
.donut-value strong { font-size: clamp(24px,3vw,42px); line-height: 1.12; }
.donut-value span { font-size: 14px; color: var(--muted); }
.device-legend { margin: 0; }
.device-legend div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 7px 0; }
.device-legend dt { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.device-legend dt::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--cyan-text); }
.device-legend div + div dt::before { background: var(--gold-text); }
.device-legend dd { margin: 0; font-weight: 680; white-space: nowrap; }
.text-action { padding: 2px 4px; border: 1px solid transparent; color: var(--gold-text); background: transparent; font-size: 14px; white-space: nowrap; }
.text-action:hover { border-color: #694f25; background: #2e281f; }
.text-action.cyan { color: var(--cyan-text); }
.task-list { margin: 0; padding: 0; list-style: none; }
.task-row { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(48px,max-content) 68px; align-items: center; gap: 12px; min-height: 38px; border-bottom: 1px solid var(--rule); padding: 3px 3px; }
.task-row:last-child { border: 0; }
.task-count { color: var(--muted); }
.task-row .text-action { justify-self: end; }
.overview-empty { margin: 0; min-height: 120px; color: var(--muted); display: grid; place-content: center; text-align: center; }
.recent-wrap table { table-layout: fixed; font-size: 15px; }
.recent-wrap th, .recent-wrap td { border: 0; border-bottom: 1px solid var(--rule); }
.recent-wrap th:first-child { width: 51%; }
.recent-wrap tr:last-child td { border-bottom: 0; }
.redemption-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.redemption-pending { color: var(--gold-text); }
.redemption-paid { color: #5ce3ad; }
.redemption-closed { color: var(--muted); }
.estimate-breakdown { margin-bottom: 14px; }
.estimate-breakdown dl { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 0; }
.estimate-breakdown dl > div { display: flex; gap: 12px; }
.estimate-breakdown dd { margin: 0; color: var(--gold-text); font-weight: 680; }
.estimate-breakdown p { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

@media (max-width: 1260px) {
  .workspace.signed-in { grid-template-columns: 212px minmax(0,1fr); }
  .sidebar .brand { padding-inline: 6px; }
  .sidebar .brand strong { font-size: 23px; }
  .sidebar .nav-button { gap: 13px; }
  .metric h2 { font-size: 15px; }
  .metric { padding-inline: 11px; }
  #salesSparkline { width: 48px; }
  .metric:has(#salesSparkline:not([hidden])) .metric-value { padding-right: 44px; }
}
@media (max-width: 1030px) {
  .workspace.signed-in { display: block; }
  .signed-in #menuToggle { display: block; flex: none; }
  .sidebar { display: none; position: fixed; z-index: 10; top: 62px; height: calc(100dvh - 62px); width: min(248px,85vw); box-shadow: 12px 0 28px #020610bc; }
  .nav-open .sidebar:not([hidden]) { display: flex; }
  .topbar { position: sticky; z-index: 11; top: 0; min-height: 62px; gap: 10px; padding: 9px 14px; }
  .content { padding-inline: 16px; }
  .topbar-date { padding: 0 6px; }
}
@media (max-width: 710px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-grid, .grid { grid-template-columns: minmax(0,1fr); }
  .overview-heading, .overview-card-heading { align-items: flex-start; }
  .overview-heading { flex-direction: column; }
  .topbar-date { display: none; }
  #logout { margin-left: auto; }
  .line:has(.record-actions) { display: grid; }
  .record-actions { justify-content: flex-start; }
  .online-breakdown { min-height: 190px; }
  .donut-wrap { width: min(100%,180px); }
}
@media (max-width: 400px) {
  .content { padding-inline: 12px; }
  .topbar { gap: 7px; padding-inline: 9px; }
  #menuToggle, #logout { padding-inline: 8px; font-size: 14px; }
  .overview-card { padding-inline: 12px; }
  .metric h2 { gap: 4px; }
  .metric .icon { width: 20px; height: 20px; }
  #salesSparkline { display: none; }
  .metric:has(#salesSparkline:not([hidden])) .metric-value { padding-right: 0; }
  .metric .metric-link { position: static; display: inline-block; margin-top: 3px; }
  .metric:has(.metric-link:not([hidden])) .metric-note { padding-right: 0; }
  .trend-days button { font-size: 11px; }
}

.customer-facts, .customer-balance { margin: 0; }
.customer-facts { display: grid; grid-template-columns: minmax(90px,max-content) minmax(0,1fr); gap: 8px 14px; }
.customer-facts dt, .customer-balance dt, .customer-record-status { color: var(--muted); }
.customer-facts dd, .customer-balance dd { margin: 0; overflow-wrap: anywhere; }
.customer-balance { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,165px),1fr)); gap: 12px; }
.customer-balance > div { padding: 9px 12px; border: 1px solid var(--rule); border-radius: 8px; }
.customer-balance dd { color: var(--gold-text); font-size: 20px; font-weight: 680; }
.customer-record-status { margin: 8px 0 0; }
.customer-record-status[aria-invalid="true"] { color: var(--danger); }
#customerRecord td { overflow-wrap: anywhere; min-width: 102px; }
#customerRecord .table-scroll:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 2px; }


.metric-value.long-value { font-size: clamp(15px,1.45vw,24px); letter-spacing: -.04em; }
.metric:has(#salesSparkline) .metric-value.long-value { padding-right: 0; }
.metric:has(.long-value) #salesSparkline { display: none; }
@media (max-width: 480px) {
  .metric:has(.long-value) { grid-column: 1 / -1; }
  .metric-value.long-value { font-size: clamp(15px,4.1vw,20px); }
}
