:root {
  --canvas: #f2f5f3;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #16201e;
  --ink-soft: #3c4a46;
  --muted: #74817d;
  --line: #e1e7e4;
  --line-strong: #ced8d4;
  --brand: #176b5b;
  --brand-dark: #113f37;
  --brand-deep: #0d312c;
  --brand-soft: #e4f2ee;
  --accent: #e59a3a;
  --accent-soft: #fff3e1;
  --danger: #c94e45;
  --danger-soft: #fff0ee;
  --warning: #b9781e;
  --warning-soft: #fff4df;
  --info: #3c6f9f;
  --info-soft: #edf5fc;
  --shadow-sm: 0 1px 2px rgba(21, 41, 35, .04), 0 6px 18px rgba(21, 41, 35, .04);
  --shadow-lg: 0 28px 80px rgba(12, 40, 32, .2);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --font-sans: "MiSans", "Alibaba PuHuiTi 3", "HarmonyOS Sans SC", "PingFang SC", sans-serif;
  --font-display: "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.hidden { display: none !important; }
.eyebrow { margin: 0; color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }

/* Login */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(480px, 1.08fr) minmax(420px, .92fr); background: var(--surface); }
.login-visual { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; overflow: hidden; padding: 46px clamp(42px, 6vw, 92px); color: #f6fbf8; background:
  radial-gradient(circle at 78% 23%, rgba(228, 160, 70, .22) 0 2px, transparent 3px),
  radial-gradient(circle at 78% 23%, transparent 0 90px, rgba(255, 255, 255, .07) 91px 92px, transparent 93px 160px, rgba(255, 255, 255, .04) 161px 162px, transparent 163px),
  linear-gradient(145deg, #174d43 0%, #0b302b 68%, #092720 100%); }
.login-visual::before { content: ""; position: absolute; inset: 0; opacity: .13; background-image: linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom right, #000, transparent 72%); }
.login-visual::after { content: ""; position: absolute; width: 420px; height: 420px; right: -230px; bottom: -190px; border: 90px solid rgba(255,255,255,.035); border-radius: 50%; }
.login-brand, .login-statement, .login-signal { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 14px; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.brand-mark { display: grid; width: 46px; height: 46px; place-items: center; color: #fff; background: var(--accent); border-radius: 14px 14px 14px 4px; box-shadow: 0 8px 24px rgba(229, 154, 58, .23); font-family: var(--font-display); font-size: 24px; }
.brand-mark.compact { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px 11px 11px 3px; font-size: 20px; }
.login-statement { max-width: 690px; margin: 10vh 0 auto; }
.login-statement .eyebrow { color: #efb766; }
.login-statement h1 { margin: 22px 0 28px; font-family: var(--font-display); font-size: clamp(42px, 5vw, 72px); font-weight: 600; line-height: 1.16; letter-spacing: -.04em; }
.login-statement > p:last-child { max-width: 480px; margin: 0; color: #b9d0c9; font-size: 16px; line-height: 1.85; }
.login-signal { display: flex; align-items: flex-end; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.13); padding-top: 22px; }
.login-signal span { display: flex; align-items: center; gap: 9px; color: #a7c4bb; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.login-signal i, .system-state i, .environment i { width: 7px; height: 7px; background: #66d69e; border-radius: 50%; box-shadow: 0 0 0 5px rgba(102,214,158,.12); }
.login-signal b { font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.login-area { display: grid; place-items: center; min-height: 100vh; padding: 56px; background: radial-gradient(circle at 85% 8%, #eef6f2 0, transparent 30%), var(--surface); }
.login-card { width: min(410px, 100%); }
.login-card-head { margin-bottom: 38px; }
.mobile-mark { display: none; }
.login-card-head h2 { margin: 12px 0 7px; font-family: var(--font-display); font-size: 36px; font-weight: 600; letter-spacing: -.03em; }
.login-card-head > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.field-label { display: block; margin: 18px 0 8px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.input-shell { position: relative; }
.input-shell input { height: 50px; padding-left: 46px; padding-right: 58px; }
.input-symbol { position: absolute; z-index: 1; left: 16px; top: 50%; display: grid; width: 20px; height: 20px; place-items: center; transform: translateY(-50%); color: var(--brand); background: var(--brand-soft); border-radius: 6px; font-size: 9px; font-weight: 900; }
.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.login-submit { width: 100%; height: 50px; justify-content: center; margin-top: 28px; }
.form-error { min-height: 20px; padding-top: 10px; color: var(--danger); font-size: 12px; }
.login-footnote { margin: 30px 0 0; padding-top: 22px; color: #96a19e; border-top: 1px solid var(--line); text-align: center; font-size: 10px; letter-spacing: .05em; }

/* Shell */
.app { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; width: 264px; flex-direction: column; padding: 22px 16px 16px; color: #e9f3ef; background:
  linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
  linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
  var(--brand-deep); background-size: 32px 32px; box-shadow: 10px 0 36px rgba(11,42,35,.08); }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand b, .brand span { display: block; }
.brand b { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: .08em; }
.brand div > span { margin-top: 3px; color: #8fb0a7; font-size: 9px; letter-spacing: .18em; }
.sidebar .sidebar-close { display: none; margin-left: auto; }
.environment { display: flex; align-items: center; gap: 9px; margin: 16px 7px 7px; padding: 9px 11px; color: #b8cec7; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.06); border-radius: 9px; font-size: 11px; }
.environment i { width: 6px; height: 6px; flex: 0 0 6px; }
.environment em { margin-left: auto; color: #6f998e; font-size: 8px; font-style: normal; font-weight: 800; letter-spacing: .12em; }
nav { flex: 1; overflow: auto; margin: 4px -4px 10px; padding: 0 4px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-label { margin: 19px 12px 7px; color: #668c82; font-size: 9px; font-weight: 800; letter-spacing: .15em; }
nav button { position: relative; display: flex; width: 100%; align-items: center; gap: 11px; margin: 2px 0; padding: 9px 11px; color: #abc3bc; background: transparent; border: 1px solid transparent; border-radius: 9px; text-align: left; font-size: 12px; transition: background .18s, color .18s, transform .18s; }
nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
nav button.active { color: #fff; background: linear-gradient(90deg, rgba(255,255,255,.13), rgba(255,255,255,.07)); border-color: rgba(255,255,255,.07); box-shadow: inset 3px 0 var(--accent); }
.nav-icon { display: grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; color: #96b7ae; background: rgba(255,255,255,.07); border-radius: 8px; font-size: 10px; font-weight: 800; }
nav button.active .nav-icon { color: #fff; background: rgba(229,154,58,.2); }
.nav-dot { width: 6px; height: 6px; margin-left: auto; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 4px rgba(229,154,58,.12); }
.sidebar-account { display: grid; grid-template-columns: 36px 1fr 30px; align-items: center; gap: 10px; padding: 13px 10px 5px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-account b, .sidebar-account span { display: block; }
.sidebar-account b { overflow: hidden; color: #f5faf8; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account div > span { margin-top: 3px; color: #759c92; font-size: 9px; }
.avatar { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: #fff; background: linear-gradient(145deg, #2a8a77, #176052); border-radius: 11px; font-size: 12px; font-weight: 800; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; color: inherit; background: transparent; border-radius: 9px; font-size: 18px; }
.icon-button:hover { background: rgba(255,255,255,.08); }
.workspace { min-width: 0; min-height: 100vh; margin-left: 264px; padding: 0 clamp(22px, 3.2vw, 52px) 64px; }
.topbar { position: relative; display: flex; min-height: 132px; align-items: center; justify-content: space-between; gap: 24px; }
.page-heading { display: flex; min-width: 0; align-items: center; gap: 12px; }
.page-heading > div { min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: #96a19e; font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.breadcrumb span:last-child { color: var(--brand); }
.breadcrumb i { color: #c7cecb; font-style: normal; }
.topbar h1 { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.025em; }
.topbar .page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.menu-toggle { display: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.topbar-actions { position: relative; display: flex; align-items: center; gap: 10px; }
.system-state { display: flex; align-items: center; gap: 9px; margin-right: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.system-state i { display: block; width: 6px; height: 6px; }
.account-chip { display: flex; height: 50px; align-items: center; gap: 10px; padding: 6px 11px 6px 7px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-sm); text-align: left; }
.account-chip > span:nth-child(2) { min-width: 74px; }
.account-chip b, .account-chip em { display: block; }
.account-chip b { overflow: hidden; max-width: 110px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.account-chip em { margin-top: 3px; color: var(--muted); font-size: 9px; font-style: normal; }
.account-chip > i { color: var(--muted); font-size: 11px; font-style: normal; }
.account-popover { position: absolute; z-index: 20; top: 58px; right: 0; width: 176px; padding: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 48px rgba(24,44,38,.15); }
.account-popover button { width: 100%; padding: 10px 12px; color: var(--ink-soft); background: transparent; border-radius: 8px; text-align: left; font-size: 11px; }
.account-popover button:hover { background: var(--surface-soft); }
.account-popover .danger-text { color: var(--danger); }

/* Controls */
input, select, textarea { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); outline: none; transition: border-color .16s, box-shadow .16s; }
input, select { min-height: 40px; padding: 9px 12px; }
textarea { min-height: 112px; padding: 11px 12px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a9b2af; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,107,91,.1); }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); background: #f2f4f3; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px; font-size: 11px; font-weight: 700; white-space: nowrap; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.button.primary { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 7px 18px rgba(23,107,91,.17); }
.button.primary:hover:not(:disabled) { background: #115f50; }
.button.secondary { background: var(--surface-soft); }
.button.quiet { color: var(--ink-soft); background: rgba(255,255,255,.7); }
.button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button.is-loading { pointer-events: none; }
.button.is-loading span { opacity: .5; }
.button.is-loading::after { content: ""; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.42); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.button.quiet.is-loading::after, .button.secondary.is-loading::after { border-color: rgba(23,107,91,.2); border-top-color: var(--brand); }
.toolbar { display: flex; min-height: 46px; align-items: center; gap: 9px; margin-bottom: 18px; }
.toolbar:empty { display: none; }
.toolbar-group { display: flex; align-items: center; gap: 9px; }
.toolbar-spacer { flex: 1; }
.search-control { position: relative; width: min(330px, 36vw); }
.search-control::before { content: "⌕"; position: absolute; z-index: 1; left: 13px; top: 50%; transform: translateY(-54%); color: #8d9995; font-size: 17px; }
.search-control input { padding-left: 37px; background: var(--surface); }
.toolbar select { width: auto; min-width: 150px; background-color: var(--surface); }
.filter-label { color: var(--muted); font-size: 10px; font-weight: 700; }

/* Dashboard */
.content { animation: reveal .25s ease both; }
.overview-band { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 28px; overflow: hidden; margin-bottom: 18px; padding: 26px 30px; color: #f4faf7; background: linear-gradient(125deg, #164f44, #0f3c35 68%, #12362f); border-radius: var(--radius-lg); box-shadow: 0 14px 38px rgba(14,55,47,.13); }
.overview-band::after { content: ""; position: absolute; right: -60px; top: -120px; width: 300px; height: 300px; border: 45px solid rgba(255,255,255,.035); border-radius: 50%; }
.overview-band > div, .overview-band > button { position: relative; z-index: 1; }
.overview-band .eyebrow { color: #efb766; }
.overview-band h2 { margin: 8px 0 7px; font-family: var(--font-display); font-size: 23px; font-weight: 600; }
.overview-band p:last-child { margin: 0; color: #abc8c0; font-size: 11px; }
.overview-band .button { color: #23433d; background: #f5efe3; border: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { position: relative; overflow: hidden; min-width: 0; min-height: 145px; padding: 21px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.metric::after { content: ""; position: absolute; width: 86px; height: 86px; right: -36px; bottom: -38px; background: var(--brand-soft); border-radius: 50%; }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-icon { display: grid; width: 30px; height: 30px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 9px; font-size: 10px; font-weight: 900; }
.metric b { display: block; overflow: hidden; margin: 18px 0 6px; font-family: "DIN Alternate", "Avenir Next", sans-serif; font-size: 29px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.metric em { color: var(--brand); font-size: 10px; font-style: normal; font-weight: 700; }
.metric.warning .metric-icon { color: var(--warning); background: var(--warning-soft); }
.metric.warning em { color: var(--warning); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .7fr); gap: 18px; }
.stack-layout { display: grid; gap: 18px; }
.trend-panel { margin-bottom: 18px; }
.trend-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; }
.trend-legend i { width: 8px; height: 8px; background: var(--brand); border-radius: 2px; }
.trend-legend i:nth-child(2) { margin-left: 7px; background: var(--accent); }
.trend-chart { display: grid; grid-template-columns: repeat(7, minmax(48px, 1fr)); gap: 12px; height: 210px; padding: 24px 28px 18px; }
.trend-column { display: grid; grid-template-rows: 1fr auto auto; min-width: 0; gap: 4px; text-align: center; }
.trend-bars { display: flex; height: 130px; align-items: flex-end; justify-content: center; gap: 5px; border-bottom: 1px solid var(--line); }
.trend-bars i { width: min(17px, 32%); min-height: 3px; background: linear-gradient(180deg, #2b8f7a, var(--brand)); border-radius: 5px 5px 0 0; }
.trend-bars i:nth-child(2) { background: linear-gradient(180deg, #efb766, var(--accent)); }
.trend-column b { color: var(--ink-soft); font-size: 9px; }
.trend-column span { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.empty-state.compact { min-height: 170px; border: 0; box-shadow: none; }
.toolbar input[type="date"] { width: 150px; background: var(--surface); }
.queue-list { display: grid; gap: 10px; padding: 16px; }
.queue-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 11px; width: 100%; padding: 12px; color: var(--ink); background: var(--surface-soft); border: 1px solid transparent; border-radius: 11px; text-align: left; }
.queue-item:hover { border-color: var(--line-strong); background: #fff; }
.queue-icon { display: grid; width: 38px; height: 38px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 10px; font-size: 11px; font-weight: 800; }
.queue-item b, .queue-item span { display: block; }
.queue-item b { font-size: 11px; }
.queue-item span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.queue-item strong { color: var(--brand); font-size: 18px; }

/* Data panels */
.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; min-height: 63px; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-list-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.panel-head-action { min-height: 32px; padding: 6px 12px; }
.panel-list-search { position: relative; width: 180px; }
.panel-list-search::before { content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-52%); color: var(--muted); }
.panel-list-search input { width: 100%; height: 32px; padding: 0 10px 0 29px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 11px; }
.client-page-hidden { display: none; }
.panel-title b, .panel-title span { display: block; }
.panel-title b { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.panel-title span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.record-count { padding: 5px 9px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 20px; font-size: 9px; font-weight: 700; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; white-space: nowrap; }
th { padding: 11px 14px; color: #899590; background: #f8faf9; border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; font-weight: 800; letter-spacing: .07em; }
.table-sort { display: inline-flex; align-items: center; gap: 6px; padding: 0; color: inherit; background: transparent; font: inherit; font-weight: inherit; letter-spacing: inherit; white-space: nowrap; }
.table-sort i { color: #b3bcb9; font-size: 10px; font-style: normal; transition: color .15s; }
.table-sort:hover, .table-sort.active { color: var(--brand); }
.table-sort.active i { color: var(--brand); }
td { max-width: 260px; padding: 13px 14px; color: var(--ink-soft); border-bottom: 1px solid #edf0ef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: #fbfcfb; }
.cell-primary { color: var(--ink); font-weight: 700; }
.cell-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; font-variant-numeric: tabular-nums; }
.money { color: var(--ink); font-family: "DIN Alternate", "Avenir Next", sans-serif; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-link { display: inline-grid; gap: 3px; padding: 5px 8px; color: var(--brand); background: var(--brand-soft); border-radius: 8px; text-align: left; }
.metric-link b { font-size: 11px; font-variant-numeric: tabular-nums; }
.metric-link span { color: var(--muted); font-size: 8px; }
.metric-link:hover { color: #fff; background: var(--brand); }
.metric-link:hover span { color: rgba(255,255,255,.72); }
.report-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.truncate { display: block; overflow: hidden; max-width: 210px; text-overflow: ellipsis; white-space: nowrap; }
.result-balls { display: flex; gap: 4px; }
.result-balls i { display: grid; width: 23px; height: 23px; place-items: center; color: #fff; background: var(--brand); border-radius: 50%; font-size: 9px; font-style: normal; font-weight: 800; }
.game-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.game-label i { display: grid; width: 25px; height: 25px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 7px; font-size: 9px; font-style: normal; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; color: var(--brand); background: var(--brand-soft); border-radius: 20px; font-size: 9px; font-weight: 800; }
.status::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.status.warning { color: var(--warning); background: var(--warning-soft); }
.status.danger { color: var(--danger); background: var(--danger-soft); }
.status.info { color: var(--info); background: var(--info-soft); }
.status.neutral { color: #68736f; background: #eef1f0; }
.actions { display: flex; align-items: center; gap: 6px; }
.action-button { padding: 6px 9px; color: var(--brand); background: var(--brand-soft); border-radius: 7px; font-size: 9px; font-weight: 800; }
.action-button:hover { background: #d8ebe5; }
.action-button.secondary { color: var(--ink-soft); background: #eef1f0; }
.action-button.danger { color: var(--danger); background: var(--danger-soft); }
.action-button.warning { color: var(--warning); background: var(--warning-soft); }
.pagination { display: flex; min-height: 58px; align-items: center; justify-content: flex-end; gap: 12px; padding: 11px 17px; color: var(--muted); background: #fcfdfc; border-top: 1px solid var(--line); font-size: 10px; }
.pagination button { min-width: 35px; height: 32px; padding: 0 10px; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 7px; font-size: 10px; font-weight: 700; }
.pagination button:not(:disabled):hover { color: var(--brand); border-color: var(--brand); }
.pagination strong { color: var(--ink); }
.empty-state, .error-state, .loading-state { display: grid; min-height: 320px; place-items: center; align-content: center; gap: 13px; padding: 60px 20px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; font-size: 11px; }
.empty-state i, .error-state i { display: grid; width: 48px; height: 48px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 15px; font-size: 18px; font-style: normal; }
.error-state i { color: var(--danger); background: var(--danger-soft); }
.empty-state b, .error-state b { color: var(--ink); font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.empty-state p, .error-state p { max-width: 420px; margin: 0; line-height: 1.7; }
.loading-state i { width: 24px; height: 24px; border: 2px solid #d7e2de; border-top-color: var(--brand); border-radius: 50%; animation: spin .75s linear infinite; }
.loading-state { min-height: 240px; }

/* Forms and cards */
.cards-layout { display: grid; grid-template-columns: minmax(330px, .75fr) minmax(360px, 1.25fr); gap: 18px; }
.form-panel { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-panel h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.form-panel > p { margin: 7px 0 22px; color: var(--muted); font-size: 10px; line-height: 1.7; }
.form-panel .button { width: 100%; margin-top: 22px; }
.result-panel { min-height: 420px; }
.result-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-panel-head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.card-result { min-height: 322px; margin: 0; padding: 18px; overflow: auto; color: #d8ece6; background: #102f2a; border-radius: 11px; white-space: pre-wrap; word-break: break-all; font: 10px/1.8 "SFMono-Regular", Consolas, monospace; }
.card-result.empty-result { display: grid; place-items: center; color: #6c9187; font-family: var(--font-sans); }

/* Dialogs */
dialog { color: var(--ink); }
.modal { width: min(620px, calc(100vw - 30px)); max-height: min(86vh, 780px); margin: auto; padding: 0; overflow: auto; background: var(--surface); border: 0; border-radius: 18px; box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(11, 31, 27, .62); backdrop-filter: blur(4px); }
.modal form { margin: 0; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 26px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2, .confirm-body h2 { margin: 7px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.modal-head p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.modal-head .icon-button { flex: 0 0 34px; color: var(--muted); background: var(--surface-soft); }
.modal-context { margin: 20px 26px 0; padding: 13px 15px; color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; font-size: 10px; line-height: 1.7; }
.context-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.context-grid span { display: block; color: var(--muted); font-size: 9px; }
.context-grid b { display: block; overflow: hidden; margin-top: 3px; color: var(--ink); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 14px; padding: 22px 26px 5px; }
.form-field { min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--ink-soft); font-size: 10px; font-weight: 800; }
.form-field label em { color: var(--danger); font-style: normal; }
.form-field small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.form-field.invalid input, .form-field.invalid select, .form-field.invalid textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(201,78,69,.08); }
.switch-field { grid-column: 1 / -1; display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 20px; padding: 11px 13px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; }
.switch-copy b, .switch-copy span { display: block; }
.switch-copy b { font-size: 10px; }
.switch-copy span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; background: #cbd3d0; border-radius: 24px; transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.16); transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.modal-error { margin: 16px 26px 0; padding: 10px 12px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f3d3cf; border-radius: 8px; font-size: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 22px 26px 25px; }
.modal-actions .button { min-width: 90px; }
.confirm-modal { width: min(480px, calc(100vw - 30px)); overflow: hidden; }
.confirm-body { display: grid; grid-template-columns: 48px 1fr; gap: 16px; padding: 27px 27px 6px; }
.confirm-icon { display: grid; width: 48px; height: 48px; place-items: center; color: var(--danger); background: var(--danger-soft); border-radius: 14px; font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.confirm-body p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

/* Notifications */
.toast-stack { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; width: min(360px, calc(100vw - 32px)); gap: 9px; pointer-events: none; }
.toast { display: grid; grid-template-columns: 30px 1fr 20px; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; color: #edf8f4; background: #153c35; border: 1px solid rgba(255,255,255,.08); border-radius: 11px; box-shadow: 0 16px 42px rgba(9,35,29,.22); animation: toast-in .24s ease both; pointer-events: auto; }
.toast.error { color: #fff5f3; background: #713c38; }
.toast-icon { display: grid; width: 28px; height: 28px; place-items: center; color: #153c35; background: #77d5b2; border-radius: 8px; font-size: 12px; font-weight: 900; }
.toast.error .toast-icon { color: #713c38; background: #ffc7c1; }
.toast b, .toast span { display: block; }
.toast b { font-size: 10px; }
.toast span { margin-top: 3px; color: rgba(255,255,255,.7); font-size: 9px; }
.toast button { color: rgba(255,255,255,.6); background: transparent; font-size: 16px; }
.sidebar-backdrop { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 1220px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .system-state { display: none; }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-102%); transition: transform .24s ease; box-shadow: 18px 0 60px rgba(6,25,21,.24); }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar .sidebar-close { display: grid; }
  .sidebar-backdrop { position: fixed; z-index: 25; inset: 0; background: rgba(7,28,23,.5); backdrop-filter: blur(2px); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .workspace { margin-left: 0; }
  .menu-toggle { display: grid; }
  .login-shell { grid-template-columns: minmax(360px, .8fr) minmax(400px, 1fr); }
  .login-visual { padding: 38px; }
  .login-statement h1 { font-size: 42px; }
}

@media (max-width: 720px) {
  .login-shell { display: block; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 100% 0, #dfeee9, transparent 38%), var(--surface); }
  .login-visual { display: none; }
  .login-area { min-height: calc(100vh - 48px); padding: 12px; background: transparent; }
  .mobile-mark { display: grid; width: 48px; height: 48px; place-items: center; margin-bottom: 28px; color: #fff; background: var(--accent); border-radius: 14px 14px 14px 4px; font-family: var(--font-display); font-size: 23px; }
  .workspace { padding: 0 14px 40px; }
  .topbar { min-height: 116px; align-items: flex-start; padding-top: 21px; }
  .topbar h1 { font-size: 25px; }
  .topbar .page-heading p { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .breadcrumb, .account-chip > span:nth-child(2), .account-chip > i, .topbar-actions > .button { display: none; }
  .account-chip { width: 44px; height: 44px; padding: 4px; border: 0; background: transparent; box-shadow: none; }
  .account-popover { top: 48px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar-group { width: 100%; flex-wrap: wrap; }
  .toolbar-spacer { display: none; }
  .search-control { width: 100%; }
  .toolbar select { min-width: 0; flex: 1; }
  .toolbar .button { flex: 0 0 auto; }
  .overview-band { grid-template-columns: 1fr; padding: 22px; }
  .overview-band .button { justify-self: start; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 132px; padding: 17px; }
  .metric b { font-size: 24px; }
  .panel { border-radius: 12px; }
  .panel-head { min-height: 58px; align-items: flex-start; flex-direction: column; padding: 12px 14px; }
  .panel-list-tools { width: 100%; flex-wrap: wrap; justify-content: space-between; }
  .panel-list-search { width: min(240px, 70%); }
  th, td { padding: 11px 12px; }
  .cards-layout { grid-template-columns: 1fr; }
  .result-panel { min-height: 360px; }
  .form-grid { grid-template-columns: 1fr; padding: 20px 18px 4px; }
  .form-field.full, .switch-field { grid-column: 1; }
  .modal-head { padding: 21px 19px 17px; }
  .modal-context { margin: 17px 18px 0; }
  .context-grid { grid-template-columns: 1fr 1fr; }
  .modal-error { margin: 14px 18px 0; }
  .modal-actions { padding: 19px; }
  .modal-actions .button { flex: 1; }
  .confirm-body { padding: 22px 20px 5px; }
}

@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 120px; }
  .overview-band h2 { font-size: 20px; }
  .pagination { justify-content: space-between; }
  .pagination span { max-width: 150px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
