/* Shift4 dashboard — visual system.
   Light/dark tokens, compact sticky header with a collapsible filter panel on phones,
   floating section menu, cards, tiles, tables, charts. No build step. */
:root {
  color-scheme: light;
  --page: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --ink: #121311;
  --ink-2: #4f504c;
  --muted: #7f807a;
  --grid: #e6e7e1;
  --axis: #c9cac1;
  --border: rgba(18, 19, 17, 0.10);
  --shadow: 0 1px 2px rgba(18, 19, 17, 0.04), 0 12px 32px -20px rgba(18, 19, 17, 0.25);
  --shadow-lg: 0 14px 44px -10px rgba(18, 19, 17, 0.30);
  --s1: #2a78d6; /* blue   - primary / selected day */
  --s2: #eb6834; /* orange - comparison */
  --s3: #1baf7a; /* aqua */
  --s4: #eda100; /* yellow */
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #6250d6;
  --s8: #e34948;
  --good: #006300;
  --bad: #d03b3b;
  --ghost: #9ec5f4;
  --header-h: 58px;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e0f11; --surface: #18191c; --surface-2: #202125; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8b8a84; --grid: #2a2b2f; --axis: #3a3b40;
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -20px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 14px 44px -10px rgba(0, 0, 0, 0.7);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --good: #0ca30c; --bad: #e66767; --ghost: #1c5cab;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e0f11; --surface: #18191c; --surface-2: #202125; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8b8a84; --grid: #2a2b2f; --axis: #3a3b40;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -20px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 14px 44px -10px rgba(0, 0, 0, 0.7);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --good: #0ca30c; --bad: #e66767; --ghost: #1c5cab;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
main { padding: 0 20px 96px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 16px; margin: 0; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 14.5px; margin: 0 0 12px; font-weight: 650; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; letter-spacing: -0.005em; }
h3 { font-size: 12.5px; margin: 16px 0 6px; color: var(--ink-2); font-weight: 650; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
svg.i { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- header ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1500px; margin: 0 auto; padding: 8px 20px; display: flex; align-items: center; gap: 16px; min-height: var(--header-h); position: relative; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--s1), var(--s7)); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; letter-spacing: 0.02em; flex: none; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15); }
.logo-chip { display: inline-flex; align-items: center; border-radius: 8px; padding: 2px 4px; flex: none; }
.logo-img { height: 30px; width: auto; display: block; }
.logo-chip.large { align-self: flex-start; padding: 6px 10px; margin-bottom: 4px; }
.logo-chip.large .logo-img { height: 54px; }
:root[data-theme="dark"] .logo-chip { background: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-chip { background: #fff; } }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; min-width: 0; }
.field { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px 6px 3px 10px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field select, .field input { font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); background: transparent; border: none; padding: 3px 2px; min-width: 0; }
.field select { cursor: pointer; }
.field:focus-within { border-color: var(--s1); }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 12px; line-height: 1.25; }
#status { font-size: 11.5px; color: var(--muted); }
#status.error { color: var(--bad); }
#account { display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; }
#filtersBtn { display: none; margin-left: auto; white-space: nowrap; flex: none; }
#filtersBtn .txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
#filtersSummary { font-weight: 600; }
#filtersSub { font-size: 10.5px; }
#filtersSub:empty { display: none; }

button { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; cursor: pointer; transition: border-color .15s, background .15s; }
button:hover { border-color: var(--s1); }
button:disabled { opacity: 0.6; cursor: default; }
select, input[type="date"], input[type="email"], input[type="password"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; }
button.primary { background: var(--s1); color: #fff; border-color: var(--s1); font-weight: 600; padding: 8px 16px; }
button.primary:hover { filter: brightness(1.08); }
button.link { border: none; background: none; color: var(--s1); padding: 0; text-decoration: underline; font-size: 12px; border-radius: 2px; }

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr)); gap: 10px; margin: 18px 0 6px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-height: 76px; box-shadow: var(--shadow); }
.tile .label { font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.tile .value { font-size: 22px; font-weight: 700; margin-top: 3px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
#rangeLabel { margin: 6px 2px 0; }

/* ---- sections and cards ---- */
.sectionTitle { display: flex; align-items: center; gap: 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 30px 0 -2px; font-weight: 700; scroll-margin-top: calc(var(--header-h) + 14px); }
.sectionTitle::after { content: ""; flex: 1; height: 1px; background: var(--grid); }
.grid { display: grid; gap: 14px; margin-top: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 18px; min-width: 0; position: relative; box-shadow: var(--shadow); }
.card > h2 { padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--grid); }
.card.loading::after { content: ""; position: absolute; inset: 0; z-index: 1; background: color-mix(in srgb, var(--surface) 65%, transparent); border-radius: var(--radius); }
.card.loading::before { content: ""; position: absolute; z-index: 2; top: 50%; left: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 2.5px solid var(--grid); border-top-color: var(--s1); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card .err { color: var(--bad); font-size: 12px; }
.chart { position: relative; height: 260px; }
.chart.short { height: 130px; }
.chart.tall { height: 340px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.toggle { margin-left: auto; display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.toggle button { font-size: 12px; padding: 3px 9px; border: none; background: transparent; color: var(--ink-2); border-radius: 7px; }
.toggle button:hover { color: var(--ink); }
.toggle button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.14); }

/* ---- tables ---- */
.tablewrap { overflow: auto; max-height: 360px; -webkit-overflow-scrolling: touch; border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; background: var(--surface); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.pos { color: var(--good); }
td.neg { color: var(--bad); }
tr.total td { font-weight: 650; border-top: 2px solid var(--axis); }
tr.sel td, td.sel { background: color-mix(in srgb, var(--s1) 10%, transparent); }
#table-compare th, #table-compare td, #table-daily th, #table-daily td { padding: 4px 6px; font-size: 12px; }
#table-compare th, #table-daily th { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
#table-compare td.pos, #table-compare td.neg, #table-daily td.pos, #table-daily td.neg { color: inherit; }
#table-compare .pos, #table-daily .pos { color: var(--good); }
#table-compare .neg, #table-daily .neg { color: var(--bad); }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; margin: 12px 0 6px; font-weight: 600; }
footer { text-align: center; padding: 12px 20px 110px; max-width: 900px; margin: 0 auto; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* ---- login ---- */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--page) 78%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 26px 26px 22px; width: 100%; max-width: 390px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; }
.panel .logo { width: 44px; height: 44px; border-radius: 13px; font-size: 15px; margin-bottom: 2px; }
.panel h2 { margin: 0; font-size: 18px; }
.panel label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.panel input { font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--ink); font-weight: 400; }
.panel input:focus { border-color: var(--s1); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--s1) 20%, transparent); }
.panel .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.panel .err { min-height: 1em; margin: 0; }

/* ---- minis, heatmap, misc ---- */
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr)); gap: 8px; margin: 2px 0 12px; }
.mini { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; }
.mini .label { font-size: 11px; color: var(--muted); font-weight: 600; }
.mini .value { font-size: 18px; font-weight: 700; margin-top: 1px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.mini .sub { font-size: 11px; color: var(--muted); }
.mini .sub.pos { color: var(--good); } .mini .sub.neg { color: var(--bad); }
table.heat th, table.heat td { padding: 3px 3px; font-size: 11px; text-align: center; border: 1px solid var(--surface); text-transform: none; letter-spacing: 0; }
table.heat td.cell { color: var(--ink); min-width: 22px; border-radius: 3px; }
table.heat th.dow { text-align: left; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; white-space: normal; }
td.warn { color: var(--s4); font-weight: 600; } td.bad { color: var(--bad); font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: color-mix(in srgb, var(--s1) 14%, transparent); color: var(--ink-2); }

/* ---- floating section menu ---- */
.fnav { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fnav-menu { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 1px; background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.fnav-menu a, .fnav-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 11px; border-radius: 9px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; border: none; background: none; white-space: nowrap; cursor: pointer; text-align: left; transition: background .12s, color .12s; }
.fnav-menu a:hover, .fnav-menu button:hover { background: var(--surface-2); color: var(--ink); }
.fnav-menu a[aria-current="true"] { background: color-mix(in srgb, var(--s1) 13%, transparent); color: var(--s1); font-weight: 650; }
.fnav-menu .sep { height: 1px; background: var(--grid); margin: 4px 8px; }
.fnav-toggle { display: none; width: 52px; height: 52px; border-radius: 50%; background: var(--s1); color: #fff; border: none; box-shadow: var(--shadow-lg); place-items: center; padding: 0; }
.fnav-toggle svg.i { width: 22px; height: 22px; stroke-width: 2; }
.fnav-toggle .ico-close, .fnav.open .fnav-toggle .ico-open { display: none; }
.fnav.open .fnav-toggle .ico-close { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- tablet: floating menu collapses to a button ---- */
@media (max-width: 1180px) {
  .fnav-toggle { display: grid; }
  .fnav-menu { display: none; min-width: 200px; }
  .fnav.open .fnav-menu { display: flex; animation: pop .16s ease-out; }
}

/* ---- phones and small tablets: header collapses to a Filters button ---- */
@media (max-width: 900px) {
  .topbar-inner { padding: 8px 14px; gap: 10px; }
  .brand-text .sub { max-width: 48vw; }
  #filtersBtn { display: inline-flex; padding: 6px 10px; font-size: 12.5px; }
  #filtersBtn[aria-expanded="true"] { border-color: var(--s1); color: var(--s1); }
  .controls { position: absolute; left: 0; right: 0; top: 100%; margin: 0; display: none; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 14px 14px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  .controls.open { display: grid; animation: pop .16s ease-out; }
  .field { width: 100%; justify-content: space-between; padding: 6px 8px 6px 12px; }
  .field select, .field input { flex: 1; text-align: right; width: 100%; }
  .field#customRange, .field.wide { grid-column: 1 / -1; }
  #customRange input { text-align: left; }
  #refresh { grid-column: 1 / -1; padding: 9px; }
  .meta { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding-top: 2px; }
}

@media (max-width: 640px) {
  main { padding: 0 12px 100px; }
  .brand-text .sub { max-width: 38vw; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
  .tile { min-height: 0; padding: 10px 12px; }
  .tile .value { font-size: 19px; }
  .grid { gap: 12px; }
  .card { padding: 14px 14px 16px; border-radius: 12px; }
  .card > h2 { font-size: 14px; }
  .toggle { margin-left: 0; width: 100%; }
  .toggle button { flex: 1; padding: 5px 4px; }
  .chart { height: 220px; }
  .chart.short { height: 120px; }
  .chart.tall { height: 280px; }
  .minis { grid-template-columns: repeat(2, 1fr); }
  .sectionTitle { margin-top: 24px; }
  .fnav { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .fnav-menu { min-width: 210px; max-height: calc(100vh - 110px); overflow: auto; }
  .fnav-menu a, .fnav-menu button { padding: 9px 12px; font-size: 13.5px; }
  footer { font-size: 11.5px; }
}
