/* ─────────────────────────────────────────────────────────────────────────────
   command.css — BuildEX Solutions | Command

   Palette and type are lifted from the portal (siteline/interface/auth.php)
   so Command reads as the same product: Bebas Neue for headings and buttons,
   DM Sans for body copy, Roboto Mono for labels and data.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg:            #0d1117;
  --panel-bg:      #111820;
  --panel-bg-2:    #0f151d;
  --panel-border:  #1c2a3a;
  --text-primary:  #dce6f0;
  --text-muted:    #7d93aa;
  --text-dim:      #334d66;
  --radius:        6px;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   rgba(37, 99, 235, .14);
  --accent-text:   #7ea6ff;

  --ok:            #22c55e;
  --ok-soft:       rgba(34, 197, 94, .14);
  --warn:          #f59e0b;
  --warn-soft:     rgba(245, 158, 11, .14);
  --bad:           #ef4444;
  --bad-soft:      rgba(239, 68, 68, .14);

  --font-head:     'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-body:     'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:     'Roboto Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  color-scheme: dark;
}

/* ── Light mode ───────────────────────────────────────────────────────────────
   head.php puts .light-mode on <html> before first paint, from the saved choice
   (localStorage ct-theme, else the portal's bdx-theme); the sun/moon button in
   the top bar — or the floating one on pages without a bar — switches it.
   These are the portal's light values, so the two read as one product. Every
   rule below is on var()s, so this block is the whole theme; the handful of
   literal colours that follow it are the ones a light page needs darker. */
:root.light-mode {
  color-scheme: light;
  --bg:            #f0f2f5;
  --panel-bg:      #ffffff;
  --panel-bg-2:    #f4f7fa;
  --panel-border:  #cfd8e3;
  --text-primary:  #0f1923;
  --text-muted:    #51677d;
  --text-dim:      #8a9bb0;
  --accent-soft:   rgba(37, 99, 235, .10);
  --accent-text:   #1d4ed8;
  --ok:            #16a34a;
  --ok-soft:       rgba(22, 163, 74, .12);
  --warn:          #d97706;
  --warn-soft:     rgba(217, 119, 6, .12);
  --bad:           #dc2626;
  --bad-soft:      rgba(220, 38, 38, .10);
}
:root.light-mode .brand:hover { color: var(--accent); }
:root.light-mode .btn.good, :root.light-mode .btn.good:hover { color: #fff; }
:root.light-mode .notice.err  { color: #991b1b; }
:root.light-mode .notice.ok   { color: #166534; }
:root.light-mode .notice.warn { color: #92400e; }

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius); flex: 0 0 auto;
  border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.theme-toggle:hover { background: var(--panel-bg-2); color: var(--text-primary); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .ico-moon { display: none; }                 /* a dark page offers the sun … */
:root.light-mode .theme-toggle .ico-sun  { display: none; }   /* … a light one the moon */
:root.light-mode .theme-toggle .ico-moon { display: inline; }
.theme-toggle.floating { position: fixed; top: 14px; right: 14px; z-index: 50; background: var(--panel-bg); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 400;
  letter-spacing: .04em;
  margin: 0 0 .4em;
  line-height: 1.1;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.wrap-narrow { max-width: 760px; }
.wrap-wide   { max-width: 1640px; }   /* table pages (admin/agents.php) — the whole table, no sideways scroll */

/* ── Modal (<dialog class="modal">) ──────────────────────────────────────── */
dialog.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 20px 22px; border: 1px solid var(--panel-border); border-radius: 10px;
  background: var(--panel-bg); color: var(--text-primary); box-shadow: 0 24px 64px rgba(0,0,0,.55);
}
dialog.modal::backdrop { background: rgba(5, 9, 14, .62); }
:root.light-mode dialog.modal { box-shadow: 0 24px 64px rgba(15,25,35,.22); }
:root.light-mode dialog.modal::backdrop { background: rgba(15, 25, 35, .35); }
dialog.modal .panel-head { margin-bottom: 14px; }
dialog.modal select[multiple] { width: 100%; }

.row      { display: flex; gap: 16px; flex-wrap: wrap; }
.row > *  { min-width: 0; }
.grow     { flex: 1 1 0; }
.stack    { display: flex; flex-direction: column; gap: 16px; }
.between  { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ── Site header ──────────────────────────────────────────────────────────── */
#site-header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  position: sticky; top: 0; z-index: 40;
}
#site-header .bar {
  max-width: 1640px; margin: 0 auto; padding: 0 20px;   /* as wide as .wrap-wide, so brand + nav + account fit one row on a laptop */
  display: flex; align-items: center; gap: 24px; min-height: 58px; flex-wrap: wrap;
}
.brand {
  font-family: var(--font-head); font-size: 1.45rem; letter-spacing: .08em;
  color: var(--text-primary); text-decoration: none; white-space: nowrap;
}
.brand:hover { text-decoration: none; color: #fff; }
/* The top bar's brand is the marketing site's wordmark — "BuildEX" in its black
   block and "Solutions" beside it, Archivo, exactly as buildexsolutions.com's
   .wordmark/.mark — followed by "- COMMAND" in Command's display face. The
   sign-in cards keep the stacked form (.brand small) below. */
#site-header .brand { display: inline-flex; align-items: center; gap: .5rem; letter-spacing: 0; }
#site-header .brand .mark {
  display: inline-flex; align-items: center; background: #000; color: #fff;
  font-family: 'Archivo', 'DM Sans', 'Helvetica Neue', Arial, sans-serif; font-weight: 800;
  font-size: 1.0625rem; letter-spacing: -.025em; line-height: 1; padding: .5rem .62rem .55rem;
}
#site-header .brand .word {
  font-family: 'Archivo', 'DM Sans', 'Helvetica Neue', Arial, sans-serif; font-weight: 400;
  font-size: 1.0625rem; letter-spacing: -.01em; color: var(--text-muted);
}
#site-header .brand .sep { font-family: var(--font-body); font-size: 1rem; color: var(--text-dim); }
#site-header .brand .app {
  font-family: var(--font-head); font-size: 1.45rem; letter-spacing: .08em; line-height: 1;
  text-transform: uppercase; color: var(--text-primary); padding-top: 2px;   /* Bebas sits high; nudge to the mark's centre */
}
#site-header .brand:hover .app { color: #fff; }
:root.light-mode #site-header .brand .word { color: #575757; }               /* the site's slate */
:root.light-mode #site-header .brand:hover .app { color: var(--accent); }
.brand small {
  display: block; font-family: var(--font-mono); font-size: .58rem;
  letter-spacing: .18em; color: var(--text-dim); text-transform: uppercase; margin-top: -4px;
}

.nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.nav a {
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 7px 12px; border-radius: var(--radius); text-decoration: none;
}
.nav a:hover { color: var(--text-primary); background: var(--panel-bg-2); text-decoration: none; }
.nav a.active { color: var(--text-primary); background: var(--accent-soft); }

.whoami {
  font-family: var(--font-mono); font-size: .7rem; color: var(--text-dim);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.whoami b { color: var(--text-muted); font-weight: 500; }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.panel-head h2, .panel-head h3 { margin: 0; }

.label {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim); display: block; margin-bottom: 4px;
}
.muted { color: var(--text-muted); }
.dim   { color: var(--text-dim); }
.mono  { font-family: var(--font-mono); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ── Chips / state badges ─────────────────────────────────────────────────── */
.chip {
  display: inline-block; font-family: var(--font-mono); font-size: .64rem;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--panel-bg-2); color: var(--text-muted); border: 1px solid var(--panel-border);
}
.chip.ok      { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.chip.warn    { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.chip.bad     { background: var(--bad-soft);    color: var(--bad);    border-color: transparent; }
.chip.info    { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-dim); text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--panel-border); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--panel-bg-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--panel-bg-2); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%;
  background: var(--panel-bg-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body); font-size: .95rem;
  padding: 9px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; }
input[disabled], select[disabled], textarea[disabled] { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; }

label.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .9rem; color: var(--text-muted); cursor: pointer;
}
label.check input { width: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-size: 1rem; letter-spacing: .06em;
  padding: 9px 18px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn.ghost { background: transparent; border-color: var(--panel-border); color: var(--text-muted); }
.btn.ghost:hover { background: var(--panel-bg-2); color: var(--text-primary); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #dc2626; }
.btn.good { background: var(--ok); color: #05230f; }
.btn.good:hover { background: #16a34a; color: #05230f; }
.btn.small { font-size: .82rem; padding: 6px 12px; }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── Notices ──────────────────────────────────────────────────────────────── */
.notice {
  border-radius: var(--radius); padding: 11px 14px; font-size: .9rem;
  border: 1px solid var(--panel-border); background: var(--panel-bg-2);
  margin-bottom: 16px;
}
.notice.err  { border-color: rgba(239,68,68,.4);  background: var(--bad-soft);  color: #fca5a5; }
.notice.ok   { border-color: rgba(34,197,94,.4);  background: var(--ok-soft);   color: #86efac; }
.notice.warn { border-color: rgba(245,158,11,.4); background: var(--warn-soft); color: #fcd34d; }

/* ── Progress bars (upload buckets) ───────────────────────────────────────── */
.meter {
  height: 6px; border-radius: 999px; background: var(--panel-bg-2);
  overflow: hidden; border: 1px solid var(--panel-border);
}
.meter > span { display: block; height: 100%; background: var(--accent); transition: width .18s ease; }
.meter.is-ok   > span { background: var(--ok); }
.meter.is-warn > span { background: var(--warn); }
.meter.is-bad  > span { background: var(--bad); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-dim);
  border: 1px dashed var(--panel-border); border-radius: var(--radius);
}
.empty h3 { color: var(--text-muted); }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { font-size: 2.1rem; display: block; text-align: center; margin-bottom: 4px; }
.login-card .brand small { text-align: center; font-size: .62rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .wrap { padding: 16px 14px 48px; }
  #site-header .bar { min-height: 0; padding: 10px 14px; gap: 10px; }
  .nav { order: 3; width: 100%; }
  .whoami { order: 2; margin-left: auto; }
  h1 { font-size: 1.6rem; }
}
