:root {
  color-scheme: light;
  --page: #f6f9fc;
  --surface: #ffffff;
  --surface-soft: #f3f7fb;
  --text: #111827;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e8eef5;
  --line-strong: #d7e0ea;
  --black: #0f172a;
  --green: #16804f;
  --red: #d84c4c;
  --orange: #f59e0b;
  --blue: #0b83d8;
  --shadow: 0 10px 30px rgba(15, 23, 42, .06);
  --shadow-strong: 0 18px 45px rgba(15, 23, 42, .08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 1px 0 0;
  font-size: clamp(18px, 3.2vw, 26px);
  font-weight: 640;
  letter-spacing: -.04em;
  line-height: 1;
}
h2 { margin: 0; font-size: 14px; font-weight: 620; letter-spacing: -.015em; }
h3 { margin: 0; font-size: 12px; font-weight: 620; letter-spacing: -.01em; }

.page-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px clamp(8px, 1.6vw, 16px) 30px;
}

.app-header,
.brand-block,
.header-actions,
.summary-head,
.section-title-row,
.block-title,
.date-controls,
.range-tabs {
  display: flex;
  align-items: center;
}

.app-header {
  justify-content: space-between;
  gap: 7px;
  margin-bottom: 10px;
  padding: 9px 11px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(232,238,245,.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.brand-block { gap: 10px; min-width: 0; }
.brand-dot {
  width: 24px;
  height: 24px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0b83d8, #3bb2ff);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  flex: 0 0 auto;
}
.overline {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.muted { color: var(--muted); font-size: 11px; line-height: 1.5; }
.header-actions { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.status-pill,
.tiny-badge,
.period-chip,
.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  color: var(--muted);
  border-radius: 999px;
  white-space: nowrap;
}
.status-pill { min-height: 24px; padding: 2px 8px; font-size: 10px; font-weight: 600; }
.status-pill.ok { color: var(--green); border-color: #cfe9d8; background: #f6fef9; }
.tiny-badge { min-width: 23px; min-height: 20px; padding: 1px 7px; font-size: 10px; font-weight: 600; }
.state-badge { min-height: 20px; padding: 1px 7px; font-size: 10px; font-weight: 600; }
.state-badge.ok { color: var(--green); border-color: #cfe9d8; background: #f6fef9; }
.state-badge.bad { color: var(--red); border-color: #ffd3d3; background: #fff2f2; }
.state-badge.warn { color: var(--orange); border-color: #f3dfb9; background: #fff8e8; }

.icon-button,
.ghost-button,
.range-tab,
.login-form button {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 11px;
  font-size: 11px;
  font-weight: 600;
}
.icon-button:hover,
.ghost-button:hover,
.range-tab:hover { border-color: #98a2b3; background: #f9fafb; }
.login-form button { background: linear-gradient(135deg, #0b83d8, #0877c4); border-color: transparent; color: #fff; padding-inline: 16px; box-shadow: 0 10px 18px rgba(11,131,216,.18); }

.hidden { display: none !important; }
.dashboard { display: grid; gap: 10px; }

.login-panel {
  display: grid;
  gap: 12px;
  width: min(410px, 100%);
  margin: 46px auto;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-panel h2 { font-size: 18px; font-weight: 620; letter-spacing: -.025em; }
.login-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.login-form input,
.date-controls input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--page);
  color: var(--text);
  border-radius: 999px;
  outline: none;
}
.login-form input { padding: 8px 11px; }
.date-controls input { max-width: 126px; padding: 5px 8px; font-size: 11px; }
.login-form input:focus,
.date-controls input:focus { border-color: #98a2b3; box-shadow: 0 0 0 3px rgba(31, 41, 55, .08); }
.error-text { min-height: 16px; margin: 0; color: var(--red); font-size: 12px; }

.toolbar-card {
  position: sticky;
  top: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.range-tabs {
  gap: 4px;
  padding: 2px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.range-tab {
  min-height: 26px;
  border-color: transparent;
  background: transparent;
  padding: 4px 10px;
}
.range-tab.active { background: linear-gradient(135deg, #0b83d8, #0877c4); color: #fff; box-shadow: 0 8px 16px rgba(11,131,216,.20); }
.date-controls { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.date-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.summary-card,
.content-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-strong);
}
.summary-card { padding: 10px; }
.summary-head { justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.period-chip { gap: 6px; min-height: 25px; padding: 2px 9px; font-size: 11px; font-weight: 600; }
.period-chip b { color: var(--faint); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.summary-block {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}
.block-title { justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.block-title span { font-size: 12px; font-weight: 600; letter-spacing: -.015em; }
.block-title em { font-style: normal; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.metric {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.metric small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: clamp(14px, 2.4vw, 18px);
  letter-spacing: -.035em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.models-strip { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.section-title-row { justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.models-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 320px));
  gap: 6px;
  align-items: stretch;
}
.model-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: transparent;
}
.model-name {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-mini {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
}
.model-mini span,
.window-meta span,
.user-meta,
.quota-meta span,
.trend-empty {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
}
.model-mini b,
.window-meta b,
.quota-meta b { display: block; font-size: 11px; letter-spacing: -.02em; }
.refresh-note { margin: 8px 2px 0; color: var(--muted); font-size: 10px; }

.content-section { padding: 10px; }
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 7px;
}
.account-card,
.user-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.account-card { padding: 10px; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 5px;
}
.card-title {
  margin: 0;
  font-size: 12px;
  font-weight: 640;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.card-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.window-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.window-box {
  min-width: 0;
  padding: 8px;
  border-radius: 12px;
  background: #fbfdff;
  border: 1px solid var(--line);
}
.window-top {
  display: flex;
  justify-content: space-between;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 600;
}
.window-top b { font-size: 11px; }
.progress {
  height: 6px;
  border-radius: 999px;
  background: #edf5fc;
  overflow: hidden;
}
.progress i {
  display: block;
  width: var(--p, 0%);
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, linear-gradient(90deg, #22c55e 0%, #facc15 50%, #ef4444 100%));
}
.progress.thin { height: 5px; }
.progress.remaining { background: #edf2f7; }
.progress.balance i { width: 100%; }
.window-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
  margin-top: 8px;
}

.users-list { display: grid; gap: 8px; }
.user-card { width: 100%; padding: 10px; }
.user-main-grid {
  display: grid;
  grid-template-columns: .86fr 1.25fr 1.15fr;
  gap: 6px;
  align-items: stretch;
}
.user-info-panel,
.weekly-panel,
.user-trend-panel {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}
.info-list {
  display: grid;
  gap: 6px;
  margin: 0;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}
.info-row b { color: var(--text); overflow-wrap: anywhere; text-align: right; }
.weekly-row { display: grid; gap: 8px; }
.weekly-item { display: grid; gap: 6px; }
.quota-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  font-size: 10px;
}
.quota-line span { color: var(--muted); }
.quota-line b { font-size: 11px; }
.quota-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.trend-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.trend-metric {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
}
.trend-metric small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trend-metric strong { display: block; margin-top: 3px; font-size: 12px; letter-spacing: -.025em; overflow-wrap: anywhere; }
.trend-empty { margin: 0; }
.empty-state {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  color: var(--muted);
  font-size: 10px;
  background: transparent;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 100;
  max-width: min(320px, calc(100vw - 28px));
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(15,23,42,.88);
  color: #fff;
  font-size: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

@media (max-width: 820px) {
  .page-shell { padding-top: 12px; }
  .toolbar-card { align-items: stretch; flex-direction: column; }
  .range-tabs { align-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); }
  .date-controls { justify-content: space-between; }
  .date-controls label { flex: 1; }
  .date-controls input { max-width: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .accounts-grid { grid-template-columns: 1fr; }
  .user-main-grid { grid-template-columns: 1fr; }
  .window-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  body { font-size: 12px; }
  .page-shell { padding: 10px 7px 28px; }
  .app-header { align-items: flex-start; gap: 7px; padding: 9px; border-radius: 20px; }
  .header-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
  .brand-dot { width: 24px; height: 24px; border-radius: 9px; }
  .summary-card,
  .content-section { padding: 10px; border-radius: 18px; }
  .summary-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .models-row { grid-template-columns: 1fr; }
  .card-head { margin-bottom: 8px; }
  .login-form { grid-template-columns: 1fr; }
  .login-form button { width: 100%; }
  .user-card,
  .account-card { padding: 9px; border-radius: 14px; }
  .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 370px) {
  .metric-grid,
  .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-controls { flex-direction: column; align-items: stretch; }
}
