/* SugarWise admin panel — one stylesheet for the sign-in page and the panel.
   No external fonts, no CDN: the panel loads nothing but these files. */
:root {
  --bg: #0e1512;
  --bg2: #131d19;
  --card: #16211c;
  --line: #24332c;
  --line2: #2f4238;
  --tx: #e8f1ec;
  --tx2: #a9bdb2;
  --tx3: #7d928a;
  --acc: #6fd39b;
  --acc-dk: #2f7d55;
  --warn: #e5b45f;
  --bad: #e88a7a;
  --info: #7fb8e8;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 700px at 15% -10%, #17362a 0%, var(--bg) 55%) fixed;
  color: var(--tx);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.locked { overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--acc); }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--tx2); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden, [hidden] { display: none !important; }

/* ---------- sign in ---------- */
body.centered { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(150deg, #2f7d55, #6fd39b); color: #06231a;
  font-weight: 800; letter-spacing: 0.02em; font-size: 15px; flex: 0 0 auto;
}
.login-card h1 { font-size: 20px; margin-top: 16px; }
.login-card .sub { color: var(--tx2); font-size: 13px; margin-top: 4px; }
form.login { margin-top: 22px; display: grid; gap: 10px; }
label.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tx3); }
input[type="password"], input[type="search"], input[type="text"], select, textarea {
  width: 100%; background: #0f1915; color: var(--tx); border: 1px solid var(--line2);
  border-radius: 10px; padding: 11px 12px; font: inherit;
}
textarea { min-height: 68px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible, tr:focus-visible {
  outline: 2px solid var(--acc); outline-offset: 2px;
}
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px;
  background: var(--acc); color: #06231a; font: inherit; font-weight: 650;
  padding: 10px 14px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--tx); border-color: var(--line2); }
.btn.ghost:hover { border-color: var(--acc-dk); color: var(--acc); }
.btn.danger { background: transparent; color: var(--bad); border-color: #5a332d; }
.btn.danger:hover { background: #2a1714; }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; font-weight: 600; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.msg { color: var(--warn); font-size: 13px; min-height: 18px; }
.msg:empty { min-height: 0; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
  background: rgba(14, 21, 18, 0.82); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 18px; }
.brand .sub { color: var(--tx2); font-size: 12.5px; }
.fresh { color: var(--tx3); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.top-actions form { margin: 0; }
main { padding: 22px 24px 40px; display: grid; gap: 18px; max-width: 1280px; margin: 0 auto; }
/* Grid items default to min-width: auto, so one wide child (the tiles or the
   growth card) used to stretch the whole page past a phone screen. Let the
   tracks shrink; the auto-fit grids inside then fold to fewer columns. */
main > * { min-width: 0; }
.tiles, .card { overflow-wrap: anywhere; }

/* ---------- totals ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.tile {
  appearance: none; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; color: var(--tx); font: inherit;
  display: grid; gap: 2px; transition: border-color 0.15s ease, background 0.15s ease;
}
.tile:hover { border-color: var(--line2); background: #182620; }
.tile.on { border-color: var(--acc-dk); box-shadow: inset 0 0 0 1px var(--acc-dk); }
.tile .k { color: var(--tx3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.tile .v { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; }
.tile .h { color: var(--tx2); font-size: 12px; }
.tile.trial .v { color: var(--info); }
.tile.active .v { color: var(--acc); }
.tile.expired .v { color: var(--warn); }
.tile.blocked .v { color: var(--bad); }
.tile.deleted .v { color: var(--tx3); }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cardhead {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.cardtitle { font-size: 14px; }

/* ---------- tools ---------- */
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 260px; min-width: 190px; }
.search input { padding-right: 34px; }
.search .slash {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--tx3);
  border: 1px solid var(--line2); border-radius: 6px; padding: 1px 5px; pointer-events: none;
}
.select select { min-width: 175px; }
.seg { display: flex; gap: 4px; background: #101a16; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.chip {
  appearance: none; border: 0; background: transparent; color: var(--tx2);
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 10px;
  border-radius: 7px; cursor: pointer;
}
.chip:hover { color: var(--tx); }
.chip.on { background: var(--acc-dk); color: #eafff4; }

/* ---------- table ---------- */
.tablewrap { overflow: auto; border-radius: 10px; max-height: 64vh; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--tx3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 600; white-space: nowrap; border-bottom-color: var(--line2);
  position: sticky; top: 0; background: var(--card); z-index: 2;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1a2620; }
tbody tr:focus-visible { background: #1a2620; }
tbody tr.sel { background: #172a21; box-shadow: inset 3px 0 0 var(--acc); }
tbody tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
.who { display: grid; gap: 2px; max-width: 320px; }
.who .nm { font-weight: 600; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.who .id { font-family: var(--mono); font-size: 11.5px; color: var(--tx3); overflow-wrap: anywhere; }
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line2);
  display: inline-block; flex: 0 0 auto;
}
.dot.live { background: var(--acc); box-shadow: 0 0 0 3px rgba(111, 211, 155, 0.16); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.trial { color: var(--info); background: rgba(127, 184, 232, 0.1); border-color: rgba(127, 184, 232, 0.3); }
.pill.active { color: var(--acc); background: rgba(111, 211, 155, 0.1); border-color: rgba(111, 211, 155, 0.3); }
.pill.expired { color: var(--warn); background: rgba(229, 180, 95, 0.1); border-color: rgba(229, 180, 95, 0.3); }
.pill.blocked { color: var(--bad); background: rgba(232, 138, 122, 0.12); border-color: rgba(232, 138, 122, 0.35); }
.sub2 { color: var(--tx2); font-size: 12px; }
.rel { white-space: nowrap; }
.rowacts { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { color: var(--tx2); padding: 18px 6px 6px; display: grid; gap: 6px; }
.empty strong { color: var(--tx); font-size: 15px; }
.hint { color: var(--tx3); font-size: 12px; margin-top: 10px; }
.hint:empty { display: none; }

/* ---------- google sign-in ---------- */
.signin-steps {
  margin: 10px 0 0; padding-left: 20px; color: var(--tx2); font-size: 13px;
  display: grid; gap: 6px;
}
.signin-steps b { color: var(--tx); }
#signin-problem { color: var(--warn); word-break: break-word; }
#signin-card .mono { color: var(--tx); }

/* ---------- recently deleted ---------- */
ul.deleted { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
ul.deleted li {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; background: #121c18; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
}
.dl-main { display: grid; gap: 2px; min-width: 180px; }
.dl-main .nm { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dl-main .id { font-family: var(--mono); font-size: 11.5px; color: var(--tx3); }
.dl-meta { color: var(--tx2); font-size: 12.5px; display: flex; gap: 2px; flex-wrap: wrap; }

/* ---------- audit ---------- */
ol.audit { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
ol.audit li { display: flex; gap: 10px; color: var(--tx2); }
ol.audit .t { font-family: var(--mono); font-size: 11.5px; color: var(--tx3); white-space: nowrap; min-width: 74px; }

/* ---------- free plans ---------- */
.grants-intro { margin: 6px 0 12px; max-width: 78ch; }
.grant-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; align-items: end; margin-bottom: 10px;
}
.grant-field { display: grid; gap: 4px; color: var(--tx3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.grant-field input, .grant-field select { text-transform: none; letter-spacing: normal; font-weight: 400; }
.grant-submit { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grant-check { display: flex; gap: 6px; align-items: center; color: var(--tx2); font-size: 12.5px; }
.grant-key { font-family: var(--mono); font-size: 11.5px; color: var(--tx3); }
.grant-row-inactive td { opacity: 0.55; }
.hint.grant-bad { color: var(--bad); }

/* ---------- scan lab ---------- */
.scan-intro { margin: 6px 0 12px; max-width: 78ch; }
.scan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 12px; }
.scan-field { display: grid; gap: 4px; color: var(--tx3); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.scan-field select, .scan-field input[type="text"] { text-transform: none; letter-spacing: normal; font-weight: 400; }
.scan-field input[type="file"] {
  background: #121c18; border: 1px dashed var(--line2); border-radius: 9px;
  padding: 7px 9px; color: var(--tx2); font-size: 12.5px; width: 100%;
}
.scan-field input[type="file"]::file-selector-button {
  background: transparent; color: var(--acc); border: 1px solid var(--line2);
  border-radius: 7px; padding: 3px 8px; margin-right: 8px; font: inherit; cursor: pointer;
}
.scan-out { margin-top: 14px; display: grid; gap: 10px; }
.scan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.scan-headline { font-size: 15.5px; font-weight: 650; }
.scan-score { display: grid; gap: 4px; }
.scan-warn { color: var(--warn); font-size: 13px; }
.scan-bad { color: var(--bad); font-size: 13px; }
.scan-table { max-height: 40vh; }
.scan-table tbody tr { cursor: default; }
.scan-table tbody tr:hover { background: transparent; }

/* ---------- detail sheet ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(6, 12, 9, 0.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 30;
}
.sheet {
  width: min(760px, 100%); max-height: min(86vh, 900px); overflow: auto;
  background: var(--card); border: 1px solid var(--line2); border-radius: 18px;
  padding: 20px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.dhead { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.dhead h2 { font-size: 17px; overflow-wrap: anywhere; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.kv { background: #121c18; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.kv .k { color: var(--tx3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; }
.kv .v { margin-top: 3px; font-size: 13.5px; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.noteform { display: grid; gap: 8px; max-width: 560px; }
/* The raw user agent is long and has no spaces worth breaking on, so it wraps
   anywhere and keeps its own scroll box instead of stretching the sheet. */
.noteform .ua {
  background: #0f1915; border: 1px solid var(--line2); border-radius: 10px;
  padding: 9px 11px; overflow-wrap: anywhere; line-height: 1.5; color: var(--tx2);
  max-height: 120px; overflow: auto;
}
ul.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ul.events li {
  display: flex; gap: 10px; font-size: 13px; color: var(--tx2);
  border-left: 2px solid var(--line2); padding: 2px 0 2px 10px;
}
ul.events .t { font-family: var(--mono); font-size: 11.5px; color: var(--tx3); white-space: nowrap; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; z-index: 50; width: min(94vw, 560px);
}
.toast {
  display: flex; align-items: center; gap: 12px; width: fit-content; max-width: 100%;
  background: #1d2a24; border: 1px solid var(--line2); color: var(--tx);
  padding: 9px 12px 9px 16px; border-radius: 12px; font-size: 13.5px; opacity: 0;
  transform: translateY(8px); transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: var(--acc-dk); }
.toast.bad { border-color: #5a332d; }
.toast-text { overflow-wrap: anywhere; }
.toast-act {
  appearance: none; border: 1px solid var(--line2); background: transparent;
  color: var(--acc); font: inherit; font-weight: 700; font-size: 12.5px;
  padding: 4px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.toast-act:hover { border-color: var(--acc-dk); background: #172a21; }

.foot { color: var(--tx3); font-size: 12px; text-align: center; padding: 18px 24px 26px; }

@media (max-width: 900px) {
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  .tablewrap { max-height: none; }
}
@media (max-width: 720px) {
  main { padding: 16px 12px 32px; }
  .top { padding: 12px; }
  .tile .v { font-size: 21px; }
  .scroll-hint { display: none; }
}

/* ---- growth card -------------------------------------------------------
   Five small panels inside the same card: advice, funnel, features,
   retention and the forecast. Bars are plain spans sized from the API
   numbers, so the chart cannot drift from the text beside it. */
.gwrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.gbox { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg2); }
.gbox.wide { grid-column: 1 / -1; }
.gbox h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--tx3); margin-bottom: 10px; }
.gadvice { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gadv { border-left: 3px solid var(--acc-dk); padding-left: 10px; }
.gadvt { display: block; font-size: 14px; color: var(--tx); }
.gadvb { display: block; color: var(--tx2); font-size: 13px; margin-top: 2px; }
.gfrow { margin-bottom: 10px; }
.gfhead { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.gflab { font-size: 13px; color: var(--tx); }
.gfn { font-size: 12px; color: var(--tx2); font-variant-numeric: tabular-nums; }
.gfbar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 4px; }
.gffill { display: block; height: 100%; background: var(--acc); }
.gfstep { font-size: 11.5px; color: var(--tx3); }
.gfeatrow { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.gfeatrow:last-child { border-bottom: 0; }
.gtable { overflow-x: auto; }
.gret { border-collapse: collapse; width: 100%; font-size: 12px; }
.gret th { text-align: left; color: var(--tx3); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line2); }
.gret td { padding: 4px 5px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.gret td:first-child, .gret th:first-child { white-space: nowrap; }
.gfbars { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.gfb { flex: 1; background: var(--acc); border-radius: 2px 2px 0 0; opacity: .85; }
.gfb.fc { background: var(--info); opacity: .55; }
.gforecast .gfn { margin-top: 8px; display: block; }

/* A device that kept reporting after the operator deleted it: still out
there, still ignored, worth seeing. */
.sub2.warn { color: var(--warn); }

/* The narrow-screen rule above hides columns 3 and 4 on every table. The scan
   tables are small and purpose-built, so they keep all of theirs. */
@media (max-width: 900px) {
  .scan-table th, .scan-table td { display: table-cell; }
}

/* Five columns do not fit a phone. Without a floor the browser gives the dish
   name one character per line and still clips the last header, so the table
   keeps a readable width and the wrapper scrolls instead. */
.scan-table table { min-width: 540px; }
.scan-table th, .scan-table td.right { white-space: nowrap; }
.scan-table th:first-child, .scan-table td:first-child { min-width: 150px; }
