:root {
  --accent: #d97706;
  --accent-dark: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --c-gold: #f59e0b;
  --c-silver: #94a3b8;
  --c-platinum: #7dd3fc;
  --c-palladium: #c4b5fd;
  --c-copper: #fb923c;
  --bg-grad-1: #0f172a;
  --bg-grad-2: #1e293b;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #f8fafc;
  --shadow: 0 20px 60px -15px rgba(2, 6, 23, 0.55);
  --radius: 16px;
  --radius-sm: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 18px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% -10%, #334155 0%, transparent 55%),
              radial-gradient(1000px 700px at 110% 10%, #92400e 0%, transparent 45%),
              linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
}
.layout { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 22px; }

.card { width: 100%; max-width: 760px; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px 24px; border: 1px solid rgba(255,255,255,0.6); }
.card__header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.card__heading { flex: 1; min-width: 0; }
.logo { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-radius: 14px; box-shadow: 0 8px 20px -6px var(--accent-dark); }
.logo svg { width: 25px; height: 25px; }
.card__header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 3px; }

.card__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.inputs, .results { min-width: 0; }

/* Inputs */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 7px; }
.input-wrap { display: flex; align-items: center; background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: #fff; }
.affix { color: var(--text-muted); font-weight: 600; font-size: 1.05rem; padding-left: 14px; }
.affix--suffix { padding-left: 0; padding-right: 14px; }
.input-wrap input { flex: 1; width: 100%; min-width: 0; border: none; outline: none; background: transparent; padding: 12px 14px; font-size: 1.05rem; font-weight: 600; color: var(--text); font-family: inherit; }

.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; margin-bottom: 14px; }
.grid2 .field { margin-bottom: 0; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 7px; line-height: 1.5; }

select.input-el {
  width: 100%; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg);
  padding: 12px 34px 12px 14px; font-size: 0.92rem; font-weight: 600; color: var(--text); font-family: inherit; outline: none;
  cursor: pointer; appearance: none; -webkit-appearance: none; min-width: 0; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select.input-el:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background-color: #fff; }

.seg { display: flex; background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 10px 4px; border: none; border-radius: 9px; background: transparent; cursor: pointer;
  font-size: 0.85rem; font-weight: 700; color: var(--text-muted); font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg button.active { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 4px rgba(2,6,23,.12); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 12px 14px; background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius-sm); transition: border-color .15s; }
.check:hover { border-color: #cbd5e1; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto; }
.check span { font-size: 0.88rem; font-weight: 600; color: var(--text); line-height: 1.4; }

/* Results */
.results { background: linear-gradient(160deg, #0f172a, #1e293b); border-radius: var(--radius); color: #fff; padding: 22px 20px; }
.result-head { display: flex; flex-direction: column; gap: 2px; padding-bottom: 16px; border-bottom: 1px solid rgba(148,163,184,.22); margin-bottom: 16px; }
.result-label { font-size: 0.85rem; color: #cbd5e1; font-weight: 600; }
.result-value { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.02em; color: #fff; font-variant-numeric: tabular-nums; }

.savings { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.85rem; line-height: 1.5; margin-bottom: 16px; }
.savings b { font-variant-numeric: tabular-nums; }
.savings--good { background: rgba(16,185,129,.14); border: 1px solid rgba(16,185,129,.35); color: #a7f3d0; }
.savings--warn { background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.35); color: #fde68a; }

.breakdown { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.donut { width: 104px; height: 104px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(rgba(148,163,184,.25) 0 100%); -webkit-mask: radial-gradient(farthest-side, transparent 58%, #000 60%); mask: radial-gradient(farthest-side, transparent 58%, #000 60%); transition: background .35s ease; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 7px; font-size: 0.85rem; flex: 1; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 8px; color: #cbd5e1; }
.legend li b { color: #fff; margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }

.rrow { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; font-size: 0.92rem; color: #cbd5e1; gap: 12px; }
.rrow span { min-width: 0; }
.rrow b { color: #fff; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rrow.net b { color: #34d399; }
.rrow.total { border-top: 1px solid rgba(148,163,184,.22); margin-top: 4px; padding-top: 11px; }
.tax-note { font-size: 0.74rem; color: #94a3b8; margin-top: 14px; line-height: 1.5; }

/* Live price board */
.board { background: linear-gradient(160deg, #0f172a, #1e293b); border-radius: var(--radius); color: #fff; padding: 20px 20px 16px; }
.board__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.board__status { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: #94a3b8; min-width: 0; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #34d399; flex: 0 0 auto; animation: pulse 2s infinite; }
.pulse--stale { background: #f59e0b; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.board .seg { max-width: 320px; flex: 1 1 220px; border-color: rgba(148,163,184,.3); background: rgba(148,163,184,.12); }
.board .seg button { color: #94a3b8; }
.board .seg button.active { background: #fff; color: var(--accent-dark); }
.ptable { width: 100%; border-collapse: collapse; }
.ptable td { padding: 11px 4px; border-bottom: 1px solid rgba(148,163,184,.16); }
.ptable tr:last-child td { border-bottom: none; }
.pmetal { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 0.95rem; }
.pmetal .dot { width: 12px; height: 12px; border-radius: 50%; }
.pmetal .sym { color: #64748b; font-size: 0.75rem; font-weight: 600; }
.pprice { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.punit { text-align: right; color: #94a3b8; font-size: 0.75rem; font-weight: 600; white-space: nowrap; padding-left: 6px; width: 1%; }
.refresh { border: 1px solid rgba(148,163,184,.35); background: transparent; color: #cbd5e1; border-radius: 9px; padding: 7px 12px; font-size: 0.78rem; font-weight: 700; font-family: inherit; cursor: pointer; flex: 0 0 auto; }
.refresh:hover { background: rgba(148,163,184,.15); }
.refresh:disabled { opacity: 0.5; cursor: default; }
.board__note { font-size: 0.72rem; color: #64748b; margin-top: 10px; line-height: 1.5; }
.pgm { margin-top: 16px; border-top: 1px solid rgba(148,163,184,.22); padding-top: 12px; }
.pgm__label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; margin-bottom: 6px; }
.pgm .ptable td { padding: 8px 4px; }
.pgm .pmetal { font-weight: 600; font-size: 0.88rem; color: #cbd5e1; }
.pgm .pprice { font-weight: 700; font-size: 0.95rem; color: #e2e8f0; }
.badge { display: inline-block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: rgba(245,158,11,.16); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); white-space: nowrap; }

/* Price change badges + history chart */
.chg { font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; vertical-align: 2px; white-space: nowrap; }
.chg--up { color: #34d399; background: rgba(52,211,153,.12); }
.chg--down { color: #f87171; background: rgba(248,113,113,.12); }
.chart { margin-top: 18px; }
.chart__meta { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.chart__price { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; }
.chart__delta { font-size: 0.85rem; font-weight: 700; }
.chart__delta.chg--up, .chart__delta.chg--down { background: none; padding: 0; }
.seg--tabs { margin-bottom: 8px; }
.seg--ranges { margin-bottom: 10px; max-width: 100%; }
.seg--ranges button { font-size: 0.78rem; padding: 8px 2px; }
.chart__plot { position: relative; min-height: 140px; }
.chart__plot svg { width: 100%; height: 240px; display: block; touch-action: pan-y; }
.chart__plot .axis-t { fill: #64748b; font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart__tip { position: absolute; top: 6px; background: rgba(15,23,42,.92); border: 1px solid rgba(148,163,184,.35); color: #e2e8f0; font-size: 0.75rem; font-weight: 600; padding: 4px 9px; border-radius: 8px; pointer-events: none; white-space: nowrap; }
.chart__range-note { display: flex; justify-content: space-between; font-size: 0.72rem; color: #94a3b8; margin-top: 6px; font-variant-numeric: tabular-nums; }
.chart__empty { color: #94a3b8; font-size: 0.85rem; padding: 30px 0; text-align: center; }

/* Calculator result */
.calc-result { background: var(--input-bg); border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.calc-result .amount { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.calc-result .detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.price-src { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.price-src button { border: none; background: none; color: var(--accent-dark); font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.75rem; padding: 0; }

/* Ad + footer */
.adslot { width: 100%; max-width: 760px; min-height: 100px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.04); border: 1px dashed rgba(148,163,184,.35); border-radius: var(--radius-sm); color: rgba(148,163,184,.7); font-size: 0.8rem; }
/* Desktop-only side rail: renders only when the gutter is wide enough to never touch the card. */
.adrail { display: none; }
@media (min-width: 1440px) {
  .adrail {
    display: flex; align-items: center; justify-content: center;
    position: fixed; left: max(16px, calc(50vw - 380px - 332px)); top: 50%; transform: translateY(-50%);
    width: 300px; height: 600px;
    background: rgba(255,255,255,.04); border: 1px dashed rgba(148,163,184,.35);
    border-radius: var(--radius-sm); color: rgba(148,163,184,.7); font-size: 0.8rem;
  }
}
.site-footer { width: 100%; max-width: 760px; display: flex; justify-content: flex-end; align-items: center; gap: 18px; padding: 4px 6px 0; color: rgba(148,163,184,.75); font-size: 0.8rem; }
.site-footer .copy { margin-right: auto; }
.site-footer a { color: rgba(203,213,225,.85); text-decoration: none; font-weight: 500; }
.site-footer a:hover { color: #fff; text-decoration: underline; }

/* Document pages */
.doc { width: 100%; max-width: 720px; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 34px 30px; border: 1px solid rgba(255,255,255,.6); }
.doc__brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); margin-bottom: 22px; }
.doc__brand .logo { width: 40px; height: 40px; }
.doc__brand .logo svg { width: 21px; height: 21px; }
.doc__brand span { font-size: 1.15rem; font-weight: 700; }
.doc h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 6px; }
.doc .updated { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 20px; }
.doc .lead { font-size: 1.06rem; color: #475569; line-height: 1.7; margin-bottom: 14px; }
.doc h2 { font-size: 1.1rem; font-weight: 700; margin: 24px 0 8px; }
.doc h3 { font-size: 1rem; font-weight: 600; margin: 18px 0 4px; }
.doc p, .doc li { color: #334155; font-size: 0.96rem; line-height: 1.7; }
.doc p { margin-bottom: 12px; }
.doc ul, .doc ol { margin: 0 0 12px 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.doc a:hover { text-decoration: underline; }
.doc .callout { background: var(--accent-soft); border: 1px solid rgba(217,119,6,.25); border-left: 4px solid var(--accent); border-radius: 12px; padding: 16px 18px; margin: 20px 0; }
.doc .callout p { margin: 0; color: var(--accent-dark); font-weight: 500; }
.doc .faq h3 { font-size: 1.02rem; font-weight: 700; margin: 20px 0 4px; color: var(--text); }
.doc .table-wrap { overflow-x: auto; margin: 14px 0 20px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 360px; }
.doc th, .doc td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--text); font-weight: 700; background: var(--input-bg); }
.doc td { color: #334155; }
.doc td:first-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.doc .back { display: inline-block; margin-top: 24px; padding: 11px 20px; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem; }
.doc .back:hover { filter: brightness(1.08); text-decoration: none; }

@media (min-width: 760px) {
  .card__body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .card__header h1 { font-size: 1.55rem; }
}
@media (max-width: 440px) {
  .card { padding: 24px 20px 22px; }
  .doc { padding: 24px 20px 22px; }
  .result-value { font-size: 2rem; }
  .grid2 { grid-template-columns: 1fr; }
  .site-footer { justify-content: center; flex-wrap: wrap; gap: 12px; }
  .site-footer .copy { margin-right: 0; width: 100%; text-align: center; }
}
