/* LeadLab back office (leadlab-admin). Served as a FILE, never inline: the CSP on this
   origin is `default-src 'none'; style-src 'self'` -- an inline <style> or a style=""
   attribute is BLOCKED by the browser, not merely discouraged, and there is no
   'unsafe-inline' to fall back on. Every affordance in views.py is therefore a class
   in this file.

   Two more rules the CSP imposes on this stylesheet specifically:
     * NO url(...) of any kind -- no background images, no data: URIs, no webfonts.
       img-src and font-src both fall back to default-src 'none', so each one would be a
       blocked request. Selects keep their native arrow; icons are text or nothing.
     * NO @import. style-src 'self' allows this file; an @import pulls a second one.

   The first two thirds of this file are /opt/leadlab-console/static/console.css,
   deliberately unchanged, so the two services read as one product. Everything under
   "BACK OFFICE ADDITIONS" is what a writable service needs and a read-only one does not:
   form controls, a primary/danger button distinction, an actions column, and the
   confirmation page that stands in for the JavaScript dialog this origin cannot have. */
:root{
  --bg:#0b0e13; --panel:#11151d; --panel-2:#161b25; --line:#222a37;
  --ink:#e6ebf2; --ink-dim:#8b97a8; --ink-faint:#5b6675;
  --ok:#3ddc97; --warn:#f5b544; --bad:#ff6b6b; --accent:#5b8dff; --accent-dim:#2b4a8f;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
  --sans:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{background:var(--bg);color:var(--ink);font-family:var(--sans);font-size:14px;line-height:1.5;
     -webkit-font-smoothing:antialiased}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

header.top{border-bottom:1px solid var(--line);background:var(--panel);position:sticky;top:0;z-index:5}
.top-in{max-width:1180px;margin:0 auto;padding:12px 20px;display:flex;align-items:center;gap:22px;flex-wrap:wrap}
.brand{font-weight:650;letter-spacing:-.01em;font-size:15px;display:flex;align-items:center;gap:9px}
.dot{width:8px;height:8px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px rgba(61,220,151,.15)}
.dot.bad{background:var(--bad);box-shadow:0 0 0 3px rgba(255,107,107,.15)}
nav{display:flex;gap:2px;flex-wrap:wrap;margin-left:auto}
nav a{padding:6px 11px;border-radius:6px;color:var(--ink-dim);font-size:13px}
nav a:hover{background:var(--panel-2);color:var(--ink);text-decoration:none}
nav a.on{background:var(--accent-dim);color:#fff}
.logout{color:var(--ink-faint);font-size:12px}

main{max-width:1180px;margin:0 auto;padding:24px 20px 64px}
h1{font-size:22px;font-weight:650;letter-spacing:-.02em;margin:0 0 4px}
.sub{color:var(--ink-dim);margin:0 0 24px;max-width:74ch}
h2{font-size:14px;font-weight:640;letter-spacing:.02em;text-transform:uppercase;
   color:var(--ink-dim);margin:34px 0 12px}
h2:first-of-type{margin-top:24px}

.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(168px,1fr));gap:12px}
.tile{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:14px 16px}
.tile .n{font-family:var(--mono);font-size:26px;font-weight:600;letter-spacing:-.02em;
         font-variant-numeric:tabular-nums;line-height:1.15}
.tile .k{color:var(--ink-dim);font-size:12px;margin-top:3px}
.tile .note{color:var(--ink-faint);font-size:11px;margin-top:7px;line-height:1.45}
.n.ok{color:var(--ok)} .n.warn{color:var(--warn)} .n.bad{color:var(--bad)}
/* A zero that is honestly neutral. Without this rule tile(..., 0, tone="mute") renders
   in full --ink and a real zero reads as a healthy figure. */
.n.mute{color:var(--ink-faint)}

.panel{background:var(--panel);border:1px solid var(--line);border-radius:10px;overflow:hidden}
.scroll{overflow-x:auto}
table{border-collapse:collapse;width:100%;font-size:13px}
th{text-align:left;font-weight:600;color:var(--ink-dim);font-size:11px;text-transform:uppercase;
   letter-spacing:.04em;padding:10px 14px;border-bottom:1px solid var(--line);white-space:nowrap;
   background:var(--panel-2)}
td{padding:9px 14px;border-bottom:1px solid var(--line);vertical-align:top}
tr:last-child td{border-bottom:none}
tbody tr:hover{background:var(--panel-2)}
td.mono,th.mono,.mono{font-family:var(--mono);font-variant-numeric:tabular-nums}
td.num{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;white-space:nowrap}
td.wrap{white-space:normal;min-width:22ch;color:var(--ink-dim)}
/* Second line inside a table cell -- the address under a resolved building name, the id
   under a campaign title. A class because style="font-size:11px" is blocked here. */
.sub-line{font-size:11px;color:var(--ink-faint)}

.pill{display:inline-block;padding:1px 8px;border-radius:99px;font-size:11px;font-weight:600;
      border:1px solid transparent;white-space:nowrap}
.pill.ok{background:rgba(61,220,151,.12);color:var(--ok);border-color:rgba(61,220,151,.28)}
.pill.warn{background:rgba(245,181,68,.12);color:var(--warn);border-color:rgba(245,181,68,.28)}
.pill.bad{background:rgba(255,107,107,.12);color:var(--bad);border-color:rgba(255,107,107,.28)}
.pill.mute{background:var(--panel-2);color:var(--ink-faint);border-color:var(--line)}
.pill.accent{background:rgba(91,141,255,.12);color:var(--accent);border-color:rgba(91,141,255,.32)}

.note-box{border:1px solid var(--line);border-left:3px solid var(--accent);background:var(--panel);
          border-radius:8px;padding:12px 15px;color:var(--ink-dim);font-size:13px;margin:12px 0 0;
          max-width:88ch}
.note-box strong{color:var(--ink)}
.note-box.warn{border-left-color:var(--warn)}
.err{border-left-color:var(--bad);color:var(--bad);font-family:var(--mono);font-size:12px}

footer{color:var(--ink-faint);font-size:12px;margin-top:44px;border-top:1px solid var(--line);
       padding-top:16px;max-width:88ch;line-height:1.6}

/* Two or three panels read side by side. */
.cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:12px;
      align-items:start;margin-bottom:12px}
.cols>div{min-width:0}
h3{font-size:12px;font-weight:600;color:var(--ink-dim);margin:0 0 8px;letter-spacing:.02em}

/* =========================================================================
   BACK OFFICE ADDITIONS
   Everything below this line is what a WRITABLE service needs. The console has
   none of it because the console has one form (its login) and no buttons at all.
   ========================================================================= */

/* --- buttons -------------------------------------------------------------
   The console styles a bare `button` at width:100% because the only button it has
   is a full-width "Sign in". Doing that here would make every row action in every
   table stretch across the cell, so the base rule is inline-sized and the login
   button opts back into full width. Tone is a CLASS, whitelisted in views.py
   (primary / danger / quiet) -- a caller cannot invent one, so a database value can
   never pick which button colour it gets. */
button,.btn{display:inline-block;padding:8px 14px;border-radius:8px;
  border:1px solid var(--line);background:var(--panel-2);color:var(--ink);
  font-family:var(--sans);font-size:13px;font-weight:600;line-height:1.2;
  cursor:pointer;text-align:center;white-space:nowrap}
button:hover,.btn:hover{filter:brightness(1.12);text-decoration:none}
a.btn{text-decoration:none}
/* The ordinary action: save, create, run. */
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
/* Destructive or IRREVERSIBLE. Reads as a warning at rest and commits to it on hover,
   because the thing behind it -- publishing a batch, burning a delivery day -- cannot
   be undone. It is never the visually dominant control on a page. */
.btn.danger{background:rgba(255,107,107,.12);border-color:rgba(255,107,107,.45);color:var(--bad)}
.btn.danger:hover{background:var(--bad);border-color:var(--bad);color:#0b0e13}
/* Cancel-shaped: gets you out, does nothing. */
.btn.quiet{background:transparent;border-color:var(--line);color:var(--ink-dim)}
.btn.quiet:hover{color:var(--ink)}
.btn.small{padding:4px 9px;font-size:12px;border-radius:6px}
button[disabled],.btn[disabled]{opacity:.5;cursor:not-allowed;filter:none}

/* --- form controls -------------------------------------------------------
   One rule for every input type views.py can emit (see INPUT_KINDS), so a field
   that gains type="date" tomorrow does not silently render unstyled.
   No custom select arrow: drawing one needs a url(...) background image, and
   img-src is 'none' on this origin. The native arrow is fine. */
input[type=text],input[type=email],input[type=password],input[type=number],
input[type=date],input[type=search],input[type=tel],input[type=url],
select,textarea{
  width:100%;padding:9px 11px;border-radius:8px;border:1px solid var(--line);
  background:var(--bg);color:var(--ink);font-size:14px;font-family:var(--sans);
  line-height:1.4}
input:hover,select:hover,textarea:hover{border-color:#2c3648}
input:focus,select:focus,textarea:focus{border-color:var(--accent);outline:none;
  box-shadow:0 0 0 3px rgba(91,141,255,.18)}
input::placeholder,textarea::placeholder{color:var(--ink-faint)}
input:disabled,select:disabled,textarea:disabled{opacity:.55;cursor:not-allowed}
textarea{min-height:88px;resize:vertical;line-height:1.55}
select{appearance:auto}
label{display:block;font-size:12px;color:var(--ink-dim);margin-bottom:6px}

.field{margin:0 0 16px;max-width:52ch}
.field .help{color:var(--ink-faint);font-size:11px;margin-top:6px;line-height:1.5;max-width:60ch}
/* A required field is marked by the browser, not by a red asterisk we would have to
   keep in sync with the `required` attribute. */
.form{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:18px 20px;
      margin-top:12px;max-width:760px}
.form.stack .field{max-width:none}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:0 18px}
.form-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:18px;
  padding-top:16px;border-top:1px solid var(--line)}
/* An inline form is a single button living in a table cell or a toolbar. Forms are
   block-level, so three of them in one cell would stack without this. */
form.inline{display:inline-block;margin:0}

/* --- the actions column --------------------------------------------------
   Shrink-to-fit and hard against the right edge, so the data columns keep the width.
   Each action is its own <form> (no JavaScript to submit a shared one), hence flex. */
td.actions,th.actions{width:1%;white-space:nowrap;text-align:right}
.row-actions{display:flex;gap:6px;justify-content:flex-end;align-items:center;flex-wrap:wrap}
.row-actions .btn,.row-actions button{padding:4px 9px;font-size:12px;border-radius:6px}

/* --- result of the last mutation ----------------------------------------
   Every mutation ends in a 303, so the outcome arrives on the NEXT page. This is where
   it lands: top of the body, above the heading, one line. */
.banner{border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:8px;
  padding:10px 14px;margin:0 0 18px;font-size:13px;background:var(--panel);max-width:88ch}
.banner.ok{border-left-color:var(--ok);color:var(--ok)}
.banner.warn{border-left-color:var(--warn);color:var(--warn)}
.banner.bad{border-left-color:var(--bad);color:var(--bad)}
.banner.mute{color:var(--ink-dim)}
.banner.accent{color:var(--accent)}

/* --- the confirmation page ----------------------------------------------
   This page IS the confirm dialog. There is no window.confirm() here: no JavaScript
   exists on this origin and the CSP would block it if it did. So the interstitial has
   to carry its own weight -- it is narrow, it leads with what cannot be undone, and the
   facts under it are the ones an operator checks before committing. */
.confirm{max-width:640px;background:var(--panel);border:1px solid var(--line);
  border-left:3px solid var(--bad);border-radius:12px;padding:22px 24px;margin-top:8px}
.confirm h1{font-size:18px;margin-bottom:12px}
.confirm .note-box{margin-top:0}
.confirm .form-actions{justify-content:flex-start}

/* Label/value facts, on the confirmation page and on detail panels. */
dl.kv{display:grid;grid-template-columns:minmax(140px,auto) 1fr;gap:8px 18px;margin:16px 0 0;
  font-size:13px}
dl.kv dt{color:var(--ink-dim);font-size:12px}
dl.kv dd{margin:0;color:var(--ink)}

/* --- login ---------------------------------------------------------------
   Three fields, one form: address, password and authenticator code together. The layout
   is the console's; the extra fields are why this block differs at all. */
.login-wrap{min-height:100dvh;display:grid;place-items:center;padding:24px}
.login{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:28px;
       width:100%;max-width:370px}
.login h1{font-size:17px;margin-bottom:20px}
.login .field{max-width:none;margin-bottom:14px}
.login button{width:100%;margin-top:6px;padding:10px}
/* The six-digit code, spaced out so a transposed digit is visible before submitting. */
input.code{font-family:var(--mono);font-size:18px;letter-spacing:.28em;text-align:center}
.msg{margin-top:16px;font-size:13px;color:var(--bad);line-height:1.5}

@media (max-width:640px){
  .top-in{padding:10px 14px;gap:12px} nav{width:100%;margin-left:0} main{padding:18px 14px 48px}
  .tile .n{font-size:22px}
  .form{padding:16px 14px}
  .form-grid{grid-template-columns:1fr}
  dl.kv{grid-template-columns:1fr;gap:2px 0}
  dl.kv dd{margin-bottom:8px}
  /* On a phone the actions column would squeeze the data to nothing; let it wrap
     under its row's content instead of forcing a horizontal scroll. */
  td.actions,th.actions{width:auto}
  .row-actions{justify-content:flex-start}
}
