:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #1e293b;
  background: #f0f4fa;
  --blue: #1d4ed8;
  --blue-light: #dbeafe;
  --muted: #526580;
  --ink: #0f172a;
  --gradient: linear-gradient(145deg, #3b82f6, #1d4ed8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: 22px 12px; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  background: #fff;
  border-radius: 38px;
  box-shadow: 0 26px 52px rgba(19, 61, 120, .13), 0 8px 18px rgba(19, 61, 120, .06);
}

.view { padding: 26px 20px 20px; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 11px 18px -8px rgba(29, 78, 216, .55);
}
.brand-mark svg { display: block; }
.brand-large { width: 88px; height: 88px; border-radius: 28px; }
.brand-large svg { width: 49px; height: 49px; }
.brand-small { width: 42px; height: 42px; border-radius: 14px; }
.brand-small svg { width: 25px; height: 25px; }
.subtitle { color: var(--muted); font-size: 13px; line-height: 1.45; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 650; letter-spacing: .13em; }

.login-view { min-height: min(745px, calc(100dvh - 44px)); display: flex; flex-direction: column; }
.login-header { display: grid; justify-items: center; text-align: center; gap: 7px; padding-top: 36px; margin-bottom: 34px; }
.login-header .brand-mark { margin-bottom: 12px; }
.login-header h1 { font-size: 26px; font-weight: 750; letter-spacing: .02em; }
.login-form { display: grid; gap: 16px; padding-inline: 4px; }
.login-form label, .custom-dates label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; font-weight: 550; }
.login-form input, .custom-dates input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  font-size: 16px;
}
.login-form input::placeholder { color: #697b92; }
.login-form input:focus, .custom-dates input:focus, select:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
  background-color: #fff;
}
.primary {
  min-height: 42px;
  padding: 8px 14px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 0;
  border-radius: 24px;
  font-weight: 700;
}
.primary:focus-visible, .logout:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }
.primary:active:not(:disabled) { transform: translateY(1px); }
.login-button { min-height: 52px; margin-top: 8px; font-size: 17px; letter-spacing: .14em; box-shadow: 0 12px 20px -10px #1d4ed8; }
.view-footer { padding-top: 24px; text-align: center; color: #62748c; font-size: 12px; }
.login-view .view-footer { margin-top: auto; }

.dashboard-header, .brand, .section-heading, .day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dashboard-header { margin-bottom: 17px; }
.dashboard-header h1 { font-size: 20px; line-height: 1.25; }
.dashboard-header .subtitle { margin-top: 3px; font-size: 12px; }
.logout {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.logout svg { width: 18px; height: 18px; }
.logout:hover { background: #eff6ff; color: var(--blue); }

.filters { display: grid; gap: 9px; margin-bottom: 14px; }
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 7px 12px 7px 14px;
  border: 1px solid var(--blue-light);
  border-radius: 19px;
  background: #f0f7ff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.filter-row > span:first-child { flex: none; }
.mode-label { display: grid; gap: 2px; min-width: 0; }
.mode-label small { color: var(--muted); font-size: 11px; font-weight: 500; }
.filter-row select, .mode-pill {
  max-width: 68%;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font-size: 14px;
  font-weight: 650;
}
.filter-row select { cursor: pointer; text-overflow: ellipsis; }
.mode-pill { display: inline-flex; align-items: center; text-align: center; }
.custom-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.custom-dates input { min-height: 42px; padding: 6px 8px; font-size: 14px; border-radius: 13px; }
.date-hint { margin-inline: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.query-button { justify-self: end; min-width: 78px; min-height: 38px; }

.panel { padding: 12px; border: 1px solid var(--blue-light); border-radius: 23px; }
.summary-panel { margin-bottom: 12px; }
.section-heading { align-items: baseline; flex-wrap: wrap; margin: 0 1px 9px; }
.section-heading h2 { font-size: 15px; }
.section-note { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric { display: grid; align-content: start; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.summary .metric { min-height: 60px; padding: 10px 11px; border: 1px solid #e0ebf8; border-radius: 15px; background: #f5f8fc; }
.metric > span { color: var(--muted); font-size: 12px; line-height: 1.25; }
.metric > strong { color: var(--ink); font-size: 16px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.summary .hero, .summary .wide { grid-column: 1 / -1; }
.summary .hero { min-height: 72px; }
.summary .hero strong { font-size: clamp(24px, 7.5vw, 31px); }
.metric.income strong { color: #c72736; }
.metric.green strong { color: #087943; }
.metric.blue strong { color: var(--blue); }

.days { display: grid; gap: 9px; }
.day { padding: 11px 10px; border: 1px solid #e0ebf8; border-radius: 17px; background: #f5f8fc; }
.day-heading { flex-wrap: wrap; justify-content: space-between; margin-bottom: 9px; }
.day-date { color: var(--ink); font-size: 14px; }
.day-identity { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.day-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px 5px; }
.day-grid.is-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.day-grid .metric > span { font-size: 11px; }
.day-grid .metric > strong { font-size: 14px; }
.message { margin: 0 0 10px; padding: 9px 11px; border: 1px solid #fecaca; border-radius: 12px; background: #fff1f2; color: #a61b29; font-size: 13px; }
.login-form .message { margin: 0; }
.empty { padding: 22px 8px; border-radius: 14px; background: #f8fafc; color: var(--muted); text-align: center; font-size: 13px; }

@media (max-width: 470px) {
  body { padding: 0; background: #fff; }
  .app-shell { width: 100%; min-height: 100dvh; border-radius: 0; box-shadow: none; }
  .view { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .login-view { min-height: 100dvh; }
}

@media (max-width: 350px) {
  .view { padding-inline: 13px; }
  .summary .metric { padding-inline: 8px; }
  .day-grid .metric > strong { font-size: 13px; }
}
