:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e8ef;
  --surface: #ffffff;
  --background: #f3f5f8;
  --navy: #101827;
  --blue: #2563eb;
  --cyan: #0891b2;
  --orange: #f97316;
  --green: #16855b;
  --shadow: 0 10px 28px rgba(16, 24, 39, 0.07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  background: var(--navy);
  color: white;
  min-height: 116px;
  padding: 24px clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.eyebrow, .section-label { margin: 0 0 4px; color: #94a3b8; font-size: 0.78rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -0.035em; }
.header-meta { display: flex; align-items: center; gap: 7px; margin: 8px 0 0; color: #cbd5e1; font-size: .875rem; font-weight: 650; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.14); }
.refresh-button { border: 1px solid rgba(255,255,255,.26); background: rgba(255,255,255,.08); color: white; border-radius: 10px; padding: 10px 16px; min-height: 44px; font-weight: 700; }
.refresh-button:hover { background: rgba(255,255,255,.15); }
.refresh-button:disabled { opacity: .55; cursor: progress; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

main { width: min(1420px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 48px; }
.quick-nav { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.quick-nav::-webkit-scrollbar { display: none; }
.quick-nav a { flex: none; padding: 9px 14px; border: 1px solid #dce3ed; border-radius: 999px; background: white; color: #344054; font-size: .875rem; font-weight: 750; text-decoration: none; }
.quick-nav a:hover, .quick-nav a:focus-visible { border-color: var(--blue); color: var(--blue); }
.quick-nav .history-nav-button { background: var(--blue); border-color: var(--blue); color: white; }
.quick-nav .history-nav-button:hover, .quick-nav .history-nav-button:focus-visible { background: #1d4ed8; color: white; }
.install-banner[hidden], .install-banner p[hidden] { display: none; }
.install-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; margin-bottom: 14px; border: 1px solid #bfdbfe; border-radius: 14px; background: #eff6ff; }
.install-banner strong, .install-banner span { display: block; }
.install-banner strong { color: #173968; font-size: .9rem; }
.install-banner span, .install-banner p { color: #475467; font-size: .8rem; }
.install-banner p { margin: 7px 0 0; }
.install-banner button { flex: none; min-height: 40px; padding: 8px 12px; border: 0; border-radius: 9px; background: #2563eb; color: white; font-weight: 750; }
.back-button { display: inline-flex; align-items: center; text-decoration: none; }
.history-page .history-panel { margin-top: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 18px; }
.toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 18px; margin-bottom: 20px; }
.period-tabs { display: flex; gap: 4px; padding: 4px; background: #e7ebf1; border-radius: 12px; overflow-x: auto; }
.period-tab { border: 0; background: transparent; color: #475467; min-height: 40px; padding: 8px 14px; border-radius: 9px; white-space: nowrap; font-weight: 700; }
.period-tab.is-active { background: white; color: var(--navy); box-shadow: 0 2px 8px rgba(16,24,39,.08); }
.filters { display: flex; gap: 10px; justify-content: flex-end; }
.filters label { display: grid; gap: 5px; color: var(--muted); font-size: .8rem; font-weight: 700; }
select { appearance: none; min-width: 160px; min-height: 42px; border: 1px solid #d7dce5; border-radius: 10px; background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='none' stroke='%23667085' stroke-width='1.5' d='m1 1 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center; padding: 8px 36px 8px 12px; color: var(--ink); }
.last-update { margin: 0 0 11px; color: var(--muted); font-size: .84rem; white-space: nowrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi-card, .panel, .message-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.kpi-card { padding: 20px; min-height: 140px; display: flex; flex-direction: column; }
.kpi-card p { margin: 0; color: var(--muted); font-size: .92rem; font-weight: 700; }
.kpi-card strong { margin: auto 0 2px; font-size: clamp(2rem, 4vw, 2.75rem); letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.kpi-card span { color: #8a94a6; font-size: .78rem; }
.accent-card { background: linear-gradient(150deg, #103c74, #2563eb); color: white; border-color: transparent; }
.accent-card p, .accent-card span { color: rgba(255,255,255,.78); }

.dashboard-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 14px; }
.panel { padding: 20px; min-width: 0; }
.production-panel { grid-column: span 2; }
.paper-panel { grid-column: span 2; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.section-label { color: #7b8495; }
h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.015em; }
.panel-total { color: var(--muted); font-size: .84rem; font-weight: 650; white-space: nowrap; }

.chart-wrap { min-height: 296px; width: 100%; overflow-x: auto; overflow-y: hidden; padding-bottom: 20px; -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain; cursor: grab; }
.chart-wrap.is-dragging { cursor: grabbing; user-select: none; }
@media (min-width: 641px) {
  .chart-wrap { scrollbar-width: none; }
  .chart-wrap::-webkit-scrollbar { display: none; }
  .chart-wrap.show-scrollbar { scrollbar-width: thin; scrollbar-color: #94a3b8 #edf0f4; }
  .chart-wrap.show-scrollbar::-webkit-scrollbar { display: block; height: 10px; }
  .chart-wrap.show-scrollbar::-webkit-scrollbar-track { background: #edf0f4; border-radius: 999px; }
  .chart-wrap.show-scrollbar::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 999px; }
}
.chart-wrap svg { display: block; width: max-content; max-width: none; height: 270px; }
.chart-hint { display: none; margin: -7px 0 10px; color: var(--muted); font-size: .8rem; }
.chart-hint[hidden] { display: none; }
.chart-grid { stroke: #e8ebf0; stroke-width: 1; }
.chart-bar { fill: var(--blue); rx: 5; }
.chart-label { fill: #7b8495; font-size: 11px; text-anchor: middle; }
.chart-value { fill: #475467; font-size: 11px; font-weight: 700; text-anchor: middle; }

.color-breakdown { min-height: 250px; display: grid; place-items: center; align-content: center; gap: 26px; }
.donut { width: 150px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--orange) var(--color-share, 0%), #dfe4eb 0); position: relative; }
.donut::after { content: ""; position: absolute; inset: 24px; background: white; border-radius: 50%; }
.donut span { z-index: 1; font-size: 1.8rem; font-weight: 800; }
.color-breakdown dl { width: 100%; margin: 0; }
.color-breakdown dl div { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.color-breakdown dt, .color-breakdown dd { margin: 0; }
.color-breakdown dd { font-weight: 800; font-variant-numeric: tabular-nums; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.color-dot { background: var(--orange); }
.bw-dot { background: #a7b0bf; }

.rank-list { display: grid; gap: 14px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(20px, 1.1fr) max-content; align-items: center; gap: 8px; }
.rank-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.rank-track { height: 8px; background: #edf0f4; border-radius: 99px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: inherit; background: var(--cyan); }
.users-panel .rank-fill { background: var(--green); }
.rank-value { font-weight: 800; font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.jobs-panel { margin-top: 14px; }
.history-panel { margin-top: 14px; }
.history-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.history-summary > div { display: flex; flex-direction: column; min-height: 106px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f7f9fc; }
.history-summary span { color: var(--muted); font-size: .83rem; font-weight: 700; }
.history-summary strong { margin-top: auto; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.history-summary small { color: var(--muted); }
.history-controls { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(130px, 1fr) minmax(160px, 1fr); gap: 10px; margin-bottom: 12px; }
.history-controls label { display: grid; gap: 6px; color: var(--muted); font-size: .875rem; font-weight: 700; }
.history-controls input { width: 100%; min-width: 0; min-height: 42px; padding: 9px 12px; border: 1px solid #d7dce5; border-radius: 10px; background: white; color: var(--ink); font: inherit; }
.history-date-field { display: grid; gap: 6px; position: relative; color: var(--muted); font-size: .875rem; font-weight: 700; }
.calendar-trigger { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #d7dce5; border-radius: 10px; background: white; color: var(--ink); text-align: left; font-weight: 650; }
.calendar-trigger::after { content: "▦"; float: right; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.calendar-trigger:hover, .calendar-trigger[aria-expanded="true"] { border-color: var(--blue); }
.calendar-popover { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(320px, calc(100vw - 36px)); padding: 14px; border: 1px solid #d7dce5; border-radius: 14px; background: white; box-shadow: 0 18px 48px rgba(16,24,39,.2); color: var(--ink); }
.calendar-popover[hidden] { display: none; }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.calendar-heading-title { display: grid; justify-items: center; gap: 1px; }
.calendar-heading-title button { width: auto; height: auto; padding: 2px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: .82rem; font-weight: 800; line-height: 1.3; }
.calendar-heading-title button:hover { background: #eff5ff; color: var(--blue); }
.calendar-heading-title #calendarYearButton { color: var(--muted); font-size: .75rem; }
.calendar-heading-title #calendarMonthButton { font-size: .93rem; }
.calendar-heading-title button[hidden] { display: none; }
.calendar-heading .calendar-arrow { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: #f7f9fc; color: var(--ink); font-size: 1.35rem; line-height: 1; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; text-align: center; }
.calendar-weekdays[hidden], .calendar-days[hidden] { display: none; }
.calendar-weekdays { margin-bottom: 4px; color: var(--muted); font-size: .73rem; }
.calendar-weekdays span { padding: 6px 0; }
.calendar-days button { aspect-ratio: 1; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-size: .82rem; }
.calendar-days button:hover { background: #eff5ff; }
.calendar-days button.is-selected { background: var(--blue); color: white; font-weight: 800; }
.calendar-days button.is-outside { color: #98a2b3; }
.calendar-days button.is-today:not(.is-selected) { box-shadow: inset 0 0 0 1px var(--blue); }
.calendar-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 6px 0 2px; }
.calendar-choices[hidden] { display: none; }
.calendar-choices button { min-height: 54px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9fc; color: var(--ink); font-size: .81rem; font-weight: 700; text-transform: capitalize; }
.calendar-choices button:hover { border-color: #93c5fd; background: #eff5ff; }
.calendar-choices button.is-selected { border-color: var(--blue); background: var(--blue); color: white; }
.calendar-today { width: 100%; min-height: 36px; margin-top: 10px; border: 1px solid #cbd7ec; border-radius: 9px; background: #eff5ff; color: #1d4ed8; font-weight: 750; }
.calendar-popover button:focus-visible, .calendar-trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.history-result-count { color: var(--muted); font-size: .875rem; margin: 0 0 8px; }
.history-list { display: grid; }
.history-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(150px, 1.4fr) 180px 105px 105px; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.history-row strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-row span { color: var(--muted); font-size: .84rem; }
.history-date { display: flex; gap: 4px; white-space: nowrap; }
.history-row b { font-variant-numeric: tabular-nums; }
.history-more { display: block; margin: 16px auto 0; min-height: 42px; padding: 8px 18px; border: 1px solid #cbd7ec; border-radius: 10px; background: #eff5ff; color: #1d4ed8; font-weight: 750; }
.history-more[hidden] { display: none; }
.jobs-list { display: grid; }
.job-row { display: grid; grid-template-columns: minmax(200px, 2fr) 90px 90px 90px 150px 100px; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.job-title { min-width: 0; }
.job-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-title span, .job-metric span { display: block; color: var(--muted); font-size: .76rem; margin-top: 3px; }
.job-metric { font-size: .9rem; font-weight: 700; }
.job-time { color: var(--muted); font-size: .84rem; text-align: right; }
.status-pill { display: inline-flex; align-items: center; width: fit-content; border-radius: 99px; padding: 4px 9px; background: #e7f6ef; color: #126a49; font-size: .75rem; font-weight: 800; }

.message-panel { padding: 32px; text-align: center; margin-top: 14px; }
.message-panel p { color: var(--muted); margin-bottom: 0; }
.empty-state { padding: 32px 4px; color: var(--muted); text-align: center; }
footer { padding: 10px 20px 30px; text-align: center; color: #8a94a6; font-size: .82rem; }

.loading-screen[hidden] { display: none; }
.skip-intro .loading-screen { display: none; }
.loading-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 36%, #1d3e74, #101827 65%); color: white; transition: opacity .4s ease, visibility .4s ease; }
.loading-screen.is-finished { opacity: 0; visibility: hidden; }
.loading-content { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 24px; }
.loading-content strong { margin-top: 8px; font-size: 1.15rem; }
.loading-content > span { color: #b9c6db; font-size: .9rem; }
.loading-brand { width: 84px; height: 84px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.32); border-radius: 24px; background: rgba(255,255,255,.08); font-size: 1.8rem; font-weight: 900; letter-spacing: -.08em; }
.loading-brand span { color: #60a5fa; }
.loading-art { position: relative; display: block; width: 84px; height: 36px; }
.loading-art i { position: absolute; display: block; background: #60a5fa; }
.loading-art-pulse i { top: 13px; left: calc(8px + var(--i, 0) * 18px); width: 10px; height: 10px; border-radius: 50%; animation: load-pulse 1.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * .15s); }
.loading-art i:nth-child(2) { --i: 1; }.loading-art i:nth-child(3) { --i: 2; }.loading-art i:nth-child(4) { --i: 3; }
@keyframes load-pulse { 0%,80%,100% { transform: scale(.65); opacity: .45; } 40% { transform: scale(1.35); opacity: 1; } }

@media (max-width: 1180px) {
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .period-tabs { grid-column: 1 / -1; justify-self: start; max-width: 100%; }
  .filters { grid-column: 1; justify-content: flex-start; min-width: 0; }
  .last-update { grid-column: 2; grid-row: 2; white-space: normal; text-align: right; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .production-panel, .paper-panel { grid-column: auto; }
}

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .job-row { grid-template-columns: minmax(180px, 2fr) 84px 84px 130px 100px; }
  .job-row .job-metric:nth-child(4) { display: none; }
  .history-row { grid-template-columns: minmax(180px, 2fr) minmax(130px, 1.3fr) 180px 90px; }
  .history-row .history-sheets { display: none; }
}

@media (min-width: 641px) and (max-width: 760px) {
  .job-row { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px 12px; }
  .job-title { grid-column: 1 / 4; grid-row: 1; }
  .job-row .job-metric:nth-child(2) { grid-column: 1; grid-row: 2; }
  .job-row .job-metric:nth-child(3) { grid-column: 2; grid-row: 2; }
  .job-row .job-metric:nth-child(4) { display: block; grid-column: 3; grid-row: 2; }
  .job-time { grid-column: 4; grid-row: 1; }
  .status-pill { grid-column: 4; grid-row: 2; }
  .history-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; }
  .history-row .history-title, .history-row .history-paper { grid-column: 1; }
  .history-row .history-date { grid-column: 2; grid-row: 1; flex-direction: column; gap: 0; text-align: right; }
  .history-row .history-prints { grid-column: 2; grid-row: 2; }
}

@media (min-width: 641px) and (max-width: 700px) {
  .dashboard-grid { display: grid; grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .history-page .topbar { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
  .history-page .topbar-actions { width: 100%; }
  .history-page .topbar-actions > * { flex: 1; justify-content: center; text-align: center; }
  .history-page .history-panel { order: 0; }
  .topbar { min-height: 112px; padding: 18px 16px; }
  .eyebrow { font-size: .75rem; }
  h1 { font-size: 1.65rem; }
  .refresh-button { padding-inline: 12px; }
  main { width: min(100% - 24px, 1420px); padding-top: 14px; display: flex; flex-direction: column; }
  .quick-nav { order: 0; width: 100%; min-width: 0; max-width: 100%; margin-bottom: 14px; margin-inline: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
  .install-banner { order: 1; }
  .quick-nav a { padding: 8px 12px; }
  .toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar { order: 2; }
  .period-tabs { width: 100%; }
  .period-tab { flex: 1 0 auto; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label { font-size: .875rem; }
  select { min-width: 0; width: 100%; }
  .last-update { margin: 0; }
  .kpi-grid { order: 3; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { min-height: 116px; padding: 14px; }
  .kpi-card p { font-size: .875rem; line-height: 1.25; }
  .kpi-card strong { font-size: 2rem; }
  .kpi-card span { font-size: .75rem; }
  .jobs-panel { order: 4; margin-top: 0; margin-bottom: 14px; }
  .dashboard-grid { order: 5; }
  .history-panel { order: 6; margin-top: 0; }
  .history-page .history-panel { order: 0; }
  .history-page .panel-heading { flex-direction: column; gap: 4px; }
  .history-page .history-row strong { white-space: normal; overflow: visible; }
  .message-panel { order: 7; }
  .dashboard-grid { display: block; }
  .dashboard-grid .panel { margin-bottom: 10px; }
  .panel { padding: 16px; }
  .chart-wrap { min-height: 310px; height: 310px; padding-bottom: 28px; }
  .chart-wrap svg { min-height: 270px; height: 270px; }
  .chart-hint { display: block; }
  .rank-row { grid-template-columns: minmax(0, 1fr) minmax(20px, 1fr) max-content; gap: 8px; }
  .job-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 16px 0; }
  .job-title { grid-column: 1; }
  .job-row .job-metric { display: flex; gap: 6px; align-items: baseline; }
  .job-row .job-metric:nth-child(4) { display: flex; }
  .job-row .job-metric span { display: inline; }
  .job-row .job-time { grid-column: 2; grid-row: 1; }
  .job-row .status-pill { grid-column: 2; }
  .history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-controls { grid-template-columns: 1fr 1fr; }
  .history-controls select { font-size: .8rem; padding-left: 10px; padding-right: 25px; background-position: right 9px center; }
  .history-search-label { grid-column: 1 / -1; }
  .history-row { grid-template-columns: 1fr auto; gap: 5px 12px; }
  .history-row .history-title { grid-column: 1; }
  .history-row .history-paper { grid-column: 1; }
  .history-row .history-date { grid-column: 2; grid-row: 1; flex-direction: column; gap: 0; text-align: right; }
  .history-row .history-prints { grid-column: 2; grid-row: 2; color: var(--ink); }
  .history-row .history-sheets { display: none; }
}

@media (max-width: 410px) {
  .kpi-card { min-height: 110px; padding: 13px; }
  .kpi-card strong { font-size: 1.8rem; }
  .filters { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .install-banner { align-items: flex-start; flex-direction: column; }
  .period-tabs { flex-wrap: wrap; overflow: visible; }
  .period-tab { flex: 1 1 calc(50% - 4px); }
  .history-controls { grid-template-columns: 1fr; }
  .history-search-label { grid-column: 1; }
  .history-page .back-button { padding-inline: 8px; font-size: .8rem; white-space: nowrap; }
}
