:root {
  color-scheme: light;
  --ink: #172630;
  --muted: #667581;
  --line: #e2eaf0;
  --paper: #eef3f7;
  --panel: rgba(255, 255, 255, 0.96);
  --green: #17bd96;
  --yellow: #f1c928;
  --orange: #f29416;
  --red: #e85b59;
  --neutral: #87959d;
  --tint: rgba(23, 189, 150, 0.14);
  --bg-start: #eefbf5;
  --bg-end: #e7f7ef;
  --current-accent: #17bd96;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 62% 48% at 9% 5%, var(--tint), transparent 72%);
  transition: background 700ms ease;
}

.app-shell {
  width: min(100%, 1720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) clamp(20px, 4vw, 62px) max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar, .brand, .top-actions, .update-status, .current-topline,
.period-row, .current-footer, .chart-heading-row, .legend,
.dialog-heading, .dialog-actions, .range-line { display: flex; align-items: center; }

.topbar {
  justify-content: space-between; gap: 20px; margin-bottom: clamp(20px, 3vh, 34px);
  min-height: 104px; padding: 18px clamp(20px, 3vw, 36px); border-radius: 27px;
  background: linear-gradient(120deg, #34d0dd 0%, #18b6ca 46%, #0798b1 100%);
  box-shadow: 0 15px 35px rgba(13, 136, 157, .16); overflow: hidden; position: relative;
}
.topbar::after { content: ""; position: absolute; width: 260px; height: 260px; right: 10%; top: -205px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 25px rgba(255,255,255,.06), 0 0 0 55px rgba(255,255,255,.045); pointer-events: none; }
.brand { gap: 14px; min-width: 0; }
.brand-icon {
  width: 50px; height: 50px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 17px; background: rgba(255,255,255,.9); box-shadow: 0 8px 20px rgba(1, 92, 105, .13);
}
.brand-icon svg { width: 27px; height: 27px; fill: #08a9a9; }
.eyebrow, .section-kicker { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.topbar .eyebrow { color: rgba(4, 61, 74, .73); }
.brand h1 { margin: 4px 0 0; color: #083946; font-size: clamp(1.14rem, 2vw, 1.55rem); letter-spacing: -.025em; }
.top-actions { gap: 10px; }
.update-status { gap: 9px; margin-right: 8px; color: rgba(5, 59, 73, .83); font-size: .88rem; font-weight: 700; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 100%; background: #087f67; box-shadow: 0 0 0 4px rgba(255, 255, 255, .32); }
.update-status.is-loading .status-dot { background: #d59b2c; animation: pulse 1.2s infinite; }
.update-status.is-error .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(202, 77, 78, .1); }
.icon-button {
  width: 46px; height: 46px; display: grid; place-items: center; padding: 0;
  border: 1px solid rgba(3, 90, 106, .13); border-radius: 15px; color: #073d49; background: rgba(255,255,255,.72);
  cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.icon-button:hover { transform: translateY(-1px); border-color: rgba(3, 90, 106, .25); background: white; }
.icon-button:active { transform: scale(.97); }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.notice {
  margin: 0 0 18px; padding: 13px 17px; border: 1px solid #eed6b1; border-radius: 14px;
  color: #6f4d19; background: rgba(255, 248, 232, .95); font-size: .95rem; line-height: 1.45;
}
.notice.is-error { border-color: #efc6c6; color: #793f3f; background: rgba(255, 242, 242, .96); }

.dashboard { display: grid; grid-template-columns: minmax(280px, .78fr) minmax(0, 1.62fr); gap: clamp(18px, 2.2vw, 32px); flex: 1; align-items: stretch; }
.panel {
  min-width: 0; border: 1px solid rgba(255, 255, 255, .96); border-radius: 28px;
  background: var(--panel); box-shadow: 0 17px 42px rgba(40, 67, 86, .075), 0 2px 8px rgba(40, 67, 86, .025);
  backdrop-filter: blur(14px);
}

.current-card { padding: clamp(26px, 3.2vw, 48px); display: flex; flex-direction: column; justify-content: center; overflow: hidden; position: relative; }
.current-card::after { content: ""; position: absolute; width: 260px; height: 260px; right: -145px; top: -145px; border: 1px solid var(--tint); border-radius: 50%; box-shadow: 0 0 0 20px var(--tint), 0 0 0 45px var(--tint); pointer-events: none; }
.price-gauge { width: 100%; margin: clamp(28px, 4vh, 45px) 0 0; padding: 7px 0 8px; position: relative; }
.price-gauge::before { content: ""; position: absolute; top: 0; right: 0; width: 39%; height: 42%; border-top: 5px solid var(--current-accent); border-right: 5px solid var(--current-accent); border-radius: 0 28px 0 0; }
.current-topline { justify-content: space-between; gap: 12px; z-index: 1; }
.price-category { padding: 7px 12px; border-radius: 99px; color: var(--category-ink, #405347); background: var(--category-bg, #edf1ed); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.current-price { margin: 0; text-align: center; }
.price-number { color: var(--current-accent); font-size: clamp(4.5rem, 8vw, 7.3rem); line-height: .98; letter-spacing: -.075em; font-weight: 780; font-variant-numeric: tabular-nums; white-space: nowrap; }
.unit { margin: 7px 0 0; color: #6d7984; font-size: clamp(1rem, 1.5vw, 1.2rem); font-weight: 650; }
.period-row { justify-content: center; gap: 10px; margin-top: clamp(20px, 3vh, 30px); font-size: clamp(1.08rem, 1.8vw, 1.38rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.period-icon { color: #11b7a0; font-size: 1.36em; line-height: 1; }
.weekly-summary { margin-top: 23px; padding-top: 19px; border-top: 1px solid rgba(225, 233, 239, .9); color: #6b7883; font-size: .94rem; line-height: 1.5; text-align: center; }
.weekly-summary strong { color: #243b48; font-variant-numeric: tabular-nums; }
.current-footer { justify-content: space-between; gap: 10px; margin-top: 22px; color: #82909a; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: #078a72; font-size: .7rem; letter-spacing: .13em; }
.live-indicator span { width: 6px; height: 6px; border-radius: 50%; background: #4fa66d; }

.chart-card { padding: clamp(23px, 2.7vw, 39px) clamp(22px, 2.9vw, 42px) 24px; display: flex; flex-direction: column; }
.chart-heading-row { justify-content: space-between; align-items: flex-start; gap: 20px; }
.chart-heading-row h2 { margin: 8px 0 0; font-size: clamp(1.34rem, 2.3vw, 1.9rem); letter-spacing: -.04em; }
.chart-subtitle { margin: 7px 0 0; color: var(--muted); font-size: .92rem; }
.chart-unit { margin-top: 2px; padding: 8px 11px; border-radius: 10px; background: #f1f6f7; color: #657781; font-size: .77rem; font-weight: 750; white-space: nowrap; }
.chart-wrap { position: relative; min-height: 260px; margin-top: clamp(22px, 3vh, 32px); overflow-x: auto; overflow-y: hidden; scrollbar-color: #c7d3c8 transparent; scrollbar-width: thin; }
.chart-bars { min-width: 620px; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); align-items: stretch; gap: clamp(3px, .65vw, 10px); padding: 8px 4px 0; }
.slot-column { display: grid; grid-template-rows: 1fr auto; min-width: 0; }
.slot-track {
  height: clamp(190px, 31vh, 280px); position: relative; min-width: 0; border-radius: 9px 9px 0 0;
  background: repeating-linear-gradient(to bottom, rgba(35, 70, 86, .075) 0, rgba(35, 70, 86, .075) 1px, transparent 1px, transparent 25%);
}
.slot-track::after { content: ""; position: absolute; left: 0; right: 0; top: var(--zero, 100%); border-top: 1px solid rgba(62, 87, 93, .3); }
.bar {
  position: absolute; left: 19%; width: 62%; min-height: 3px; border-radius: 7px 7px 4px 4px;
  background: var(--bar-color); box-shadow: 0 5px 11px color-mix(in srgb, var(--bar-color), transparent 72%);
  transition: height .4s ease, top .4s ease, filter .2s ease;
}
.bar.current { outline: 3px solid rgba(28, 58, 39, .88); outline-offset: 3px; z-index: 2; filter: saturate(1.16); }
.bar.negative { border-radius: 4px 4px 7px 7px; }
.bar-value { position: absolute; left: 50%; z-index: 3; min-width: 100%; transform: translate(-50%, -100%); text-align: center; color: #52656e; font-size: clamp(.62rem, .78vw, .75rem); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-value.negative { transform: translate(-50%, 0); }
.now-tag { position: absolute; left: 50%; top: -21px; transform: translateX(-50%); color: #087966; font-size: .56rem; font-weight: 900; letter-spacing: .08em; }
.slot-time { min-height: 31px; display: flex; justify-content: center; align-items: center; color: #788790; font-size: clamp(.61rem, .76vw, .72rem); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slot-column.current .slot-time { color: #087f72; font-weight: 900; }
.empty-chart { min-height: 260px; display: grid; place-items: center; color: #8a978d; text-align: center; padding: 24px; }
.daily-extremes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 3px 0 2px; }
.extreme-card { min-width: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; row-gap: 5px; padding: 14px 16px; border: 1px solid #e6edf1; border-radius: 15px; background: rgba(248, 251, 253, .92); }
.extreme-label { grid-column: 1 / -1; display: flex; align-items: center; gap: 7px; color: #71808a; font-size: .68rem; font-weight: 850; letter-spacing: .095em; }
.extreme-label i { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); }
.extreme-card.high .extreme-label i { background: var(--red); }
.extreme-card strong { color: #283e48; font-size: clamp(1.18rem, 1.8vw, 1.55rem); font-weight: 760; letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.extreme-time { justify-self: end; color: #788791; font-size: .77rem; font-weight: 650; white-space: nowrap; }
.legend { gap: clamp(11px, 2vw, 27px); flex-wrap: wrap; padding-top: 15px; color: #66746a; font-size: .78rem; font-weight: 650; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--neutral); }
.swatch.cheap { background: var(--green); }
.swatch.average { background: var(--yellow); }
.swatch.expensive { background: var(--orange); }
.swatch.very-expensive { background: var(--red); }
.threshold-note { margin: 11px 0 0; color: #87938a; font-size: .73rem; line-height: 1.45; }

.loading-view { flex: 1; min-height: 42vh; display: grid; align-content: center; justify-items: center; gap: 15px; color: #758278; font-weight: 650; }
.loader { width: 37px; height: 37px; border: 3px solid #dbe6dc; border-top-color: #378459; border-radius: 50%; animation: spin .8s linear infinite; }
.footer { display: flex; justify-content: center; align-items: center; gap: 9px; margin-top: 20px; padding: 8px 0 max(4px, env(safe-area-inset-bottom)); color: #89959c; font-size: .74rem; }
.footer a { color: #4f7580; font-weight: 650; text-decoration: underline; text-decoration-color: #b9cbd0; text-underline-offset: 3px; }
.footer a:hover { color: #126d78; }
.footer-separator { color: #c0c9c1; }

.settings-dialog { width: min(92vw, 480px); max-height: min(90vh, 720px); padding: 0; overflow: auto; border: 1px solid #e0e8e0; border-radius: 25px; color: var(--ink); background: #fbfdfb; box-shadow: 0 28px 90px rgba(18, 44, 27, .26); }
.settings-dialog::backdrop { background: rgba(20, 38, 26, .37); backdrop-filter: blur(5px); }
.settings-dialog form { padding: clamp(23px, 5vw, 34px); }
.dialog-heading { justify-content: space-between; margin-bottom: 25px; }
.dialog-heading h2 { margin: 7px 0 0; font-size: 1.65rem; letter-spacing: -.04em; }
.close-button { width: 39px; height: 39px; border-radius: 12px; font-size: 1.7rem; font-weight: 300; }
.field-label { display: block; margin: 18px 0 7px; color: #45564a; font-size: .87rem; font-weight: 750; }
.settings-dialog select { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid #d9e3da; border-radius: 12px; color: #24352a; background: white; }
.range-line { gap: 14px; }
.range-line input { flex: 1; accent-color: #318253; }
.range-line output { min-width: 55px; color: #3a5843; text-align: right; font-variant-numeric: tabular-nums; font-weight: 750; }
.field-help { margin: 9px 0 0; color: #748176; font-size: .79rem; line-height: 1.55; }
.dialog-actions { justify-content: flex-end; gap: 10px; margin-top: 28px; }
.button { min-height: 45px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 750; cursor: pointer; }
.button.secondary { color: #526257; background: #edf2ed; }
.button.primary { color: white; background: #246b43; box-shadow: 0 5px 14px rgba(36, 107, 67, .2); }
.button.primary:hover { background: #1d5a38; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 960px) {
  .dashboard { grid-template-columns: 1fr; }
  .current-card { min-height: 365px; }
  .chart-card { min-height: 480px; }
  .price-number { font-size: clamp(4.1rem, 12vw, 6.5rem); }
  .chart-wrap { min-height: 245px; }
  .slot-track { height: clamp(180px, 25vh, 250px); }
}

@media (max-width: 600px) {
  .app-shell { padding: max(13px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); }
  .topbar { gap: 8px; margin-bottom: 15px; }
  .brand { gap: 9px; }
  .brand-icon { width: 42px; height: 42px; border-radius: 14px; }
  .brand-icon svg { width: 23px; height: 23px; }
  .eyebrow { font-size: .61rem; }
  .brand h1 { font-size: 1rem; }
  .top-actions { gap: 6px; }
  .update-status { max-width: 106px; margin-right: 1px; font-size: .67rem; white-space: normal; line-height: 1.2; }
  .status-dot { flex: 0 0 auto; width: 7px; height: 7px; }
  .icon-button { width: 38px; height: 38px; border-radius: 12px; }
  .icon-button svg { width: 18px; height: 18px; }
  .dashboard { gap: 13px; }
  .panel { border-radius: 21px; }
  .current-card { min-height: 0; padding: 23px 21px; }
  .price-gauge { margin-top: 26px; }
  .price-number { font-size: clamp(3.7rem, 18vw, 5.8rem); }
  .period-row { margin-top: 22px; font-size: 1.05rem; }
  .weekly-summary { margin-top: 17px; padding-top: 14px; font-size: .83rem; }
  .current-footer { margin-top: 16px; }
  .chart-card { min-height: 0; padding: 21px 17px 18px; }
  .chart-heading-row h2 { font-size: 1.3rem; }
  .chart-subtitle { font-size: .82rem; }
  .chart-unit { padding: 6px 8px; font-size: .7rem; }
  .chart-wrap { margin-top: 16px; min-height: 220px; }
  .chart-bars { min-width: 610px; gap: 3px; }
  .slot-track { height: 195px; }
  .bar-value { font-size: .63rem; }
  .slot-time { font-size: .61rem; }
  .legend { gap: 10px 16px; font-size: .72rem; }
  .daily-extremes { gap: 8px; }
  .extreme-card { grid-template-columns: 1fr; padding: 12px 11px; column-gap: 6px; }
  .extreme-label { font-size: .58rem; letter-spacing: .07em; }
  .extreme-card strong { font-size: 1.1rem; }
  .extreme-time { justify-self: start; font-size: .67rem; }
  .threshold-note { font-size: .68rem; }
  .footer { flex-wrap: wrap; margin-top: 13px; font-size: .69rem; }
}

@media (display-mode: fullscreen) {
  .app-shell { padding-top: max(24px, env(safe-area-inset-top)); }
}

@media (orientation: landscape) and (min-width: 700px) {
  .dashboard { grid-template-columns: minmax(280px, .78fr) minmax(0, 1.62fr); }
  .current-card, .chart-card { min-height: 0; }
  .chart-wrap { overflow-x: hidden; }
  .chart-bars { min-width: 0; }
  .price-number { font-size: clamp(3.8rem, 6vw, 6.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
