/* Track add-ons on top of theme.css (the ROI dashboard theme). Uses only theme variables:
   --ink --muted --faint --card --surface --surface-2 --border --border-strong --accent --accent-soft
   --good --good-soft --bad --bad-soft --warn --warn-soft --shadow */

/* Tabs and buttons rendered as links */
.tabs a.tab { text-decoration: none; display: inline-flex; align-items: center; }
a.act { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.act.danger { color: var(--bad); }
.saverow { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.page-in { animation: trk-up .45s cubic-bezier(.2,.8,.2,1) both; }
.page-head { margin: 4px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* Filters row (secondary filters under the day segment) */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.dayrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }

/* KPI grid */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.kpis .kpi { animation: trk-up .5s cubic-bezier(.2,.8,.2,1) both; }
.kpis .kpi:nth-child(2) { animation-delay: .05s; } .kpis .kpi:nth-child(3) { animation-delay: .1s; }
.kpis .kpi:nth-child(4) { animation-delay: .15s; } .kpis .kpi:nth-child(5) { animation-delay: .2s; }

/* Tables inside panels */
.panel.table-wrap { overflow-x: auto; padding: 0; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 9px 12px; text-align: left; white-space: nowrap; vertical-align: top; }
table.data td:first-child { white-space: normal; min-width: 230px; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]::after { content: "↕"; margin-left: 5px; opacity: .35; }
table.data th[data-dir="desc"]::after { content: "↓"; opacity: 1; color: var(--accent); }
table.data th[data-dir="asc"]::after { content: "↑"; opacity: 1; color: var(--accent); }
table.data tbody tr.row-in { animation: trk-up .4s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 18ms); }
table.data tbody tr.flash td { animation: trk-flash .8s ease; }
table.data tfoot td { font-weight: 700; border-top: 1px solid var(--border-strong); }
table.data.compact td, table.data.compact th { padding: 6px 10px; }
.num { text-align: right !important; }
.name { font-weight: 650; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
[data-copy] { cursor: copy; border-bottom: 1px dashed transparent; }
[data-copy]:hover { border-bottom-color: var(--muted); }

/* ROI colours (theme good/bad/warn) */
.r-great, .r-good { color: var(--good); font-weight: 700; }
.r-ok { color: var(--good); }
.r-flat { color: var(--warn); }
.r-bad, .r-bad2 { color: var(--bad); font-weight: 650; }
.r-none { color: var(--muted); }

.pill-active, .pill-ok { color: var(--good); }
.pill-failed { color: var(--bad); }
.pill-partial, .pill-running { color: var(--warn); }
.flag { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--bad); margin-top: 3px; }
.ok { color: var(--good); font-size: 12px; font-weight: 600; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 12px; margin: 0 0 14px; font-size: 13.5px; font-weight: 600; border: 1px solid; }
.alert-info { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-ok { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.alert-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.empty { color: var(--muted); padding: 26px 8px; text-align: center; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; align-items: end; }
.narrow { max-width: 480px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
textarea { width: 100%; resize: vertical; }
.secret { -webkit-text-security: disc; font-family: ui-monospace, monospace; }
.auth-card { max-width: 400px; margin: 10vh auto 0; }
.auth-card.panel, .auth-card { padding: 26px; }

/* Button loading state */
.act.is-loading, button.is-loading { pointer-events: none; opacity: .75; }
.act.is-loading::before, button.is-loading::before { content: ""; width: 13px; height: 13px; margin-right: 7px; display: inline-block; vertical-align: -2px;
  border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: trk-spin .7s linear infinite; }

/* Daily bars */
td.bars, th.bars { width: 32%; min-width: 170px; }
.bar { display: block; height: 7px; border-radius: 4px; margin: 3px 0; transform-origin: left; animation: trk-grow .7s cubic-bezier(.2,.8,.2,1) both; }
.bar-cost { background: var(--bad); } .bar-rev { background: var(--good); animation-delay: .08s; }

/* Hourly chart (Best hour to spend) */
.chart-kpis { display: flex; flex-wrap: wrap; gap: 14px 34px; padding: 6px 0; }
.chart-kpis .kpi { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
.hchart { position: relative; height: 190px; margin: 10px 0 4px 36px; border-bottom: 1px solid var(--border-strong); display: grid; grid-template-columns: repeat(24, 1fr); gap: 6px; align-items: end; }
.hchart .line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--faint); }
.hchart .yl { position: absolute; left: -36px; transform: translateY(-50%); font-size: 10px; color: var(--faint); }
.hbar { position: relative; border-radius: 3px 3px 0 0; min-height: 2px; transform-origin: bottom; animation: trk-bar .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 25ms); }
.hbar.win { background: var(--good); } .hbar.lose { background: var(--bad); } .hbar.none { background: var(--border); }
.hbar:hover { filter: brightness(1.2); }
.hbar .tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--card); color: var(--ink);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow); padding: 6px 8px; border-radius: 8px; font-size: 11.5px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 4; }
.hbar:hover .tip { opacity: 1; }
.hx { display: grid; grid-template-columns: repeat(24, 1fr); gap: 6px; margin-left: 36px; font-size: 10px; color: var(--faint); }
.hx span { text-align: center; }
.chart-note { margin-top: 14px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); border-left: 3px solid var(--warn); color: var(--muted); font-size: 13px; }
.chart-note b.g { color: var(--good); } .chart-note b.r { color: var(--bad); }

/* Toasts + busy overlay */
.toasts { position: fixed; z-index: 90; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--card); color: var(--ink); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); animation: trk-up .35s cubic-bezier(.2,.8,.2,1) both; cursor: pointer; font-size: 13.5px; }
.toast::before { content: "✓"; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--good-soft); color: var(--good); }
.toast.bad::before { content: "!"; background: var(--bad-soft); color: var(--bad); }
.toast.out { animation: trk-out .3s ease forwards; }
.busy { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); }
.busy[hidden] { display: none; }
.busy-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 360px; margin: 16px; padding: 26px 24px; border-radius: 16px;
  background: var(--card); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.busy-card small { color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: trk-spin .8s linear infinite; display: inline-block; }
.spinner.big { width: 38px; height: 38px; border-width: 3px; }
body.loading main { opacity: .55; transition: opacity .2s; pointer-events: none; }

@keyframes trk-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes trk-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes trk-spin { to { transform: rotate(360deg); } }
@keyframes trk-grow { from { transform: scaleX(0); } }
@keyframes trk-bar { from { transform: scaleY(0); } }
@keyframes trk-flash { from { background: var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; } }

/* Phones */
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters { flex-direction: column; align-items: stretch; }
  .dayrow .field, .dayrow .field input { width: 100% !important; }
  table.data td:first-child, table.data th:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); min-width: 165px; max-width: 200px; }
  .hchart, .hx { gap: 2px; } .hchart { height: 150px; }
  .toasts { left: 16px; right: 16px; max-width: none; }
  header.top { flex-direction: column; align-items: flex-start; gap: 10px; }
  header.top > div:last-child { text-align: left !important; width: 100%; }
  header.top > div:last-child > div:first-child, .saverow { justify-content: flex-start !important; }
}

/* Particle background canvas (same as ROI dashboard) */
.wrap { position: relative; z-index: 1; }
.livedot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 5px; vertical-align: 0; box-shadow: 0 0 0 0 var(--good); animation: trk-live 1.8s infinite; }
@keyframes trk-live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Fix: paint the theme background on <html> (full window, any page height) and keep <body>
   transparent so the particle canvas (z-index:-1) shows through, as on the ROI dashboard. */
html { min-height: 100%; background:
    radial-gradient(1100px 700px at 12% -8%, rgba(10,167,137,.16), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(20,161,80,.12), transparent 60%),
    linear-gradient(160deg,#eef4f1,#e6efe9) fixed !important; }
:root:not([data-theme="light"]) { background:
    radial-gradient(1100px 700px at 12% -8%, rgba(37,240,192,.16), transparent 60%),
    radial-gradient(900px 720px at 100% 0%, rgba(31,190,200,.12), transparent 60%),
    radial-gradient(1000px 780px at 50% 120%, rgba(37,240,192,.10), transparent 62%),
    #05080d fixed !important; }
body, :root[data-theme="dark"] body, :root:not([data-theme="light"]) body { background: transparent !important; min-height: 100vh; }
.kpi.hero .k-val.neg { color: var(--bad) !important; text-shadow: none !important; }
#bgfx { z-index: 0 !important; }
.wrap, .toasts, .busy { position: relative; z-index: 1; }
.toasts, .busy { position: fixed; }
.ecpm-box { border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 14px; padding: 12px 18px; text-align: center; background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.ecpm-box .l { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.ecpm-box .v { font-size: 24px; font-weight: 750; color: var(--accent); margin: 2px 0; }
.ecpm-box .s { font-size: 11px; color: var(--faint); }
.loglvl { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--good-soft); color: var(--good); }
.loglvl.warn { background: var(--warn-soft); color: var(--warn); } .loglvl.error { background: var(--bad-soft); color: var(--bad); }
.logmeta { font-family: ui-monospace, monospace; font-size: 11px; color: var(--faint); margin-top: 2px; white-space: normal; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips a { text-decoration: none; }

/* Campaign names: keep on one line inside the dashboard's 1240px width */
table.data td:first-child .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
table.data td:first-child .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* Wider content area (only change from the ROI dashboard layout) */
.wrap { max-width: 1560px !important; }
table.data td:first-child .name, table.data td:first-child .sub { max-width: 420px; }

/* Faint square grid, same lines/size as the ROI dashboard, drawn on the window background */
html::after { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(70,140,125,.10) 1px, transparent 1px), linear-gradient(90deg, rgba(70,140,125,.10) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(circle at 50% 28%, #000 0%, transparent 82%); mask-image: radial-gradient(circle at 50% 28%, #000 0%, transparent 82%); }
:root:not([data-theme="light"])::after { background-image: linear-gradient(rgba(70,140,125,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(70,140,125,.16) 1px, transparent 1px); opacity: .9; }

/* Align everything to the wider layout */
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi .k-val, .kpi .k-label, .kpi .k-sub { text-align: left !important; justify-content: flex-start !important; }
.kpi .k-val { font-size: 24px; }
.dayrow { align-items: center; }
#goalpanel .pbody, .panel .pbody { padding-left: 16px; padding-right: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Popups always above the page */
.busy { position: fixed !important; z-index: 9999 !important; }
.toasts { position: fixed !important; z-index: 9998 !important; }

/* Text sizes matched to the ROI dashboard */
.kpi .k-val { font-size: revert-layer; }
.kpis .kpi .k-val { font-size: 21px !important; }
.kpi.hero .k-val { font-size: 24px !important; }
table.data { font-size: 13.5px !important; }
table.data th { font-size: 10.5px !important; font-weight: 700 !important; letter-spacing: .08em !important; text-transform: uppercase; color: var(--faint) !important; padding: 10px 12px !important; }
table.data td { padding: 11px 12px !important; }
table.data td:first-child .name { font-size: 14px !important; font-weight: 600; }
table.data td:first-child .sub { font-size: 11px !important; }
table.data tfoot td { font-size: 14px !important; }
.panel-head h2 { font-size: 15px !important; }
.chart-kpis .k-label { font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace !important; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.chart-kpis .k-val { font-size: 17px !important; font-weight: 700; }
.chart-kpis .k-sub { font-size: 11px; color: var(--faint); }
.alert, .muted, .chart-note { font-size: 12.5px !important; }
.dayrow .daynote, .dayseg .dseg { font-size: 13px; }

/* Campaigns tab: boxes fill the row, tidy filters, readable wide table */
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.filters select, .filters input[type=text], .filters input[type=search], .filters input:not([type]) {
  height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; min-width: 170px; outline: none; }
.filters input[type=text], .filters input[type=search], .filters input:not([type]) { min-width: 240px; }
.filters select:focus, .filters input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filters button, .filters .act { height: 34px; }
.table-wrap { overflow-x: auto; max-height: 75vh; overflow-y: auto; }
table.data thead th { position: sticky; top: 0; z-index: 2; background: var(--card); white-space: nowrap; }
table.data td.num { white-space: nowrap; }
table.data td:first-child .name { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data tbody tr:hover td { background: var(--accent-soft); }

/* Hourly chart summary: small text, no boxes */
.panel .chart-kpis { padding: 14px 18px 4px !important; gap: 10px 36px !important; }
.panel .chart-kpis .kpi { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; min-height: 0 !important; }
.panel .chart-kpis .kpi .k-val { font-size: 15px !important; font-weight: 700 !important; margin: 3px 0 1px !important; line-height: 1.3 !important; }
.panel .chart-kpis .kpi .k-label { font-size: 10px !important; }
.panel .chart-kpis .kpi .k-sub { font-size: 11px !important; }
