:root {
  color-scheme: light;
  --paper: #f4f5fa;
  --card: #fff;
  --ink: #191b2c;
  --muted: #626779;
  --line: #e2e4ef;
  --accent: #5742a2;
  --accent-hover: #46358b;
  --accent-soft: #f1edff;
  --chart: #22213a;
  --chart-ink: #f6f6ff;
  --chart-muted: #c2c3df;
  --danger: #a62e42;
  --success: #247052;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, select { font: inherit; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #a48ef9; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mast { background: #fff; border-bottom: 1px solid var(--line); }
.mast-inner, .shell { max-width: 1162px; margin-inline: auto; padding-inline: 30px; }
.mast-inner { display: flex; align-items: center; justify-content: space-between; min-height: 70px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.125rem; font-weight: 720; text-decoration: none; }
.brand img, .login img { display: block; border-radius: 22%; }
.account { display: flex; align-items: center; gap: 9px; }
.secondary, .quiet {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 12px;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none;
}
.secondary { border-color: var(--line); }
.secondary:hover, .quiet:hover { background: var(--accent-soft); color: var(--accent); }
.shell { padding-top: 34px; padding-bottom: 48px; }
h1, h2, p { margin: 0; }
h1 {
  font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 600;
  line-height: 1.08; letter-spacing: -.045em;
}
h2 { font-size: 1.16rem; font-weight: 720; letter-spacing: -.025em; }
.intro { margin-bottom: 25px; }
.intro .error:not(:empty) { margin-top: 10px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 19px; }
.metric {
  text-align: left; min-width: 0; border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 17px; background: var(--card); color: var(--ink);
}
.metric[aria-pressed="true"] { border-color: #baa8f6; background: var(--accent-soft); }
.metric:hover { border-color: #baa8f6; }
.metric-name { display: block; margin-bottom: 8px; font-size: .88rem; font-weight: 680; line-height: 1.2; }
.metric-value { display: block; font-size: clamp(1.18rem, 2.5vw, 1.85rem); font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-value small { font-size: .75rem; letter-spacing: 0; color: var(--muted); font-weight: 550; white-space: nowrap; }
.dashboard {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, .56fr);
  grid-template-areas: "chart entry" "history entry"; gap: 18px; align-items: start;
}
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 19px; padding: 23px; background: var(--card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chart { grid-area: chart; background: var(--chart); border-color: var(--chart); color: var(--chart-ink); overflow: hidden; }
.chart-head { align-items: flex-start; margin-bottom: 13px; }
.chart-heading p { margin-top: 6px; color: var(--chart-muted); font-size: .875rem; }
.chart select { background-color: #302e4c; border-color: #514d72; color: var(--chart-ink); min-height: 38px; font-size: .875rem; width: auto; }
.chart-body { position: relative; height: 224px; border-bottom: 1px solid #474463; }
.chart-body canvas { width: 100%; height: 100%; display: block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--chart-muted); padding: 10px; }
.chart-foot { display: flex; min-height: 26px; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; color: var(--chart-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.chart-foot span:last-child { color: #d9d1fd; text-align: right; }
.entry { grid-area: entry; }
.entry form, .login { display: grid; gap: 11px; }
.entry form > label:first-child { margin-bottom: -7px; }
label { display: block; margin-bottom: 5px; font-size: .875rem; font-weight: 650; }
input:not([type="checkbox"]), select {
  min-height: 45px; width: 100%; min-width: 0; border-radius: 10px;
  border: 1px solid #cfd2e3; background-color: #fff; color: var(--ink); padding: 9px 10px;
}
select { padding-inline-end: 25px; }
input:disabled { opacity: .6; background: #f3f3f8; }
.form-row { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row > div { min-width: 0; }
.time-label { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.time-label button { padding: 0; border: 0; color: var(--accent); background: transparent; font-size: .82rem; font-weight: 650; }
.value-row { grid-template-columns: 1.15fr 1fr; }
.check-row { display: flex; align-items: center; gap: 8px; width: max-content; min-height: 28px; color: var(--muted); font-weight: 550; margin: 0; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.optional { font-size: .78rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.primary {
  display: inline-flex; justify-content: center; align-items: center; color: white; background: var(--accent);
  min-height: 46px; padding: 9px 18px; border: 1px solid transparent; border-radius: 10px; font-weight: 680;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .65; cursor: default; }
.form-status { min-height: 1.15em; color: var(--success); font-size: .875rem; }
.error, .form-status.failure { color: var(--danger); font-size: .875rem; }
.history { grid-area: history; }
.history .panel-head { margin-bottom: 7px; }
.muted, .history-empty { color: var(--muted); font-size: .875rem; }
.history-empty { padding-block: 15px 6px; }
.entries { list-style: none; padding: 0; margin: 0; }
.entries li + li { border-top: 1px solid var(--line); }
.entry-row {
  display: grid; width: 100%; padding: 12px 0; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 15px;
  text-align: left; border: 0; border-radius: 6px; background: transparent; color: var(--ink);
}
.entry-row:hover { background: #f6f4ff; }
.entry-value { font-weight: 720; font-size: 1.07rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-date { color: var(--muted); font-size: .87rem; text-align: right; align-self: center; }
.entry-description { grid-column: 1 / -1; color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.login-wrap, .authorize { display: grid; place-items: center; min-height: min(65vh, 520px); padding: 25px 0; }
.login, .authorize .panel { width: min(100%, 408px); padding: 27px; }
.login h1, .authorize h1 { font-size: 2rem; margin-block: 7px 10px; }
.authorize { padding: 50px 20px; }
.authorize p { margin-bottom: 14px; color: var(--muted); }
.authorize label input { margin-top: 5px; }
.authorize button { margin: 8px 4px 0 0; }
.authorize button[formnovalidate] { min-height: 46px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.loading { color: var(--muted); margin: 38px 0; text-align: center; }
@media (max-width: 760px) {
  .mast-inner, .shell { padding-inline: 15px; }
  .mast-inner { min-height: 60px; }
  .shell { padding-top: 22px; }
  .intro { margin-bottom: 17px; }
  .metrics { gap: 7px; margin-bottom: 12px; }
  .metric { border-radius: 12px; padding: 10px 8px; }
  .metric-name { font-size: .78rem; min-height: 2.34em; margin-bottom: 3px; }
  .metric-value { line-height: 1.05; }
  .metric-value small { display: block; margin-top: 3px; }
  .dashboard { grid-template-columns: minmax(0, 1fr); grid-template-areas: "entry" "chart" "history"; gap: 13px; }
  .panel { border-radius: 15px; padding: 15px; }
  .panel-head { margin-bottom: 12px; }
  .chart-body { height: 192px; }
  .entry-row { grid-template-columns: minmax(0, 1fr) auto; }
  .account { gap: 2px; }
}
