/* 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: 1280px; margin: 0 auto; 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; }
.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; }
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(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }

/* 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: 120px; display: grid; place-items: center; background: var(--surface-2); }
.card .pic img { max-height: 110px; max-width: 90%; object-fit: contain; }
.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; } }
