/* EMS Cloud Print portal. Layout: top bar + summary strip + printer card grid; printer page = print panel beside a filterable log. */
:root {
  /* EMS brand: orange #FB8F1E (accent) + slate #475361 (header, neutrals) */
  --orange: #FB8F1E;
  --slate: #475361;
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #eceff2;
  --ink: #1f2731;
  --muted: #5d6874;
  --line: #d5dbe1;
  --brand: #FB8F1E;          /* buttons, focus, highlights */
  --brand-ink: #1f2731;      /* dark text on orange (white on #FB8F1E is too low-contrast) */
  --link: #475361;
  --header-bg: #475361;
  --ok: #1d7a48;
  --ok-soft: #e3f3ea;
  --warn: #9a6100;
  --warn-soft: #fbf0db;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --idle: #6b7785;
  --idle-soft: #e9edf1;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .05);
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1f25; --surface: #232a32; --surface-2: #2b333d; --ink: #e8ecf0; --muted: #a3adb8; --line: #36404b;
    --brand: #FB8F1E; --brand-ink: #1f2731; --link: #FDB062; --header-bg: #36404b;
    --ok: #5ccf8f; --ok-soft: rgba(92, 207, 143, .12); --warn: #f0b252; --warn-soft: rgba(240, 178, 82, .13);
    --bad: #ff8a80; --bad-soft: rgba(255, 138, 128, .13); --idle: #8b98a6; --idle-soft: rgba(139, 152, 166, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* top bar */
.topbar { background: var(--header-bg); border-bottom: 3px solid var(--orange); position: sticky; top: 0; z-index: 5;
  /* light-on-slate versions of the tokens used inside the header */
  --ink: #ffffff; --muted: #dbe1e7; --line: rgba(255, 255, 255, .25); --surface: rgba(255, 255, 255, .08); --surface-2: rgba(255, 255, 255, .16);
  --ok: #8be3b0; --ok-soft: rgba(139, 227, 176, .16); --bad: #ffb4ab; --bad-soft: rgba(255, 180, 171, .16);
  --idle: #d5dbe1; --idle-soft: rgba(255, 255, 255, .12); color: var(--ink); }
.topbar select option { color: #1f2731; background: #ffffff; }
.topbar-in { max-width: none; margin: 0; padding: 10px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; display: block; }
.spacer { flex: 1; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 5px 10px; border-radius: 7px; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--orange); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.idle { color: var(--idle); background: var(--idle-soft); }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
select, input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
label.field > :not(span) { color: var(--ink); }

main { max-width: 1280px; margin: 0 auto; padding: 20px 20px 48px; display: flex; flex-direction: column; gap: 20px; }
main.wide { max-width: none; margin: 0; }
h1 { font-size: 1.5rem; margin: 0; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* summary strip */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 160px)); gap: 10px; justify-content: start; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; text-align: center; }
.stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }

/* customer block: printers on the left (max 4 across), that customer's connection log on the right */
.cust-body { display: flex; gap: 12px; align-items: stretch; }
.cust-body > .grid { grid-template-columns: repeat(var(--cols, 4), minmax(220px, 250px)); flex: 0 0 auto; align-content: start; }
/* folded: a slim vertical tab next to the printers */
.conn-tab { flex: 0 0 auto; width: 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; }
.conn-tab:hover { color: var(--ink); border-color: var(--orange); }
.conn-tab-label { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 600; font-size: .78rem; letter-spacing: .04em; }
.conn-badge { min-width: 20px; padding: 1px 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; text-align: center; }
.cust-body .connpanel { display: none; }
/* open: the log takes the remaining width and the printer cards shrink */
.cust-body.log-open .conn-tab { display: none; }
.cust-body.log-open .connpanel { display: flex; flex: 1 1 auto; min-width: 340px; align-self: flex-start; }
.cust-body.log-open > .grid { grid-template-columns: repeat(var(--cols, 4), minmax(150px, 170px)); gap: 10px; }
.cust-body.log-open .card .pic { height: 96px; }
.cust-body.log-open .card .pic img { max-height: 80px; }
.cust-body.log-open .card .problem { font-size: .72rem; min-height: 28px; padding: 5px 8px; }
.cust-body.log-open .card .problem time { display: none; }
.cust-body.log-open .card .body { padding: 8px 10px 2px; }
.cust-body.log-open .card .name { font-size: .85rem; }
.cust-body.log-open .specs { font-size: .7rem; }
.cust-body.log-open .counts b { font-size: .9rem; }
.cust-body.log-open .counts em, .cust-body.log-open .counts small { font-size: .6rem; }
.cust-body.log-open .pic-badge .pill, .cust-body.log-open .maint { font-size: .64rem; padding: 1px 6px; }
.cust-body.log-open .maint svg { width: 10px; height: 10px; }
.connpanel { padding: 12px; gap: 8px; max-height: 640px; }
.connpanel .head h2 { font-size: .95rem; }
.connlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; }
.connlist li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: .8rem; }
.connlist li:last-child { border-bottom: 0; }
.connlist .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.connlist .what { overflow-wrap: anywhere; }
.connlist .why { grid-column: 2; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .cust-body, .cust-body.log-open { flex-direction: column; }
  .cust-body > .grid, .cust-body.log-open > .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .conn-tab { width: auto; flex-direction: row; justify-content: center; padding: 8px 12px; }
  .conn-tab-label { writing-mode: horizontal-tb; transform: none; }
  .cust-body.log-open .connpanel { min-width: 0; align-self: stretch; }
}

/* printer cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; text-decoration: none; color: inherit; overflow: hidden; transition: border-color .15s; }
.card:hover { border-color: var(--orange); }
.card .problem { padding: 8px 12px; font-size: .82rem; font-weight: 600; display: flex; gap: 8px; align-items: baseline; min-height: 36px; }
.card .problem.none { color: var(--ok); background: var(--ok-soft); }
.card .problem.has { color: var(--bad); background: var(--bad-soft); }
.card .problem.offline { color: var(--idle); background: var(--idle-soft); }
.card .problem time { margin-left: auto; font-weight: 500; opacity: .8; white-space: nowrap; }
.card .pic { height: 150px; display: grid; place-items: center; background: var(--surface-2); padding: 8px; position: relative; }
.pic-badge { position: absolute; top: 8px; z-index: 1; }
.pic-badge.left { left: 8px; }
.pic-badge.right { right: 8px; }
.pic-badge .pill { background: var(--surface); box-shadow: var(--shadow); }
.maint { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: var(--surface); box-shadow: var(--shadow); white-space: nowrap; }
.maint.idle { color: var(--muted); }
.maint.warn { color: var(--warn); background: var(--warn-soft); }
.maint.bad { color: var(--bad); background: var(--bad-soft); }
.copy { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 1px 4px; margin: -1px -4px;
  border-radius: 5px; cursor: copy; color: inherit; font-size: inherit; text-align: left; overflow-wrap: anywhere; }
.copy svg { opacity: .45; flex: none; }
.copy:hover { background: var(--surface-2); }
.copy:hover svg { opacity: .9; }
.copy.copied { background: var(--ok-soft); color: var(--ok); }
.copy.copied::after { content: "Copied"; font-family: var(--sans); font-size: .7rem; font-weight: 600; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 6px 0 0; font-size: .8rem; }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; overflow-wrap: anywhere; }
.card .pic img { max-height: 134px; max-width: 90%; object-fit: contain; border-radius: 6px; }
.printer-photo { display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.printer-photo img { max-height: 180px; max-width: 100%; object-fit: contain; border-radius: 6px; }
.printer-photo svg { width: 160px; height: 110px; }

/* customer panel (Sentinel licenses) */
.custblock { display: flex; flex-direction: column; gap: 12px; }
.customer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 12px 16px; background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: 10px; }
.customer h2 { font-size: 1.15rem; }
.lic { display: flex; align-items: center; gap: 10px; }
.lic .box { min-width: 64px; text-align: center; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 2px solid var(--orange); border-radius: 10px; padding: 2px 12px; }
.lic .box.empty { color: var(--muted); border-style: dashed; font-weight: 500; font-size: 1rem; padding: 6px 12px; }
.lic small { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }
.card .body { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 2px; }
.card .name { font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: .82rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); margin-top: 10px; }
.counts div { padding: 8px 4px 10px; text-align: center; }
.counts div + div { border-left: 1px solid var(--line); }
.counts b { display: block; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.counts small { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.counts em { display: block; font-style: normal; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* printer page */
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; align-items: start; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; align-self: flex-start; }
.tabs button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
textarea { resize: vertical; min-height: 110px; font-family: var(--mono); }
.result { border-radius: 8px; padding: 8px 12px; font-size: .9rem; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.bad { background: var(--bad-soft); color: var(--bad); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
.tbl table { min-width: 860px; }
td:first-child, td.mono { white-space: nowrap; }
td.detail { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; white-space: pre-line; color: var(--muted); }
tr.new { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--warn-soft); } to { background: transparent; } }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .88rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 20, 30, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.error { color: var(--bad); font-size: .88rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); }

@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
