/* ===========================================================================
   BEACON — operations console
   Dark "watch room". Ember (warm orange) is the brand mark; device status uses
   a separate green/amber/red/grey scale. The signature is the signal-fire tile.
   =========================================================================== */

:root {
  --ink:        #0e1218;   /* page */
  --panel:      #161c26;   /* raised surface */
  --panel-2:    #1c232f;   /* inputs / nested */
  --line:       #28303d;   /* hairlines */
  --text:       #e7ecf3;
  --muted:      #8b97a8;

  --ember:      #ff7a18;   /* brand */
  --ember-soft: #ffb259;

  --ok:         #2fb87a;
  --warning:    #f5a524;
  --critical:   #e5484d;
  --offline:    #6b7280;

  --type-barix:   #ff7a18;
  --type-peplink: #4c8bf5;
  --type-pdu:     #b26bf0;

  --radius:     12px;
  --shadow:     0 6px 24px rgba(0,0,0,.35);
  --shadow-lg:  0 20px 60px rgba(0,0,0,.4);

  --bg:          var(--ink);
  --page-glow:   #182231;               /* top-right glow behind the page */
  --topbar-bg:   rgba(14,18,24,.7);
  --on-ember:    #1a1205;               /* text on ember buttons */
  --ember-hover: var(--ember-soft);     /* ember button hover */
  --link:        var(--ember-soft);     /* ember-tinted text and links */
  --ok-text:     var(--ok-text);
  --critical-text: var(--critical-text);
  --backdrop:    var(--backdrop);

  color-scheme: dark;
}

/* ---- light theme ----
   Chosen per user (users.theme). data-theme="light" is an explicit choice;
   with no data-theme the browser's preference decides. Keep both blocks
   identical. */
:root[data-theme="light"] {
  --ink: #f3f5f8; --panel: #ffffff; --panel-2: #f0f3f7; --line: #dbe1e9;
  --text: #141a23; --muted: #5a6575;
  --ember: #f07316; --ember-soft: #ff9a45;
  --ok: #17885a; --warning: #a86a00; --critical: #cc2f35; --offline: #8a93a0;
  --shadow: 0 4px 16px rgba(20,30,45,.08); --shadow-lg: 0 18px 50px rgba(20,30,45,.16);
  --page-glow: #ffffff; --topbar-bg: rgba(255,255,255,.8);
  --ember-hover: #ff8b2e; --link: #b54f00;
  --ok-text: #12704a; --critical-text: #a8222a; --backdrop: rgba(20,28,40,.45);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #f3f5f8; --panel: #ffffff; --panel-2: #f0f3f7; --line: #dbe1e9;
    --text: #141a23; --muted: #5a6575;
    --ember: #f07316; --ember-soft: #ff9a45;
    --ok: #17885a; --warning: #a86a00; --critical: #cc2f35; --offline: #8a93a0;
    --shadow: 0 4px 16px rgba(20,30,45,.08); --shadow-lg: 0 18px 50px rgba(20,30,45,.16);
    --page-glow: #ffffff; --topbar-bg: rgba(255,255,255,.8);
    --ember-hover: #ff8b2e; --link: #b54f00;
    --ok-text: #12704a; --critical-text: #a8222a; --backdrop: rgba(20,28,40,.45);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, var(--page-glow) 0%, var(--ink) 55%);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo { background: #fff; border-radius: 8px; padding: 5px 8px; display: inline-flex; align-items: center; }
.brand-logo img { display: block; height: 22px; }
.brand-sep { width: 1px; height: 22px; background: var(--line); }
.brand-ember {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--ember-soft), var(--ember) 70%);
  box-shadow: 0 0 10px 1px rgba(255,122,24,.7), 0 0 22px 4px rgba(255,122,24,.35);
  align-self: center;
}
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: .04em; }
.brand-tag  { color: var(--muted); font-size: 13px; }

.nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.nav-link {
  color: var(--muted); text-decoration: none;
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.nav-link:hover { color: var(--text); background: var(--panel); }
.nav-link.is-active { color: var(--text); background: var(--panel); box-shadow: inset 0 -2px 0 var(--ember); }

.wrap { max-width: 1160px; margin: 0 auto; padding: 28px; }

/* ---- flash ---- */
.flash {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--ember);
  padding: 12px 16px; border-radius: 8px; margin-bottom: 22px;
}

/* ---- summary strip ---- */
.summary {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  justify-content: space-between; margin-bottom: 26px;
}
.summary-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.stat b { color: var(--text); font-size: 16px; }
.stat::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.stat--ok::before       { background: var(--ok); }
.stat--warning::before  { background: var(--warning); }
.stat--critical::before { background: var(--critical); }
.stat--offline::before  { background: var(--offline); }
.stat--type-barix::before   { background: var(--type-barix); }
.stat--type-peplink::before { background: var(--type-peplink); }
.stat--type-pdu::before     { background: var(--type-pdu); }

/* clickable filter chips on the dashboard */
a.stat { text-decoration: none; cursor: pointer; transition: opacity .15s, border-color .15s; }
a.stat:hover { border-color: var(--muted); }
a.stat.is-off { opacity: .38; }
a.stat.is-off b { color: var(--muted); }
.filter-reset { color: var(--link); text-decoration: none; }
.filter-reset:hover { text-decoration: underline; }

/* device web-page link on tiles */
.ip-link { color: var(--link); text-decoration: none; }
.ip-link:hover { text-decoration: underline; }
.summary-meta { font-size: 13px; color: var(--muted); }

/* ---- site sections ---- */
.site { margin-bottom: 30px; }
.site-title {
  font-size: 14px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted);
  margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.tiles {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ---- the signal-fire tile (signature) ---- */
.tile {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tile::before {                      /* status spine down the left edge */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--offline);
}
.tile--ok::before       { background: var(--ok); }
.tile--warning::before  { background: var(--warning); }
.tile--critical::before { background: var(--critical); }
.tile--offline::before  { background: var(--offline); }
.tile--unknown::before  { background: var(--critical); }

.tile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tile-brand { font-weight: 600; font-size: 16px; }
.tile-state { margin-left: auto; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* the ember: lit and calm when OK, pulsing when something's wrong, dark when off */
.ember { width: 11px; height: 11px; border-radius: 50%; background: var(--offline); flex: none; }
.ember--ok       { background: var(--ok);       box-shadow: 0 0 8px 1px rgba(47,184,122,.65); }
.ember--warning  { background: var(--warning);  box-shadow: 0 0 8px 1px rgba(245,165,36,.65);  animation: pulse 1.8s ease-in-out infinite; }
.ember--critical { background: var(--critical); box-shadow: 0 0 9px 1px rgba(229,72,77,.7);     animation: pulse 1.1s ease-in-out infinite; }
.ember--offline  { background: var(--offline); }
.ember--unknown  { background: var(--critical); box-shadow: 0 0 9px 1px rgba(229,72,77,.7); }

@keyframes pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .45; transform: scale(.82); }
}

.tile-data { display: flex; gap: 22px; margin: 0 0 12px; }
.tile-data dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.tile-data dd { margin: 0; font-size: 17px; font-family: "JetBrains Mono", monospace; }
.tile-data .is-flag dd { color: var(--warning); }

.flag {
  font-family: "Space Grotesk", sans-serif; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  background: rgba(245,165,36,.15); color: var(--warning);
  padding: 2px 6px; border-radius: 5px; vertical-align: middle;
}

.tile-song   { margin: 0 0 8px; font-size: 13px; color: var(--link); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-reason { margin: 0 0 8px; font-size: 13px; color: var(--text); }
.tile-error  { margin: 0 0 8px; font-size: 12.5px; color: var(--critical); }
.tile-note   { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.tile-foot   { margin: 6px 0 0; font-size: 12px; }
.tile-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.tile-reboot-form { display: contents; }
.tile-note--error { align-self: center; font-size: 11px; color: var(--critical); }
.tile-btn {
  flex: 1; cursor: pointer; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font: 500 12.5px "Space Grotesk", sans-serif;
  transition: border-color .15s, background .15s;
}
.tile-btn:hover { border-color: var(--ember); background: var(--panel); }
.tile-btn:active { transform: translateY(1px); }
.tile-btn:disabled { opacity: .45; cursor: not-allowed; }
.tile-btn:disabled:hover { border-color: var(--line); background: var(--panel-2); }

/* ---- admin pages ---- */
.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }

.settings-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.settings-card { text-decoration: none; color: inherit; display: block; transition: border-color .15s ease; }
.settings-card:hover { border-color: var(--ember); }
.settings-card h2 { margin: 0 0 8px; font-size: 16px; }
.settings-card p { margin: 0; font-size: 13px; }

.cols { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 16px; font-size: 16px; }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 13px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-row { display: flex; gap: 13px; }
.form-row label { flex: 1; min-width: 0; }
.form-row label.narrow { flex: 0 0 104px; }
.form input, .form select, .form textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 9px 11px; font: inherit; font-size: 14px;
  width: 100%; min-width: 0;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,122,24,.18);
}
.form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form .check input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ember); color: var(--on-ember); border: none; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 8px; text-decoration: none;
}
.btn:hover { background: var(--ember-hover); }
.btn--ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn--ghost:hover { color: var(--text); background: var(--panel-2); }

/* ---- tables ---- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; align-items: center; gap: 14px; justify-content: flex-end; }
.row-actions a { color: var(--link); text-decoration: none; font-size: 13px; }
.row-actions form { margin: 0; }
.link-danger { background: none; border: none; color: var(--critical); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* ---- empty state ---- */
.empty { text-align: center; padding: 60px 20px; }
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

/* ---- map view ---- */
.map {
  height: calc(100vh - 230px); min-height: 420px;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; background: var(--panel);
}
.map-legend { display: inline-flex; align-items: center; gap: 7px; margin-left: 16px; }
.map-legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot--green { background: var(--ok); box-shadow: 0 0 8px 1px rgba(47,184,122,.6); }
.dot--red   { background: var(--critical); box-shadow: 0 0 8px 1px rgba(229,72,77,.6); }
.dot--yellow { background: var(--warning); box-shadow: 0 0 8px 1px rgba(245,165,36,.6); }
.dot--grey  { background: var(--offline); }

/* sites-list enabled/disabled icon */
.status-cell { width: 28px; text-align: center; }
.status-icon--on  { color: var(--ok); font-size: 13px; }
.status-icon--off { color: var(--warning); font-size: 11px; letter-spacing: -1px; }
.map-unplaced { margin-top: 14px; font-size: 13px; }
.map-pop { font-family: "Space Grotesk", sans-serif; font-size: 13px; line-height: 1.5; }
.map-pop a { color: var(--ember); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2); color: var(--text); }
.leaflet-container { font: inherit; }

/* ---- streams view ---- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 18px; }
.filters .check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text); cursor: pointer; }
.url-cell { max-width: 520px; }
.url-cell a { color: var(--link); text-decoration: none; font-family: "JetBrains Mono", monospace; font-size: 13px; word-break: break-all; }
.url-cell a:hover { text-decoration: underline; }
.s-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; }
.s-dot--ok       { background: var(--ok); }
.s-dot--warning  { background: var(--warning); }
.s-dot--critical { background: var(--critical); }
.s-dot--offline  { background: var(--offline); }
.s-dot--unknown  { background: var(--critical); }

/* ---- SLA view ---- */
.section-title { font-size: 16px; margin: 30px 0 12px; }
.chip {
  display: inline-flex; align-items: center; padding: 6px 13px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  text-decoration: none; font-size: 13px;
}
.chip--on { color: var(--text); border-color: var(--ember); box-shadow: inset 0 0 0 1px var(--ember); }

.sla-cards { display: flex; flex-direction: column; gap: 16px; }
.sla-card {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.sla-card-info { flex: 0 0 220px; }
.sla-card-chart { flex: 1; min-width: 0; }
.sla-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sla-card-head h2 { margin: 0; font-size: 16px; }
.sla-figures { display: flex; align-items: baseline; gap: 12px; }
.sla-big { font-size: 30px; font-weight: 700; font-family: "JetBrains Mono", monospace; color: var(--text); }
.sla-big.is-met { color: var(--ok); }
.sla-big.is-missed { color: var(--critical); }
.sla-target { color: var(--muted); font-size: 13px; }

.sla-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 6px; }
.sla-badge--met    { background: rgba(47,184,122,.15); color: var(--ok); }
.sla-badge--missed { background: rgba(229,72,77,.15); color: var(--critical); }
.sla-badge--none   { background: var(--panel-2); color: var(--muted); }

.sla-chart { width: 100%; height: 130px; display: block; }
.sla-chart .bar-ok  { fill: var(--ok); }
.sla-chart .bar-bad { fill: var(--critical); }
.sla-target-line { stroke: var(--ember); stroke-width: 1; stroke-dasharray: 3 3; opacity: .8; }
.sla-nochart { padding: 24px 0; font-size: 13px; }

.table .num { text-align: right; }
.pill { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 5px; }
.pill--met    { background: rgba(47,184,122,.15); color: var(--ok); }
.pill--missed { background: rgba(229,72,77,.15); color: var(--critical); }
.pill--none   { background: var(--panel-2); color: var(--muted); }

/* ---- settings: sub-nav, manage cards ---- */
.subnav {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.subnav-link {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 6px 13px; border-radius: 8px;
}
.subnav-link:hover { color: var(--text); background: var(--panel); }
.subnav-link.is-active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }

.field-hint { display: block; font-size: 12px; margin-top: 2px; }

.manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.manage-grid--hub { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.panel--narrow { max-width: 460px; }
.manage-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 16px; text-decoration: none; color: var(--text);
  transition: border-color .15s, color .15s;
}
.manage-card:hover { border-color: var(--ember); color: var(--link); }
.manage-card svg { width: 30px; height: 30px; color: var(--link); }
.manage-card:hover svg { color: var(--ember); }
.manage-card-title { font-weight: 600; font-size: 14px; color: var(--text); }
.manage-card:hover .manage-card-title { color: var(--text); }

/* ---- contractor site-role assignment ---- */
.site-roles { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; margin: 2px 0; }
.site-roles legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
.site-role-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.site-role-name { font-size: 14px; }
.site-role-row select { width: 130px; flex: none; min-width: 0; }

/* ---- login + auth ---- */
.login-body {
  min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 600px at 50% -10%, rgba(255,122,24,.08), transparent), var(--bg);
}
.login-card {
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 30px 28px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .brand-name { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 22px; letter-spacing: .5px; }
.login-tag { margin: 4px 0 20px; font-size: 13px; }
.login-error {
  background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.4); color: var(--critical-text);
  padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.login-tabs { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.login-tab {
  flex: 1; background: none; border: 0; color: var(--muted); cursor: pointer;
  font: 500 14px "Space Grotesk", sans-serif; padding: 8px; border-radius: 7px;
}
.login-tab.is-active { background: var(--ember); color: var(--on-ember); font-weight: 600; }
.login-form .btn.login-submit { width: 100%; justify-content: center; margin-top: 4px; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0 14px; }
.login-or span { white-space: nowrap; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-ms { width: 100%; justify-content: center; }
.login-sso { text-align: center; }

/* current user + sign out in the top bar */
/* current user + sign out: one graphical pill, vertically centred in the nav */
.nav-account {
  display: inline-flex; align-items: stretch; margin-left: 10px;
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--panel-2); font-size: 13px; line-height: 1;
}
.nav-user { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; color: var(--text); white-space: nowrap; }
.nav-user-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px 1px rgba(47,184,122,.6); }
.nav-signout {
  display: inline-flex; align-items: center; padding: 7px 13px;
  color: var(--muted); text-decoration: none; border-left: 1px solid var(--line);
}
.nav-signout:hover { color: var(--link); background: var(--panel); }

/* contractor login fieldset */
.login-fields { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; margin: 2px 0; }
.login-fields legend { padding: 0 6px; font-size: 13px; color: var(--muted); }

/* site owner fieldset */
.owner-fields { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; margin: 2px 0; }
.owner-fields legend { padding: 0 6px; font-size: 13px; color: var(--muted); }

/* Rhema logo on the login card */
.login-logo { background: #fff; border-radius: 10px; padding: 12px 16px; display: inline-flex; margin-bottom: 18px; }
.login-logo img { display: block; height: 34px; }

/* Microsoft logo on the SSO button */
.login-ms { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.ms-logo { width: 16px; height: 16px; display: block; }

/* modal (contact tech) */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; width: 420px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-x { background: none; border: 0; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 8px 18px 18px; }
.contact-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact-row:last-child { border-bottom: 0; }
.contact-role {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 3px;
}
.contact-row--primary .contact-role { color: var(--link); }
.contact-name { font-weight: 600; font-size: 15px; }
.contact-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.contact-meta a { color: var(--link); text-decoration: none; }
.contact-meta a:hover { text-decoration: underline; }
.contact-notes {
  margin-top: 6px; padding: 8px 10px; font-size: 13px; line-height: 1.4;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}

/* page-head with a right-aligned action */
.page-head--row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.crumb { margin: 0 0 4px; font-size: 13px; }
.crumb a { color: var(--link); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* grouped fieldsets on the contractor form */
.panel--form { max-width: 680px; }
.form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 14px; margin: 0 0 16px; }
.form fieldset legend { padding: 0 6px; font-size: 13px; color: var(--muted); }

/* delivery label button in the contact modal */
.contact-label-btn { margin-top: 8px; padding: 5px 10px; font-size: 12px; }
.contact-links { display: flex; gap: 8px; flex-wrap: wrap; }
.contact-links .contact-label-btn { margin-top: 0; }

/* ---- delivery label (print) ---- */
.label-body { margin: 0; background: var(--bg); min-height: 100vh; padding: 24px; display: flex; flex-direction: column; align-items: center; }
.label-toolbar { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.label-page {
  width: 150mm; height: 100mm; box-sizing: border-box;
  box-shadow: 0 16px 50px rgba(0,0,0,.4);
  page: dxlabel;
}
.label-page svg { display: block; width: 100%; height: 100%; }
.label-warn { color: #b00; font-size: 13px; }

.bulk-sheet {
  width: 210mm; height: 297mm; box-sizing: border-box;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  margin-bottom: 24px; background: #fff; box-shadow: 0 16px 50px rgba(0,0,0,.4);
  page: dxbulk;
}
.bulk-cell { width: 105mm; height: 74mm; box-sizing: border-box; overflow: hidden; flex: 0 0 auto; }
.bulk-cell svg { display: block; width: 100%; height: 100%; }

/* Two different label pages share this one stylesheet, so each print page
   size is scoped to a named @page via the `page:` property above — an
   unscoped `@page { size: ... }` here would apply to whichever page loads
   the stylesheet last, silently breaking the other one. */
@media print {
  .bulk-sheet { box-shadow: none; margin-bottom: 0; page-break-after: always; }
  .bulk-sheet:last-child { page-break-after: auto; }
  @page dxbulk { size: A4; margin: 0; }
}

@media print {
  .label-body { background: #fff; padding: 0; }
  .label-toolbar { display: none; }
  .label-page { box-shadow: none; }
  @page dxlabel { size: 150mm 100mm; margin: 0; }
}

/* ---- site detail / log ---- */
.cols--wide-left { grid-template-columns: 1.7fr 1fr; }
.site-title a { color: inherit; text-decoration: none; }
.site-title a:hover { color: var(--link); }

.onsite-badge {
  display: inline-flex; align-items: center; gap: 8px; align-self: center;
  background: rgba(47,184,122,.12); border: 1px solid rgba(47,184,122,.4);
  color: var(--ok-text); border-radius: 999px; padding: 6px 14px; font-size: 13px; white-space: nowrap;
}
.onsite-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 7px 1px rgba(47,184,122,.7); }

.checkin-form { margin: 0; }
.checkin-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.checkin-row .field-hint { display: block; }

.access-notes { white-space: pre-wrap; font-size: 14px; line-height: 1.6; margin: 0; }

.site-device { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 14px; }
.site-device + .site-device { border-top: 1px solid var(--line); }
.site-device-name { flex: 1; }

.log { list-style: none; margin: 0; padding: 0; }
.log-item { padding: 14px 0; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; padding-top: 0; }
.log-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.log-who { font-weight: 600; }
.log-body { margin: 6px 0 0; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.log-badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.log-badge--in   { color: var(--ok-text); border-color: rgba(47,184,122,.5); }
.log-badge--out  { color: var(--muted); }
.log-badge--work { color: var(--link); border-color: rgba(255,122,24,.45); }
.log-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.log-thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.log-file {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--link); text-decoration: none; background: var(--panel-2);
}
.log-file:hover { border-color: var(--ember); }

/* ---- responsive ---- */
@media (max-width: 820px) {
  .cols { grid-template-columns: 1fr; }
  .cols--wide-left { grid-template-columns: 1fr; }
  .topbar { gap: 14px; padding: 14px 18px; flex-wrap: wrap; }
  .brand-tag { display: none; }
  .nav { flex-wrap: wrap; margin-left: 0; row-gap: 8px; }
  .wrap { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .ember--warning, .ember--critical { animation: none; }
}

/* ---- Ship It: address type-ahead ---- */
.address-suggestions {
  position: relative; margin-top: -8px; margin-bottom: 8px;
}
.address-suggestion {
  padding: 9px 12px; font-size: 14px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-top: none;
}
.address-suggestion:first-child { border-top: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.address-suggestion:last-child { border-radius: 0 0 8px 8px; }
.address-suggestion:hover { background: var(--panel); color: var(--link); }
.address-selected {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; margin-bottom: 12px;
}
.address-selected .link-danger { margin-left: 8px; }

/* ---- Ship It: shipping-service rate options ---- */
.rate-option {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 8px; cursor: pointer; background: var(--panel-2);
}
.rate-option:hover { border-color: var(--ember); }
.rate-option input { margin: 0; }
.rate-desc { flex: 1; font-size: 14px; }
.rate-price { font-family: "JetBrains Mono", monospace; font-size: 15px; font-weight: 600; }

/* ---- Ship It: dashboard KPI tiles ---- */
.kpi-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.kpi {
  flex: 1; min-width: 160px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--ember);
  border-radius: var(--radius); padding: 14px 18px;
}
.kpi--warning { border-left-color: var(--warning); }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.kpi-value { display: block; font-size: 28px; font-weight: 600; margin-top: 4px; }

/* ---- ShipIt settings ---- */
.flash--error { border-left-color: var(--critical); }
.flash--warn  { border-left-color: var(--warning); }
.pill--warn   { background: rgba(245,165,36,.15); color: var(--warning); }
.table input, .table select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); padding: 6px 8px; font: inherit; font-size: 13px; width: 100%; min-width: 0;
}
.table input[type="checkbox"] { width: auto; }
.table .narrow { width: 90px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.inline-form { display: flex; flex-direction: row; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1; min-width: 140px; }
.problems { margin: 0 0 14px; padding-left: 18px; color: var(--critical); font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---- light/dark switch in the top bar ----
   Two submit buttons; the lit half is the theme on screen. With no saved
   choice (no data-theme) the browser's preference decides which is lit. */
.theme-switch {
  display: inline-flex; margin: 0 0 0 10px; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2);
}
.theme-opt {
  background: none; border: 0; cursor: pointer; border-radius: 999px;
  padding: 4px 11px; font: 500 12.5px "Space Grotesk", system-ui, sans-serif; line-height: 1.2;
  color: var(--muted);
}
.theme-opt:hover { color: var(--text); }
.theme-opt:focus-visible { outline: 2px solid var(--ember); outline-offset: 1px; }
.theme-opt[aria-pressed="true"],
:root:not([data-theme]) .theme-opt--dark {
  background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.15);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-opt--dark { background: none; color: var(--muted); box-shadow: none; }
  :root:not([data-theme]) .theme-opt--light {
    background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.15);
  }
}

/* Label preview in Settings → Printing */
.label-preview { width: min(100%, 300px); border: 1px solid var(--line); background: #fff; }
.label-preview svg { display: block; width: 100%; height: auto; }

/* ---- settings list: header with "+ Add new", row just saved ---- */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.table tr.is-saved td { background: color-mix(in srgb, var(--ember) 10%, transparent); }
.table tr.is-saved td:first-child { box-shadow: inset 3px 0 0 var(--ember); }

/* ---- shipments: views, stages, needs attention, bulk actions ---- */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--ember); }
.tab-count, .chip-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; text-align: center;
  background: var(--panel-2); color: var(--muted); font-weight: 600; }
.tab-count--warn { background: rgba(245,165,36,.18); color: var(--warning); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.chip:hover { color: var(--text); background: var(--panel-2); }
.chip.is-active { color: var(--text); border-color: var(--ember); background: color-mix(in srgb, var(--ember) 10%, transparent); }
.panel--attention { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); box-shadow: inset 4px 0 0 var(--warning); }
.panel--attention h2 { display: flex; align-items: center; gap: 8px; }
.table .select-col { width: 34px; padding-right: 0; }
.table--select input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--ember); }
.pill--test { background: rgba(124,92,255,.16); color: #8f78ff; }
:root[data-theme="light"] .pill--test { color: #5b3fd6; }
.select-matching { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--link); cursor: pointer; text-decoration: underline; }
.btn--danger { background: var(--critical); color: #fff; }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 85%, #000); }
.bulk-bar { position: sticky; bottom: 12px; z-index: 5; margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.bulk-bar[hidden] { display: none; }
.bulk-count { margin-right: 4px; }
.bulk-group { display: inline-flex; gap: 6px; align-items: center; }
.bulk-group select, .bulk-group input { padding: 6px 10px; font-size: 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
.test-banner { margin: 0 0 18px; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: rgba(124,92,255,.12); border: 1px solid rgba(124,92,255,.35); }
.test-banner strong { color: #8f78ff; }
:root[data-theme="light"] .test-banner strong { color: #5b3fd6; }
@media (max-width: 820px) { .bulk-bar { bottom: 8px; } .bulk-group { flex-wrap: wrap; } }
.queue-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.queue-filters label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.queue-filters select { padding: 6px 10px; font: inherit; font-weight: 400; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }

/* ---- settings: developer ---- */
.log-detail { margin: 8px 0 0; padding: 10px 12px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; font: 12px/1.5 "JetBrains Mono", ui-monospace, monospace; }
details > summary { cursor: pointer; }

/* ---- DX dispatch: scan alerts ---- */
.scan-alert { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.scan-alert[hidden] { display: none; }
.scan-alert--add { background: color-mix(in srgb, #17885a 88%, transparent); pointer-events: none; animation: scan-flash .25s ease-out; }
.scan-alert--already { background: color-mix(in srgb, #e07b00 92%, transparent); }
.scan-alert--reject { background: color-mix(in srgb, #cc2f35 94%, transparent); }
.scan-alert-box { text-align: center; color: #fff; max-width: 720px; }
.scan-alert-icon { font-size: clamp(120px, 28vw, 260px); line-height: 1; font-weight: 800; }
.scan-alert-box h2 { color: #fff; font-size: clamp(26px, 4vw, 44px); margin: 8px 0 10px; }
.scan-alert-box p { color: #fff; font-size: clamp(17px, 2.2vw, 24px); margin: 0 0 26px; }
.scan-alert-ok { font-size: 22px; padding: 16px 36px; background: #fff; color: #111; border-color: #fff; }
@keyframes scan-flash { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }

/* ---- tables that must fit narrow panels ---- */
.table--compact td, .table--compact th { padding: 8px 6px; }
.wrap-anywhere { overflow-wrap: anywhere; }

/* ---- DX manifest review & edit ---- */
.manifest-edit { min-width: 1180px; }
.manifest-edit th { text-align: center; white-space: pre-line; vertical-align: bottom; font-size: 10px; }
.manifest-edit th .col-letter { display: block; font-size: 13px; color: var(--text); font-weight: 700; margin-bottom: 2px; }
.manifest-edit td { vertical-align: top; padding: 8px 6px; }
.manifest-edit td.c { text-align: center; }
.manifest-edit td.c input { width: 20px; height: 20px; accent-color: var(--ember, #f07a1a); cursor: pointer; }
.manifest-edit select { min-width: 118px; }
.manifest-edit .table-input-inv, .manifest-edit input.inv { width: 96px; min-width: 96px; }
.manifest-edit input[type="radio"] { width: 20px; min-width: 0; }
.manifest-edit td.is-edited { background: color-mix(in srgb, var(--warning) 16%, transparent); }
.manifest-edit tr.has-problem td:first-child { box-shadow: inset 4px 0 0 var(--critical, #cc2f35); }
.manifest-edit .undecided { display: block; margin-top: 4px; font-size: 11px; }
.link-button { background: none; border: none; padding: 0; color: var(--ember, #f07a1a); text-decoration: underline; cursor: pointer; font: inherit; }

/* ---- DX: spot check after adding without scanning ---- */
.spot-check { border-left: 4px solid var(--warning); }
.spot-list { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.spot-list li { font-size: 15px; }
.spot-list li.is-done { color: var(--ok-text, var(--ok)); }
