/*
 * The vendor console.
 *
 * Same design system as the product — concrete, ink, one safety orange, 2px corners, IBM
 * Plex — but built on the *dark* half of it, deliberately. This surface can see and change
 * every customer, and the cheapest protection against acting on the wrong one is that it
 * never for a moment looks like a customer's dashboard. You should know which window you
 * are in from across the room.
 */

:root {
  --bg: #131417;
  --surface: #1a1c20;
  --raised: #22252a;
  --ink: #e8e6e1;
  --muted: #a9ada9;
  --faint: #8b8f8b;
  --line: #3a3d43;
  --row: #2b2e33;
  --accent: #e85d10;
  --accent-ink: #ffa061;
  --accent-soft: #3a2312;
  --ok: #55b46d;
  --ok-soft: #1b2f21;
  --warn: #d9a642;
  --warn-soft: #332a10;
  --danger: #e46262;
  --danger-soft: #381a1a;

  --sans: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  --r: 2px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

/*
 * `hidden` must actually hide.
 *
 * Any element given its own `display` — the sheets below are `display: flex` — beats the
 * attribute's implicit `display: none`, so both overlays render on load with nothing to
 * suggest why. This is the rule that makes `el.hidden = true` mean what it says.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
p { margin: 0; }
.mono { font-family: var(--mono); }
.up { text-transform: uppercase; letter-spacing: .08em; }
.right { text-align: right; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--sans); font-size: .85rem; font-weight: 500;
  padding: .5rem 1rem; border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.btn-solid { background: var(--accent); color: #17181a; border-color: var(--accent); }
.btn-solid:hover:not([disabled]) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { background: var(--raised); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-quiet { background: none; color: var(--muted); border-color: transparent; }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { background: none; color: var(--danger); border-color: var(--line); }
.btn-danger:hover { border-color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-xs { font-size: .72rem; padding: .3rem .6rem; }

.err {
  padding: .6rem .75rem; font-size: .82rem; margin-top: 1rem;
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--r);
}

/* ------------------------------------------------------------------- gate */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.gate-card {
  width: 100%; max-width: 25rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 1.75rem;
  display: flex; flex-direction: column;
}
.gate-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.4rem; }
.mark { width: 40px; height: 40px; color: var(--ink); flex: none; }
.mark.sm { width: 26px; height: 26px; }
.gate-brand b, .brand b { display: block; font-size: 1rem; letter-spacing: .16em; font-weight: 600; }
.gate-brand small, .brand small {
  display: block; font-family: var(--mono); font-size: .55rem;
  letter-spacing: .2em; color: var(--accent-ink); margin-top: 2px;
}

.gate-warn {
  font-size: .8rem; color: var(--warn); background: var(--warn-soft);
  border: 1px solid var(--warn); border-radius: var(--r);
  padding: .6rem .75rem; margin-bottom: 1.4rem;
}

label {
  display: block; font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .35rem;
}
fieldset label:not(.radio):not(.ack) { margin-top: 1rem; }

input[type='text'], input[type='password'], input:not([type]) {
  width: 100%; font-family: var(--mono); font-size: .92rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: .55rem .7rem; transition: border-color .12s var(--ease);
}
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
#business, #adminName { font-family: var(--sans); }

.hint { font-size: .72rem; color: var(--faint); margin-top: .35rem; line-height: 1.45; }
.hint code { font-family: var(--mono); color: var(--accent-ink); }

.gate-card .btn { margin-top: 1.3rem; width: 100%; }

/* -------------------------------------------------------------------- bar */

.bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.bar-in {
  max-width: 80rem; margin: 0 auto; padding: 0 1.5rem; height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.bar-right { display: flex; align-items: center; gap: .6rem; }
.pool { font-size: .68rem; color: var(--faint); letter-spacing: .06em; }

/* ------------------------------------------------------------------- main */

.main { max-width: 80rem; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }
.head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 1.4rem; }
.head h1 { font-size: 1.5rem; }
.sub { font-family: var(--mono); font-size: .7rem; color: var(--faint); letter-spacing: .1em; margin-top: .3rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; min-width: 62rem; }
thead th {
  text-align: left; font-family: var(--mono); font-size: .6rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint); font-weight: 500;
  padding: .7rem .9rem; background: var(--surface); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: .8rem .9rem; border-bottom: 1px solid var(--row); vertical-align: top; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface); }

.sys-id { font-family: var(--mono); font-weight: 500; letter-spacing: .06em; }
.sys-name { color: var(--muted); font-size: .78rem; margin-top: .15rem; }

.chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.chip {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .08em;
  padding: .15rem .4rem; border-radius: var(--r); white-space: nowrap;
  background: var(--raised); color: var(--muted); border: 1px solid var(--line);
}
.chip.on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.chip.off { opacity: .4; text-decoration: line-through; }

.stamp {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase;
  padding: .18rem .45rem; border-radius: var(--r); white-space: nowrap;
}
.stamp.ok { background: var(--ok-soft); color: var(--ok); }
.stamp.warn { background: var(--warn-soft); color: var(--warn); }
.stamp.danger { background: var(--danger-soft); color: var(--danger); }

.acts { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.empty { color: var(--faint); font-size: .88rem; padding: 2.5rem 0; text-align: center; }

/* ------------------------------------------------------------------ sheet */

.sheet { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; }
.sheet-bg { position: absolute; inset: 0; background: rgba(8, 9, 11, .72); }
.sheet-card {
  position: relative; width: min(34rem, 100%); background: var(--surface);
  border-left: 1px solid var(--line); display: flex; flex-direction: column;
  max-height: 100vh;
}
.creds-card { margin: auto; border: 1px solid var(--accent); border-radius: var(--r); max-height: 90vh; }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--line); flex: none;
}
.sheet-head h2 { font-size: 1.1rem; }
.x { background: none; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .2rem .4rem; }
.x:hover { color: var(--ink); }

.sheet-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.sheet-foot {
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: 1.1rem 1.5rem; border-top: 1px solid var(--line); flex: none;
}

fieldset { border: 0; padding: 0; margin: 1.6rem 0 0; }
legend {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-ink); padding: 0 0 .6rem; width: 100%;
  border-bottom: 1px solid var(--line); margin-bottom: .9rem;
}

.radio { display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 .7rem;
         font-family: var(--sans); font-size: .85rem; text-transform: none;
         letter-spacing: 0; color: var(--ink); cursor: pointer; }
.radio input { margin-top: .25rem; accent-color: var(--accent); }
.radio b { display: block; font-weight: 500; }
.radio em { display: block; font-style: normal; font-size: .74rem; color: var(--faint); margin-top: .1rem; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .5rem; }
.check {
  display: flex; gap: .5rem; align-items: flex-start; cursor: pointer;
  font-family: var(--sans); font-size: .82rem; text-transform: none; letter-spacing: 0;
  color: var(--ink); margin: 0; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
}
.check:hover { border-color: var(--muted); }
.check input { margin-top: .2rem; accent-color: var(--accent); }
.check.locked { opacity: .6; cursor: default; }
.check b { display: block; font-weight: 500; font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; }
.check em { display: block; font-style: normal; font-size: .7rem; color: var(--faint); margin-top: .15rem; line-height: 1.35; }

/* ------------------------------------------------------------ credentials */

.creds-warn {
  font-size: .84rem; color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: var(--r); padding: .7rem .85rem;
  margin-bottom: 1.3rem;
}
.cred { margin-bottom: 1.1rem; }
.cred label { margin-bottom: .3rem; }
.cred-row { display: flex; gap: .5rem; }
.cred-val {
  flex: 1; font-family: var(--mono); font-size: .82rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: .55rem .7rem; word-break: break-all; line-height: 1.45;
}
.cred-note { font-size: .72rem; color: var(--faint); margin-top: .3rem; }

.ack {
  display: flex; gap: .55rem; align-items: flex-start; margin-top: 1.4rem;
  font-family: var(--sans); font-size: .85rem; text-transform: none; letter-spacing: 0;
  color: var(--ink); cursor: pointer;
}
.ack input { margin-top: .25rem; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
