:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #091323;
  color: #f4f8ff;
  --panel: #111e31;
  --line: #26374e;
  --muted: #a9b9ce;
  --accent: #68e6d0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
.shell { width: min(calc(100% - 96px), 1480px); margin-inline: auto; }
.topbar { border-bottom: 1px solid #203047; background: #0e1a2c; }
.topbar-inner { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; gap: 12px; align-items: center; font-weight: 700; }
.brand-mark {
  background: var(--accent); color: #071d22; display: grid; place-items: center;
  width: 31px; height: 31px; border-radius: 8px; font-weight: 800;
}
.brand-divider { display: inline-block; width: 1px; height: 12px; background: var(--line); margin: 0 13px; }
.brand-detail { font-size: 13px; color: var(--muted); font-weight: 500; }
.account-actions { display: flex; align-items: center; gap: 16px; }
.source-badge { color: var(--muted); font-size: 12px; }
.bm-panel { position: relative; }
.bm-panel summary {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 11px;
  background: #15283d; border: 1px solid #344d65; border-radius: 8px;
  color: #dce9f9; font-size: 12px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.bm-panel summary::-webkit-details-marker { display: none; }
.bm-panel[open] summary { border-color: #518281; }
.chevron { width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.bm-panel[open] .chevron { transform: translateY(1px) rotate(225deg); }
.bm-popover {
  position: absolute; inset: calc(100% + 8px) 0 auto auto; z-index: 2; width: 215px;
  padding: 4px 12px; border: 1px solid #344d65; border-radius: 12px;
  background: #142438; box-shadow: 0 16px 36px #030b17a0;
}
.bm-popover ul { margin: 0; padding: 0; list-style: none; }
.bm-popover li { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 0; font-size: 13px; font-weight: 650; }
.bm-popover li + li { border-top: 1px solid var(--line); }
.bm-status { padding: 3px 8px; border-radius: 5px; background: #223751; color: #dce9f9; font-size: 11px; }
.bm-status[data-state="active"] { color: #a4f4d9; background: #214740; }
.bm-status[data-state="pending"] { color: #f8d99e; background: #4b3d2e; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 42%); gap: 32px; align-items: center;
  margin: 23px 0; padding: 24px 32px; border: 1px solid #31505a; border-radius: 18px;
  background: linear-gradient(112deg, #122f39, #152b3d 53%, #132134);
}
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .17em; margin: 0 0 9px; }
h1 { margin: 0; font-size: clamp(2.3rem, 4vw, 3.5rem); letter-spacing: -.045em; line-height: 1.05; }
.subtitle { margin: 11px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.delivery { min-width: 0; padding: 14px 16px; background: #0d2030; border: 1px solid #31505a; border-radius: 12px; }
.delivery-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.delivery h2 { margin: 0; font-size: 14px; font-weight: 600; }
.delivery strong { color: var(--accent); font-variant-numeric: tabular-nums; font-size: clamp(24px, 3vw, 35px); letter-spacing: -.04em; }
.delivery p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
progress { width: 100%; height: 8px; margin-top: 8px; appearance: none; border: 0; border-radius: 12px; background: #273d50; color: var(--accent); }
progress::-webkit-progress-bar { background: #273d50; border-radius: 12px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 12px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 12px; }
.controls { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.controls label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
select, button, input {
  background: var(--panel); border: 1px solid var(--line); color: inherit; border-radius: 8px;
  min-height: 39px; font: inherit; font-size: 13px; padding: 0 12px;
}
select { padding-right: 26px; }
button { background: #15283d; border-color: #344d65; color: #dce9f9; cursor: pointer; font-weight: 650; }
button span { font-size: 17px; margin-right: 3px; vertical-align: -1px; }
button:hover:not(:disabled) { background: #203b54; }
.quiet-button { min-height: 32px; font-size: 12px; }
:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.notice { border-left: 2px solid #376663; color: var(--muted); font-size: 13px; background: #0d1929; margin: 0 0 22px; padding: 10px 13px; }
.notice[data-state="error"] { border-color: #f19eac; color: #ffc7d0; background: #251c2a; }

.activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 23px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px 16px; margin-bottom: 11px; }
.activity-grid .section-heading { align-items: center; min-height: 27px; }
.section-heading h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.015em; }
.section-heading p, .section-heading > span { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.section-heading .trend-change {
  margin: 0; padding: 4px 8px; border-radius: 7px; background: #21324a;
  font-size: 11px; font-weight: 650;
}
.trend-change[data-direction="up"] { background: #173f3b; color: #a4f4d9; }
.trend-change[data-direction="down"] { background: #3b293b; color: #ffbdc5; }
.cards { display: grid; gap: 13px; }
.messages { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.messages:has(.remaining) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.today-section + section { margin-top: 22px; }
.today-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.today-cards .card {
  display: flex; align-items: center; justify-content: space-between; gap: 6px 12px;
  flex-wrap: wrap; min-height: 65px; padding-block: 10px;
}
.today-cards .value { margin: 0; font-size: 32px; }
.today-cards .errors .value { color: #ffb2ba; }
.card { background: var(--panel); border: 1px solid #26374b; border-radius: 13px; min-width: 0; padding: 15px 17px; }
.card.sent { border-color: #396965; background: linear-gradient(130deg, #17353e, #132438 85%); }
.card.remaining { border-color: #416383; background: linear-gradient(145deg, #1b324b, var(--panel) 82%); }
.card.remaining .icon { background: #264763; color: #bfddff; }
.card.remaining progress { display: block; margin: 6px 0 5px; height: 4px; }
.card.delivered .value { color: var(--accent); }
.card h3 { font-size: 14px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
.icon { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; color: var(--accent); background: #1c4148; font-size: 17px; font-weight: 700; }
.errors .icon { color: #ffabac; background: #3b293b; }
.pending .icon { color: #f2ce89; background: #3d342d; }
.manual .icon, .baseSize .icon { background: #21344e; color: #bdd2ee; }
.value { font-size: 43px; letter-spacing: -.045em; margin: 10px 0 4px; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.chart { margin: 0; padding: 25px 15px 30px; background: var(--panel); border: 1px solid #26374b; border-radius: 13px; }
.trend-chart { background: linear-gradient(125deg, #122438, #112235 65%, #122938); border-color: #32525c; }
.chart p { color: var(--muted); font-size: 13px; margin: 0; }
.chart-layout { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; }
.chart-axis { display: flex; flex-direction: column; justify-content: space-between; min-width: 21px; margin-block: -8px; text-align: right; color: var(--muted); font-size: 11px; }
.chart-grid {
  height: 137px; border-top: 1px solid #263b51;
  background: repeating-linear-gradient(to top, #263b51 0 1px, transparent 1px 20%);
}
.chart-columns { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 0; padding: 0; list-style: none; }
.chart-columns li { position: relative; display: grid; height: 100%; min-width: 0; justify-items: center; }
.chart-plot { width: min(52%, 112px); height: 100%; display: flex; flex-direction: column; justify-content: end; }
.chart-bar { position: relative; flex: 0 0 auto; border-radius: 6px 6px 0 0; background: linear-gradient(#5d95bb, #325b82); }
.chart-current .chart-bar { background: linear-gradient(#6ae8d0, #348f91); }
.chart-value { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-date { position: absolute; top: calc(100% + 7px); color: var(--muted); font-size: 11px; white-space: nowrap; }
.trend-grid { position: relative; }
#trend-canvas { position: absolute; inset: -18px 0 0; display: block; width: 100%; height: 155px; }
.trend-labels {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: absolute; top: calc(100% + 7px);
  left: 0; right: 0; margin: 0; padding: 0; list-style: none; text-align: center; color: var(--muted); font-size: 11px;
}
.history { border: 1px solid #26374b; border-radius: 10px; margin-top: 22px; background: #0e1a2b; }
.history summary { cursor: pointer; padding: 11px 15px; font-size: 13px; font-weight: 650; }
.history summary span { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--muted); }
.history p { color: var(--muted); font-size: 13px; margin: 0; padding: 0 15px 12px; }
.table-wrap { overflow: auto; margin: 0 15px 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
th:first-child { text-align: left; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
footer { display: flex; gap: 12px; justify-content: space-between; padding: 13px 0 20px; color: var(--muted); font-size: 12px; }

.login-page {
  min-height: 100svh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 24% 10%, #173e49, transparent 55%), #091323;
}
.login-panel {
  width: min(100%, 430px); background: #111e31; border: 1px solid #31505a; border-radius: 20px;
  padding: clamp(23px, 6vw, 39px); box-shadow: 0 22px 65px #030b17a0;
}
.login-panel h1 { margin-top: 25px; font-size: clamp(28px, 6vw, 37px); }
.login-form { display: grid; margin-top: 28px; }
.login-form label { font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.login-form input { width: 100%; min-height: 45px; font-size: 16px; background: #0c1728; margin-bottom: 16px; }
.primary-button { background: var(--accent); color: #0a2329; border-color: transparent; min-height: 44px; text-align: left; display: flex; justify-content: space-between; align-items: center; }
.primary-button:hover:not(:disabled) { background: #a3f3e5; }
.login-error { color: #ffbdc5; background: #332538; padding: 9px 11px; border-radius: 7px; margin: 0 0 14px; font-size: 13px; }

@media (max-width: 1050px) {
  .shell { width: calc(100% - 48px); }
  .card { padding-inline: 13px; }
  .messages:has(.remaining) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .messages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .activity-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}
@media (max-width: 530px) {
  .shell { width: calc(100% - 28px); }
  .brand-detail, .brand-divider { display: none; }
  .source-badge { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 19px; margin: 16px 0 19px; }
  .topbar-inner, .account-actions { gap: 8px; }
  .section-heading { flex-wrap: wrap; }
  .messages, .messages:has(.remaining) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-cards { grid-template-columns: minmax(0, 1fr); }
  .cards { gap: 9px; }
  .card h3 { gap: 5px; }
  .value { font-size: 34px; }
  .history summary span { display: block; margin: 3px 0 0 14px; }
}
