/* The Scan & Go tracker (public/tracker.html): the site's look (app.css) with the tracker's own cards, charts and log.
   Status colours here are a ramp of their own (green through amber to red, public/tracker.js riskColor), set per card
   from the script; everything else takes the site's tokens, so both themes work. */

.sg-page { max-width: 1180px; padding-top: 20px; }
.sg-pad { padding: 14px 16px; }
.sg-prose p { margin: 0 0 10px; max-width: 72ch; }
.sg-prose p:last-child { margin-bottom: 0; }
.sg-prose p, .sg-prose li { color: var(--muted); font-size: 14.5px; }
.sg-lede { color: var(--ink) !important; font-size: 16px !important; }
.sg-points { margin: 4px 0 14px; padding-left: 20px; display: grid; gap: 6px; max-width: 72ch; }
.sg-points strong { color: var(--ink); }
.sg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0; }
.sg-msg { min-height: 1.4em; }
.sg-msg:empty { min-height: 0; }

/* ---- Passphrase, recovery code and unlock ---- */
#sgSetup, #sgRecovery, #sgUnlock, #sgReset, #sgPitch { max-width: 640px; width: 100%; justify-self: center; }
.sg-form { display: grid; gap: 12px; }
.sg-form p { margin: 0; }
.sg-form .field input { width: 100%; font-size: 16px; }
.sg-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sg-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.sg-code { margin: 4px 0; padding: 14px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); font: 600 clamp(15px, 4.4vw, 20px)/1.5 var(--mono); letter-spacing: .06em; text-align: center; overflow-wrap: anywhere; user-select: all; }
.sg-codein { font-family: var(--mono) !important; letter-spacing: .04em; text-transform: uppercase; }
.sg-more { border-top: 1px solid var(--line); padding-top: 10px; }
.sg-more summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink); min-height: 32px; display: flex; align-items: center; list-style: none; }
.sg-more summary::-webkit-details-marker { display: none; }
.sg-more summary::before { content: "›"; width: 1em; flex: none; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s; }
.sg-more[open] summary::before { transform: rotate(90deg); }
.sg-more > :not(summary) { margin-top: 10px; }

/* ---- Layout: the numbers in the wide column, the form, the log and the data beside them ---- */
.sg-app { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.sg-main, .sg-side { display: grid; gap: 16px; min-width: 0; }
@media (max-width: 999px) {
  /* A phone: the form first, then the numbers, the log and the data, and how it is kept last. */
  .sg-side, .sg-main { display: contents; }
  .sg-lapsed { order: 0; }
  #sgAddPanel { order: 1; }
  .sg-main > * { order: 2; }
  #sgLogPanel { order: 3; }
  #sgDataPanel { order: 4; }
  .sg-main > #sgHowPanel { order: 5; }
}
@media (min-width: 1000px) {
  .sg-app { grid-template-columns: minmax(0, 1fr) 380px; }
  .sg-lapsed { grid-column: 1 / -1; }
}
.sg-lapsed { border-color: var(--caution); background: var(--caution-bg); }
.sg-lapsed strong { color: var(--caution); }
.sg-sync { min-height: 24px; }

/* ---- Log a block ---- */
.sg-add { display: grid; gap: 12px; }
.sg-add .field input, .sg-add .field select { width: 100%; font-size: 16px; }
.sg-row2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; }
.sg-type { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sg-type button { min-height: 46px; padding: 6px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.sg-type .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .45; flex: none; }
.sg-type button[aria-pressed="true"] .dot { opacity: 1; }
.sg-type button.wk[aria-pressed="true"] { color: var(--open); border-color: var(--open); background: var(--open-bg); }
.sg-type button.sg[aria-pressed="true"] { color: var(--closed); border-color: var(--closed); background: var(--closed-bg); }
.sg-type button.cx[aria-pressed="true"] { color: var(--caution); border-color: var(--caution); background: var(--caution-bg); }
#sgAddBtn { min-height: 46px; font-size: 15px; }

/* ---- Rate cards ---- */
.sg-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 4px; }
/* Each card sizes its number to its own width (container units), so five across a narrow column still fit. */
.sg-card { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 11px; background: var(--surface-2); min-width: 0; container-type: inline-size; }
.sg-card.wide { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .sg-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sg-card.wide { grid-column: auto; }
}
.sg-clabel { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 6px; font: 600 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sg-status { font-size: 9.5px; letter-spacing: .1em; padding: 2px 6px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.sg-pct { font: 700 clamp(17px, 19cqi, 34px)/1 var(--display); letter-spacing: -.02em; margin: 10px 0 2px; color: var(--muted); white-space: nowrap; }
.sg-card.wide .sg-pct { font-size: clamp(22px, 12cqi, 42px); }
@media (min-width: 640px) { .sg-card.wide .sg-pct { font-size: clamp(17px, 19cqi, 34px); } }
.sg-track { position: relative; height: 6px; margin: 10px 0 8px; border-radius: 6px; background: var(--ground); border: 1px solid var(--line); overflow: hidden; }
.sg-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; transition: width .5s cubic-bezier(.2, .7, .2, 1); }
.sg-tick { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--line-2); }
.sg-meta { font-size: 12px; color: var(--muted); line-height: 1.35; }
@keyframes sg-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 45, 45, 0); }
  50% { box-shadow: inset 0 0 22px 0 rgba(255, 45, 45, .16), 0 0 18px 1px rgba(255, 50, 50, .32); }
}
@keyframes sg-blink { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.sg-card.critical { border-color: var(--closed); animation: sg-glow 1s ease-in-out infinite; }
.sg-card.critical .sg-pct { animation: sg-blink 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .sg-card.critical { animation: none; background: var(--closed-bg); }
  .sg-card.critical .sg-pct { animation: none; }
  .sg-fill { transition: none; }
}

/* ---- Charts ---- */
.sg-chart { padding: 8px 16px 14px; }
.sg-chart svg { display: block; width: 100%; height: auto; max-width: 100%; }
.sg-grid { stroke: var(--line); stroke-width: 1; }
.sg-line { fill: none; stroke: var(--line-2); stroke-width: 2; }
.sg-axis { fill: var(--muted); font: 500 11px var(--mono); }
.sg-val { font: 700 11.5px var(--mono); }
.sg-nodata { margin: 0; padding: 14px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.sg-subh { margin: 0; padding: 14px 16px 0; font: 600 13px/1.3 var(--body); color: var(--muted); }

/* ---- When they happen ---- */
.sg-patterns { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; padding: 14px 16px; }
.sg-pcard { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: var(--surface-2); }
.sg-phead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.sg-pwin { font: 600 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sg-pflag { font: 700 10.5px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.sg-pflag.clean { color: var(--open); }
.sg-pflag.found { color: var(--caution); }
.sg-pitem { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; display: grid; gap: 1px; }
.sg-pitem:first-of-type { border-top: 0; }
.sg-pitem span { color: var(--muted); font-size: 12px; }
.sg-pitem.lead strong { color: var(--caution); }
.sg-pnone { margin: 0; font-size: 13px; color: var(--muted); }

/* ---- Totals ---- */
.sg-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: 0 0 10px 10px; overflow: hidden; }
@media (min-width: 640px) { .sg-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sg-stat { background: var(--surface); padding: 11px 14px; min-width: 0; }
.sg-k { font: 600 11px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sg-v { font: 700 19px/1.2 var(--display); margin-top: 4px; }
.sg-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Pay per package: the trend ---- */
.sg-trend { margin: 14px 16px 0; padding: 14px 12px; border: 1px solid var(--line); border-radius: 10px; text-align: center; display: grid; gap: 4px; }
.sg-trend.none { color: var(--muted); background: var(--surface-2); }
.sg-tword { font: 800 clamp(19px, 5vw, 24px)/1.1 var(--display); font-stretch: 110%; letter-spacing: .02em; text-transform: uppercase; }
.sg-tsub { font-size: 13px; font-weight: 600; opacity: .9; }

/* ---- The log ---- */
.sg-log { list-style: none; margin: 0; padding: 0; }
.sg-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.sg-item:last-child { border-bottom: 0; }
.sg-idate { width: 58px; flex: none; color: var(--muted); font: 500 12.5px var(--mono); }
.sg-iamt { width: 64px; flex: none; font-weight: 700; }
.sg-pill { font: 600 10.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 7px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.sg-pill.wk { color: var(--open); background: var(--open-bg); }
.sg-pill.sg { color: var(--closed); background: var(--closed-bg); }
.sg-pill.cx { color: var(--caution); background: var(--caution-bg); }
.sg-per { font: 500 11.5px var(--mono); color: var(--accent); white-space: nowrap; }
.sg-grow { flex: 1; }
.sg-del { flex: none; width: 36px; height: 36px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 20px; line-height: 1; }
.sg-del:hover { color: var(--closed); background: var(--closed-bg); }
.sg-none { padding: 16px; color: var(--muted); font-size: 14px; }
.sg-more-row { border-top: 1px solid var(--line); }

/* ---- Your data ---- */
.sg-data { display: grid; gap: 10px; }
.sg-data > p { margin: 0; }
.sg-text { width: 100%; min-height: 140px; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface-2); color: var(--ink); font: 500 12px/1.45 var(--mono); resize: vertical; }

@media (max-width: 420px) {
  .sg-item { gap: 7px; padding-left: 12px; }
  .sg-idate { width: 50px; }
  .sg-iamt { width: 58px; }
  .sg-per { display: none; }
  .sg-type button { font-size: 13px; gap: 5px; }
}
