:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-hover: #f1f5f9;
  --ink: #172033;
  --muted: #667085;
  --muted-light: #98a2b3;
  --line: #e4e7ec;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --sans: "Inter", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, ui-monospace, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .06);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; overflow-x: clip; }
body { min-width: 320px; margin: 0; color: var(--ink); background: var(--bg); font-family: var(--sans); font-size: 14px; line-height: 1.5; overflow-x: hidden; overscroll-behavior-x: none; }
button, input { font: inherit; }
button, input { touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(37, 99, 235, .22); outline-offset: 2px; }
.skip-nav { position: absolute; top: -50px; left: 18px; z-index: 50; padding: 10px 14px; color: #fff; background: var(--accent); }
.skip-nav:focus { top: 18px; }

.app-shell { min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 clamp(22px, 5vw, 80px); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--mono); font-size: 12px; letter-spacing: -.04em; text-decoration: none; }
.brand i { color: var(--muted-light); font-style: normal; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: #fff; background: var(--accent); border-radius: 7px; font-size: 10px; font-weight: 700; letter-spacing: -.12em; }
.topbar-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.live-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 4px var(--success-soft); }
.logout-button { padding: 3px 0; color: var(--muted); background: transparent; border: 0; border-bottom: 1px solid transparent; font-family: var(--mono); font-size: 10px; }
.logout-button:hover { color: var(--accent); border-color: var(--accent); }

.main-content { width: min(1360px, 100%); margin: 0 auto; padding: clamp(42px, 6vw, 76px) clamp(22px, 5vw, 64px) 72px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px; margin-bottom: 46px; }
.eyebrow { margin: 0 0 10px; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 780px; margin-bottom: 14px; color: var(--ink); font-size: clamp(38px, 5vw, 64px); font-weight: 750; letter-spacing: -.075em; line-height: 1; }
h2 { margin: 0; color: var(--ink); font-size: 20px; font-weight: 700; letter-spacing: -.04em; line-height: 1.2; }
.intro-copy { max-width: 520px; margin: 0; color: var(--muted); font-size: 14px; }
.intro-meta { display: flex; flex: none; flex-direction: column; align-items: flex-start; min-width: 190px; padding: 14px 0 14px 18px; border-left: 2px solid var(--accent); }
.intro-meta span, .intro-meta small { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.intro-meta strong { margin: 8px 0 6px; color: var(--ink); font-family: var(--mono); font-size: 14px; font-weight: 500; }

.filter-panel, .reset-panel, .data-panel, .records-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.filter-panel { position: relative; z-index: 20; isolation: isolate; margin-bottom: 38px; padding: 24px clamp(18px, 3vw, 28px) 20px; }
.filter-panel::before { position: absolute; top: -1px; left: 24px; width: 30px; height: 2px; content: ""; background: var(--accent); }
.filter-heading, .section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.filter-heading { margin-bottom: 22px; }
.saved-state, .panel-note, .period-label { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.filters { position: relative; z-index: 21; display: flex; align-items: end; gap: 10px; }
.field { display: flex; flex: 1; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .02em; }
input, .account-trigger { width: 100%; height: 44px; padding: 0 12px; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius-sm); }
input:hover, .account-trigger:hover { border-color: #c7cdd7; }
input[type="datetime-local"] { color-scheme: light; font-family: var(--mono); font-size: 12px; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
.date-arrow { padding-bottom: 12px; color: var(--muted-light); font-family: var(--mono); }
.account-field { position: relative; z-index: 40; flex: 1.1; }
.account-picker { position: relative; z-index: 41; }
.account-trigger { display: flex; align-items: center; justify-content: space-between; text-align: left; }
.account-menu { position: absolute; top: 51px; left: 0; z-index: 100; display: none; width: 100%; max-height: 250px; overflow: auto; padding: 6px; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.account-menu.open { display: block; }
.account-option { display: flex; align-items: center; gap: 9px; padding: 9px 8px; color: var(--ink); font-family: var(--mono); font-size: 11px; cursor: pointer; }
.account-option:hover { background: var(--accent-soft); }
.account-option input { width: 15px; height: 15px; padding: 0; accent-color: var(--accent); }
.account-option em { color: var(--muted); font-size: 9px; font-style: normal; }
.primary-button { display: flex; align-items: center; justify-content: space-between; gap: 22px; height: 44px; padding: 0 15px; color: #fff; background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-weight: 700; white-space: nowrap; }
.primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); transform: translateY(-1px); }
.quick-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.quick-filters button { padding: 3px 0; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid transparent; }
.quick-filters button:hover { color: var(--accent); border-color: var(--accent); }

.reset-panel { display: grid; grid-template-columns: auto minmax(220px, 1fr) minmax(360px, 1.2fr); align-items: start; gap: 18px 24px; margin-bottom: 46px; padding: 22px clamp(18px, 3vw, 28px) 0; }
.reset-mark { display: grid; place-items: center; width: 40px; height: 40px; color: var(--accent); background: var(--accent-soft); border: 1px solid #bfdbfe; border-radius: 50%; font-size: 23px; line-height: 1; }
.reset-copy p:last-child { max-width: 430px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.reset-controls { display: flex; align-items: end; gap: 10px; }
.reset-actions { display: flex; align-items: center; gap: 8px; }
.reset-actions .primary-button { min-width: 146px; }
.secondary-button { height: 44px; padding: 0 13px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius-sm); white-space: nowrap; }
.secondary-button:hover { color: var(--accent); border-color: #bfdbfe; background: var(--accent-soft); }
.reset-result { grid-column: 1 / -1; padding: 16px 0 20px; border-top: 1px solid var(--line); }
.reset-empty { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.reset-period { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 13px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.reset-period strong { color: var(--ink); font-weight: 400; }
.reset-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.reset-metrics > div { padding: 13px 14px; background: var(--surface-muted); }
.reset-metrics span { display: block; margin-bottom: 5px; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.reset-metrics strong { color: var(--accent); font-family: var(--mono); font-size: 17px; font-weight: 600; }
.quota-estimator { display: grid; grid-template-columns: minmax(170px, 1fr) auto minmax(180px, .8fr); align-items: center; gap: 18px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.quota-copy { display: flex; flex-direction: column; gap: 4px; }
.quota-copy span { color: var(--ink); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.quota-copy small, .quota-output span { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.quota-controls { display: flex; align-items: center; gap: 0; }
.quota-input { display: block; width: 132px; }
.quota-input input { height: 38px; padding-right: 8px; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-family: var(--mono); font-size: 12px; }
.quota-suffix { display: grid; place-items: center; height: 38px; padding: 0 10px; color: var(--muted); background: var(--surface-muted); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 11px; }
.quota-controls .secondary-button { height: 38px; margin-left: 8px; color: var(--ink); font-size: 11px; }
.quota-output { display: flex; flex-direction: column; gap: 4px; padding-left: 18px; border-left: 1px solid var(--line); }
.quota-output strong { color: var(--accent-dark); font-family: var(--mono); font-size: 20px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.summary-section, .records-section { margin-bottom: 46px; }
.section-heading { margin-bottom: 17px; }
.hero-metrics { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 12px; }
.hero-card { display: flex; flex-direction: column; justify-content: space-between; min-height: 172px; padding: 22px 23px 19px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: border-color .25s var(--ease), transform .25s var(--ease); }
.hero-card:hover { border-color: #c7cdd7; transform: translateY(-2px); }
.accent-card { background: var(--accent-soft); border-color: #bfdbfe; }
.navy-card, .plain-card { background: var(--surface); color: var(--ink); }
.metric-label { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: -.02em; }
.accent-card .metric-label { color: #1e40af; }
.metric-label span { margin-left: 5px; color: var(--muted-light); font-size: 9px; }
.hero-value { overflow: hidden; margin: 17px 0; color: var(--ink); font-family: var(--mono); font-size: clamp(28px, 3.5vw, 48px); font-weight: 500; letter-spacing: -.09em; line-height: 1; text-overflow: ellipsis; }
.accent-card .hero-value { color: #1e40af; }
.metric-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 11px; color: var(--muted); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 10px; }
.metric-foot strong { color: var(--accent); font-weight: 600; }
.accent-card .metric-foot { color: #3b82f6; border-color: #bfdbfe; }
.accent-card .metric-foot strong { color: #1e40af; }
.detail-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; margin-top: 12px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.detail-item { min-width: 0; padding: 14px 13px; background: var(--surface); }
.detail-label { display: block; overflow: hidden; margin-bottom: 6px; color: var(--muted); font-family: var(--mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.detail-value { display: block; overflow: hidden; color: var(--ink); font-family: var(--mono); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 46px; }
.data-panel { min-height: 292px; padding: 24px clamp(18px, 3vw, 28px); }
.panel-heading { margin-bottom: 27px; }
.bars { display: flex; flex-direction: column; gap: 17px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 12px; font-family: var(--mono); font-size: 11px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 6px; overflow: hidden; background: var(--surface-hover); border-radius: 99px; }
.bar-fill { width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s var(--ease); }
.bar-number { min-width: 57px; color: var(--muted); text-align: right; }
.empty-state { padding: 30px 0; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.records-section { padding: 24px clamp(18px, 3vw, 28px) 23px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 12px; }
th { color: var(--muted); background: var(--surface-muted); font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { color: var(--ink); font-family: var(--mono); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--accent-soft); }
td.cost { color: var(--accent-dark); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 15px; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.pagination-actions { display: flex; gap: 8px; }
.pagination .secondary-button:disabled { cursor: not-allowed; color: var(--muted-light); background: var(--surface-hover); border-color: var(--line); opacity: .75; }
.table-caption { margin: 11px 0 0; color: var(--muted-light); font-family: var(--mono); font-size: 10px; }

.footer { display: flex; justify-content: space-between; max-width: 1480px; margin: 0 auto; padding: 18px clamp(22px, 5vw, 80px) 28px; color: var(--muted-light); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 10px; }
.error-banner { margin: -22px 0 30px; padding: 12px 14px; color: var(--danger); background: var(--danger-soft); border: 1px solid #fecdca; border-radius: var(--radius-sm); font-family: var(--mono); font-size: 11px; }
.loading-state { display: flex; align-items: center; gap: 8px; margin: -12px 0 30px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.reveal { animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.login-brand { margin-bottom: 58px; }
.login-card h1 { margin-bottom: 13px; font-size: 38px; }
.login-copy { margin-bottom: 28px; color: var(--muted); }
.login-button { width: 100%; margin-top: 17px; }
.login-error { margin: 12px 0 0; padding: 10px 12px; color: var(--danger); background: var(--danger-soft); border: 1px solid #fecdca; border-radius: var(--radius-sm); font-family: var(--mono); font-size: 11px; }

@media (max-width: 1000px) {
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .accent-card { grid-column: span 2; }
  .detail-grid { grid-template-columns: repeat(4, 1fr); }
  .reset-panel { grid-template-columns: auto 1fr; }
  .reset-controls { grid-column: 2; }
  .reset-result { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .topbar { min-height: 62px; padding-inline: 16px; }
  .topbar-meta { gap: 9px; }
  .topbar-meta .live-dot, .topbar-meta #timezone-label { display: none; }
  .main-content { padding: 32px 16px 48px; }
  .intro { grid-template-columns: 1fr; gap: 22px; margin-bottom: 34px; }
  .intro-meta { min-width: 0; padding: 12px 0 0 13px; }
  .intro-meta strong { font-size: 12px; }
  .filter-panel { padding: 20px 16px 18px; }
  .filter-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .filters { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .date-arrow { display: none; }
  .account-field, .filters .primary-button { grid-column: auto; }
  .filters .primary-button { justify-content: space-between; width: 100%; }
  input[type="datetime-local"], .quota-input input { font-size: 16px; }
  .quick-filters { gap: 12px 16px; }
  .reset-panel { grid-template-columns: 1fr; gap: 14px; }
  .reset-controls { display: grid; grid-column: auto; grid-template-columns: 1fr; align-items: stretch; }
  .reset-actions { justify-content: stretch; }
  .reset-actions .primary-button { flex: 1; }
  .reset-result { grid-column: auto; }
  .reset-period { flex-direction: column; align-items: flex-start; gap: 6px; }
  .reset-metrics { grid-template-columns: 1fr 1fr; }
  .quota-estimator { grid-template-columns: 1fr; gap: 12px; }
  .quota-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .quota-input { width: auto; min-width: 0; }
  .quota-controls .secondary-button { grid-column: 1 / -1; width: 100%; margin: 8px 0 0; }
  .quota-output { padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .hero-metrics { grid-template-columns: 1fr; }
  .accent-card { grid-column: auto; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .breakdown-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .pagination-actions { width: 100%; }
  .pagination-actions .secondary-button { flex: 1; }
  .footer { flex-direction: column; gap: 8px; }
  h1 { font-size: 40px; }
  .login-card { padding: 28px 22px; }
  .table-wrap { overflow: visible; border: 0; }
  table, tbody, tbody tr, tbody td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { margin-bottom: 10px; padding: 10px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
  tbody tr:last-child td { border-bottom: 0; }
  tbody td { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 0; white-space: normal; text-align: right; overflow-wrap: anywhere; }
  tbody td::before { flex: 0 0 auto; color: var(--muted); font-family: var(--mono); font-size: 10px; text-align: left; content: attr(data-label); }
  tbody td.empty-state { display: block; padding: 24px 0; text-align: center; }
  tbody td.empty-state::before { display: none; }
}

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