:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101621;
  color: #edf4ff;
  --surface: #1a2230;
  --border: #2a394c;
  --muted: #a6b4ca;
  --green: #72e7af;
  --red: #ff9a9f;
  --amber: #f7c46c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 45% -55%, #29446a, transparent 68%);
}

.dashboard {
  max-width: 96rem;
  margin: auto;
  padding: 1.4rem clamp(1rem, 3vw, 2.5rem) 1.5rem;
}

.dashboard-header, .heading, .overview, .counts, .timing, .total {
  display: flex;
  align-items: center;
}

.dashboard-header {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.heading { gap: .85rem; }

.alert-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: none;
  border: 1px solid #557bae;
  border-radius: .85rem;
  background: linear-gradient(145deg, #244f91, #1e3462);
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -.05em;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.8vw, 2rem);
  line-height: 1.15;
  letter-spacing: -.04em;
}

.market {
  margin: .23rem 0 0;
  color: var(--muted);
  font-size: .85rem;
}

button {
  flex: none;
  padding: .55rem .9rem;
  border: 1px solid #7299db;
  border-radius: .55rem;
  background: #b0cdfb;
  color: #10254a;
  font: 650 .875rem/1.2 system-ui, sans-serif;
  cursor: pointer;
}

button:hover { background: #c7ddff; }
button[aria-pressed="true"] { background: #213650; color: #d3e3ff; }
button:disabled { opacity: .7; cursor: progress; }

.test-alert {
  padding: .4rem .6rem;
  border-color: #526a8b;
  background: transparent;
  color: #cfdef4;
}

.test-alert:hover { background: #213650; }

.stop-alarm {
  padding: .4rem .6rem;
  border-color: #ff9a9f;
  background: #8a2b37;
  color: #fff;
}

.stop-alarm:hover { background: #a43342; }

button:focus-visible, .product:focus-visible, .product-history:focus-visible {
  outline: 2px solid #a9cbff;
  outline-offset: 2px;
}

.overview {
  min-height: 2.5rem;
  justify-content: space-between;
  gap: .55rem 1.2rem;
  flex-wrap: wrap;
  margin-bottom: .65rem;
  padding: .46rem .7rem;
  border: 1px solid var(--border);
  border-radius: .6rem;
  background: #151e2d;
  color: var(--muted);
  font-size: .875rem;
}

.counts, .timing { flex-wrap: wrap; gap: .45rem 1rem; }
.counts > :first-child { color: #e0ebfb; font-weight: 650; }
.timing { font-size: .8125rem; font-variant-numeric: tabular-nums; }
.dashboard-link { color: #a9cbff; text-underline-offset: .16em; }
.dashboard-link:hover { color: #d3e3ff; }
.total { gap: .35rem; }
.total-in { color: var(--green); }
.total-out { color: var(--red); }
.total-unknown { color: var(--amber); }
.dot { width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }

.dashboard-message {
  margin: 0 0 .6rem;
  color: var(--amber);
  font-size: .875rem;
}

.products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .42rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.product {
  display: flex;
  height: 4.2rem;
  flex-direction: column;
  justify-content: space-between;
  gap: .2rem;
  padding: .38rem .55rem .42rem .65rem;
  border: 1px solid var(--border);
  border-left: 3px solid #5c6f8b;
  border-radius: .48rem;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.product:hover { background: #233044; }
.product.in { border-left-color: #51cf94; background: #18302e; }
.product.in:hover { background: #204039; }
.product.out { border-left-color: #db717b; }
.product.unknown { border-left-color: #d9a752; }

.product-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  font-size: .875rem;
  font-weight: 620;
  line-height: 1.18;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  white-space: nowrap;
  font-size: .875rem;
  line-height: 1.15;
}

.price { color: var(--muted); font-variant-numeric: tabular-nums; }
.stock { color: var(--amber); font-weight: 650; }
.product.in .stock { color: var(--green); }
.product.out .stock { color: var(--red); }
.product.live-product {
  position: relative;
  isolation: isolate;
  height: 5.45rem;
}
.product-checked { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }

.live-product.just-checked::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: rgb(101 168 243 / .28);
  box-shadow: inset 0 0 0 1px rgb(162 208 255 / .55);
  pointer-events: none;
  animation: product-check-pulse 1050ms ease-out both;
}

@keyframes product-check-pulse {
  0% { opacity: .7; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .live-product.just-checked::after { animation: none; opacity: .75; }
}

@media (max-width: 60rem) {
  .products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 44rem) {
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard { padding: .9rem .7rem; }
}

@media (max-width: 30rem) {
  .mark { display: none; }
  .alert-actions { flex-direction: column-reverse; align-items: flex-end; gap: .3rem; }
  .product { height: 4.45rem; }
  .product-meta { font-size: .8125rem; }
}

@media (max-width: 23rem) {
  .products { grid-template-columns: minmax(0, 1fr); }
}

.products > li { position: relative; }
.products > li:has(> .product-history) .product-name { margin-inline-end: 1.6rem; }

.product-history {
  position: absolute;
  z-index: 1;
  inset-block-start: .24rem;
  inset-inline-end: .45rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: .35rem;
  color: var(--muted);
}

.product-history::before {
  content: "";
  width: .8rem;
  height: .8rem;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.product-history::after {
  content: "";
  position: absolute;
  bottom: 45%;
  left: 50%;
  width: .22rem;
  height: .3rem;
  border-left: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
}

.product-history:hover { background: #213650; color: #edf4ff; }

.products > .ps-stock-basket-card:has(> .product:not(.live-product)) .product-history {
  inset-inline-start: .57rem;
  inset-inline-end: auto;
}

.products > .ps-stock-basket-card > .product:not(.live-product) .product-name { margin-inline-start: 1.6rem; }

.history-page { max-width: 76rem; }
.history-nav { display: flex; gap: 1rem; margin-bottom: 1rem; }
.history-overview { margin-top: 1rem; }
.history-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 27rem), 1fr));
  gap: .75rem;
  align-items: start;
  margin-top: 1rem;
}

.history-section {
  min-width: 0;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: .6rem;
  background: var(--surface);
}

.history-section h2 { margin: 0 0 .5rem; font-size: 1rem; }
.history-note { color: var(--muted); font-size: .8125rem; }
.history-table-wrap { overflow-x: auto; }
.history-section table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.history-section :is(th, td) {
  padding: .48rem .4rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.history-section th { color: var(--muted); }
.history-section td time { white-space: nowrap; }
.history-section tr:last-child td { border-bottom: 0; }

.restock-bars { display: grid; gap: .5rem; list-style: none; padding: 0; margin: 0; }
.restock-bars li {
  display: grid;
  grid-template-columns: 6.75rem minmax(0, 1fr) 2ch;
  align-items: center;
  gap: .6rem;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}
.restock-bars meter { width: 100%; height: 1rem; }
.restock-bars meter::-moz-meter-bar { background: #51cf94; }
.restock-bars strong { text-align: right; }
