:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #111827;
  --text: #273142;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --orange: #f97316;
  --orange-2: #ea580c;
  --orange-soft: #fff4ec;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --slate: #475569;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button { border: 0; }
a { color: inherit; }
.hidden { display: none !important; }
.icon { width: 17px; height: 17px; flex: 0 0 auto; }

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  background:
    radial-gradient(circle at 16% 20%, rgba(249, 115, 22, 0.16), transparent 32%),
    linear-gradient(180deg, #fff, #f4f6f8);
}
.auth-visual {
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.22);
  flex: 0 0 auto;
}
.mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--orange), #fb923c);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(249, 115, 22, 0.25);
}
.auth-copy { max-width: 650px; }
.auth-copy h1 {
  color: var(--ink);
  font-size: 46px;
  line-height: 1.04;
  margin: 0 0 18px;
  letter-spacing: 0;
}
.auth-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}
.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 680px;
}
.auth-metric {
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
  background: rgba(255,255,255,0.78);
  padding: 14px;
}
.auth-metric strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}
.auth-metric span {
  color: var(--muted);
  font-size: 12px;
}
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.auth-box {
  width: 100%;
  max-width: 430px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px;
}
.eyebrow {
  color: var(--orange);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.auth-box h2, .analytics-hero h2 {
  color: var(--ink);
  margin: 0 0 6px;
  font-size: 24px;
}
.auth-box .sub {
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.field label, .form-label {
  color: var(--slate);
  font-size: 12px;
  font-weight: 750;
}
.input, .select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.14);
}
.btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  background: #eef2f7;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { background: #e2e8f0; }
.btn.primary { background: var(--orange); color: white; }
.btn.primary:hover { background: var(--orange-2); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.14); color: #e2e8f0; }
.btn.ghost:hover { background: rgba(255,255,255,0.08); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.auth-box .btn { width: 100%; margin-top: 8px; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  color: white;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}
.app-header .brand-mark { color: white; }
.app-header .brand-icon { width: 38px; height: 38px; }
.nav {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
}
.nav button {
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.nav button:hover, .nav button.active {
  color: white;
  background: rgba(249, 115, 22, 0.18);
}
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}
.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.account-row strong {
  display: block;
  color: white;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-row span:not(.avatar) {
  display: block;
  color: #94a3b8;
  font-size: 11px;
}
.side-action {
  width: auto;
  white-space: nowrap;
}
.icon-action {
  width: 42px;
  height: 38px;
  padding: 0;
  align-self: auto;
  justify-content: center;
}
.icon-action .icon {
  margin: 0;
}
.main { min-width: 0; }
.topbar {
  min-height: 68px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  position: static;
  z-index: 5;
}
.page-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
}
.page-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--orange-soft);
  color: var(--orange-2);
  display: grid;
  place-items: center;
  font-weight: 900;
  flex: 0 0 auto;
}
.content { padding: 24px 28px 36px; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tab {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--slate);
  background: white;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 850;
  font-size: 12px;
}
.tab.active {
  color: white;
  background: var(--orange);
  border-color: var(--orange);
}
.schedule-pill {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.schedule-pill.recording {
  color: #166534;
  background: #ecfdf5;
  border-color: #bbf7d0;
}
.schedule-pill.paused {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

.alert-banner {
  border: 1px solid #fecaca;
  background: linear-gradient(180deg, #fff5f5, #fff);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: 0 12px 32px rgba(220, 38, 38, 0.08);
}
.alert-banner-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #991b1b;
}
.alert-banner-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.alert-banner-list span {
  background: white;
  border: 1px solid #fee2e2;
  border-radius: 999px;
  padding: 5px 9px;
  color: #7f1d1d;
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi, .metric-tile {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.kpi span, .metric-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.kpi strong, .metric-tile strong {
  color: var(--ink);
  font-size: 28px;
}
.floor-section { margin-bottom: 22px; }
.floor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}
.floor-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}
.floor-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.floor-head > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.printer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}
.printer-card {
  position: relative;
  display: block;
  overflow: hidden;
  text-decoration: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  min-height: 164px;
  color: inherit;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
  transition: border-color .16s, transform .16s, box-shadow .16s;
}
a.printer-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.09);
  border-color: #cbd5e1;
}
.printer-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--faint);
}
.printer-card.online::before { background: var(--green); }
.printer-card.offline::before { background: var(--red); }
.printer-card.unknown::before { background: var(--amber); }
.printer-card.usb::before { background: var(--slate); }
.printer-card.alerting {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fffafa, #fff);
}
.printer-card-bg {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  right: -74px;
  top: -74px;
  background: rgba(148, 163, 184, 0.08);
  pointer-events: none;
}
.printer-card.online .printer-card-bg { background: rgba(22, 163, 74, 0.08); }
.printer-card.offline .printer-card-bg { background: rgba(220, 38, 38, 0.08); }
.printer-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.printer-title-block {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}
.printer-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
  flex: 0 0 auto;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }
.status-dot.unknown { background: var(--amber); box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.12); }
.status-dot.usb { background: var(--slate); box-shadow: 0 0 0 4px rgba(71, 85, 105, 0.12); }
.printer-name {
  color: var(--ink);
  font-weight: 850;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.printer-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.printer-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  flex: 0 0 auto;
  max-width: 46%;
  position: relative;
  z-index: 1;
}
.printer-actions .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
}
.status.online { background: #dcfce7; color: #166534; }
.status.offline { background: #fee2e2; color: #991b1b; }
.status.unknown { background: #fef3c7; color: #92400e; }
.status.usb { background: #e5e7eb; color: #475569; }
.printer-detail-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 20px;
}
.printer-detail-row strong { color: var(--ink); }
.mini-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  min-width: 0;
}
.mini-stat {
  background: var(--panel-2);
  border: 1px solid #eef2f7;
  border-radius: 6px;
  padding: 8px 9px;
  min-width: 0;
  overflow: hidden;
}
.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-stat strong {
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.analytics-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}
.analytics-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  max-width: 680px;
}
.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  min-width: 420px;
}
.metric-tile {
  background: var(--panel-2);
  padding: 14px;
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.chart-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}
.chart-panel.wide { grid-column: 1 / -1; }
.chart-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.chart-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}
.chart-heading span {
  color: var(--muted);
  font-size: 12px;
}
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}
.donut {
  width: 174px;
  height: 174px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.donut-hole {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  align-content: center;
  box-shadow: inset 0 0 0 1px var(--line);
}
.donut-hole strong {
  color: var(--ink);
  font-size: 24px;
}
.donut-hole span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
}
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 190px;
}
.legend-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}
.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-row strong { color: var(--ink); }
.floor-analytics {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.floor-bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr 70px;
  align-items: center;
  gap: 12px;
}
.floor-bar-row strong {
  display: block;
  color: var(--ink);
}
.floor-bar-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.floor-bar-track {
  height: 9px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}
.floor-bar-fill {
  height: 100%;
  border-radius: 999px;
}
.floor-bar-row b {
  text-align: right;
}
.attention-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attention-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px 100px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.attention-row strong {
  color: var(--ink);
  display: block;
}
.attention-row span {
  color: var(--muted);
  font-size: 12px;
}
.attention-score {
  font-weight: 900;
  text-align: right;
}
.attention-incidents {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.empty.compact { padding: 18px; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.report-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 250px;
}
.report-card.disabled {
  opacity: 0.58;
}
.report-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--orange);
  background: var(--orange-soft);
}
.report-card h3 {
  margin: 0;
  color: var(--ink);
}
.report-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
}
.tool-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}
.tool-panel h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.check-item input { accent-color: var(--orange); }
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 9px 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 10px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
td.actions { white-space: nowrap; }
.empty {
  background: white;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}
#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #111827;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
  pointer-events: none;
  z-index: 20;
  max-width: 360px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #991b1b; }

@media (max-width: 1100px) {
  .analytics-hero { flex-direction: column; }
  .analytics-summary { min-width: 0; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .app-header {
    position: static;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .nav { flex-direction: row; overflow-x: auto; }
  .header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }
  .account-row {
    padding-left: 0;
    border-left: 0;
  }
  .side-action, .icon-action { width: auto; }
  .icon-action { min-width: 42px; }
  .topbar { padding: 0 16px; align-items: flex-start; flex-direction: column; justify-content: center; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid, .chart-grid { grid-template-columns: 1fr; }
  .chart-panel.wide { grid-column: auto; }
  .floor-bar-row { grid-template-columns: 1fr; }
  .floor-bar-row b { text-align: left; }
}

@media (max-width: 620px) {
  .auth-panel { padding: 18px; }
  .auth-box { padding: 22px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .form-grid, .check-grid, .analytics-summary { grid-template-columns: 1fr; }
  .printer-grid { grid-template-columns: 1fr; }
  .attention-row { grid-template-columns: 1fr; }
  .attention-score, .attention-incidents { text-align: left; }
  .header-actions { grid-template-columns: 1fr; }
  .side-action, .icon-action { width: 100%; }
}
