:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --ink: #17221f;
  --muted: #687772;
  --line: #dce5e2;
  --brand: #087f5b;
  --brand-soft: #e8f7f1;
  --watch: #b7791f;
  --watch-soft: #fff8e5;
  --danger: #c2413a;
  --danger-soft: #fff0ef;
  --shadow: 0 16px 38px rgba(31, 53, 46, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { min-height: 44px; cursor: pointer; }

.shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.login-panel {
  width: min(430px, 100%);
  margin: clamp(50px, 14vh, 130px) auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 22px; border-radius: 13px; background: var(--brand); color: white; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.65rem, 4vw, 2.15rem); letter-spacing: -.035em; }
h2 { margin-bottom: 18px; font-size: 1.15rem; letter-spacing: -.015em; }
.eyebrow { margin-bottom: 5px; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }
.small { font-size: .84rem; }
label { display: block; margin: 22px 0 7px; font-size: .86rem; font-weight: 700; }
input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #b9c8c3; border-radius: 10px; color: var(--ink); background: white; }
input:focus, button:focus-visible { outline: 3px solid rgba(8, 127, 91, .22); outline-offset: 2px; }

button { padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; }
.primary { color: white; background: var(--brand); }
.secondary { color: var(--brand); border-color: #a7cbbf; background: white; }
.ghost { color: var(--muted); border-color: transparent; background: transparent; }
.full { width: 100%; margin-top: 16px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: .84rem; }

.dashboard { display: grid; gap: 22px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 5px 0 8px; }
.topbar h1 { margin-bottom: 4px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.period-tabs { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: #eaf0ee; }
.period { min-height: 38px; padding: 7px 12px; color: var(--muted); background: transparent; }
.period.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(30, 55, 47, .09); }

.notice, .quota-banner { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; }
.notice.error { color: var(--danger); border-color: #efb7b3; background: var(--danger-soft); }
.quota-banner.normal { color: #126548; border-color: #b5ddcf; background: var(--brand-soft); }
.quota-banner.watch, .quota-banner.warning { color: #805314; border-color: #ead092; background: var(--watch-soft); }
.quota-banner.blocked { color: #9d2f2a; border-color: #efb7b3; background: var(--danger-soft); }

.section-heading { display: flex; justify-content: space-between; align-items: end; }
.metric-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
.metric { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.metric strong { display: block; overflow-wrap: anywhere; font-size: clamp(1.28rem, 2vw, 1.75rem); letter-spacing: -.03em; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.panel { min-width: 0; padding: 21px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: 0 8px 24px rgba(31, 53, 46, .04); }
.panel-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.status-pill { padding: 6px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.quota-numbers { display: flex; justify-content: space-between; gap: 15px; align-items: baseline; margin: 7px 0 9px; }
.quota-numbers strong { font-size: 1.75rem; letter-spacing: -.04em; }
.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: #e7eeec; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .25s ease; }
.progress-fill.watch, .progress-fill.warning { background: var(--watch); }
.progress-fill.blocked { background: var(--danger); }
.thresholds { display: flex; justify-content: space-between; gap: 8px; margin-top: 13px; color: var(--muted); font-size: .69rem; }

.period-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.period-stat { padding: 12px; border-radius: 11px; background: #f5f8f7; }
.period-stat span { display: block; color: var(--muted); font-size: .73rem; }
.period-stat strong { display: block; margin-top: 5px; font-size: 1.18rem; }

.chart-panel { overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: .72rem; }
.dot { width: 8px; height: 8px; margin-left: 7px; border-radius: 50%; background: #3b82f6; }
.dot.success { background: var(--brand); }
.dot.failed { background: var(--danger); }
.chart { display: grid; grid-template-columns: repeat(var(--columns, 1), minmax(22px, 1fr)); gap: 8px; align-items: end; min-height: 220px; padding-top: 18px; overflow-x: auto; }
.chart-day { display: grid; min-width: 22px; height: 190px; grid-template-rows: 1fr auto; gap: 7px; text-align: center; }
.bars { display: flex; justify-content: center; align-items: end; gap: 2px; min-height: 150px; border-bottom: 1px solid var(--line); }
.bar { width: 24%; min-width: 3px; min-height: 2px; border-radius: 3px 3px 0 0; background: #3b82f6; }
.bar.success { background: var(--brand); }
.bar.failed { background: var(--danger); }
.chart-label { color: var(--muted); font-size: .65rem; white-space: nowrap; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: 10px 7px; border-bottom: 1px solid #edf1f0; text-align: left; overflow-wrap: anywhere; }
th { color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.number { text-align: right; }
.empty { color: var(--muted); text-align: center; }
.resource-grid, .cost-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.resource-item, .cost-item { min-width: 0; padding: 12px; border-radius: 11px; background: #f5f8f7; }
.resource-item span, .cost-item span { display: block; color: var(--muted); font-size: .72rem; }
.resource-item strong, .cost-item strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 1.05rem; }
.data-note { margin: 14px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .login-panel { padding: 24px 20px; }
  .topbar { display: block; }
  .actions { justify-content: flex-start; margin-top: 16px; }
  .period-tabs { width: 100%; }
  .period { flex: 1; }
  .actions > .secondary, .actions > .ghost { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 17px 15px; }
  .period-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { min-width: 100%; }
  .thresholds { flex-wrap: wrap; }
}

@media (max-width: 390px) {
  .metric { padding: 13px 11px; }
  .panel-title-row { display: block; }
  .status-pill { display: inline-block; margin-bottom: 10px; }
  .legend { margin-bottom: 10px; }
}
