/* PO Overview — horizontal calendar view.
   Visual language: medusajs.com — warm off-white, Instrument Serif headlines,
   Inter for body, JetBrains Mono for numbers and SKUs. */

:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --bg-elev: #fbf9f4;
  --ink: #0a0a0a;
  --ink-soft: #4a4a4a;
  --ink-mute: #8a877f;
  --line: #e6e2d8;
  --line-strong: #cdc7b9;
  --accent: #111111;
  --accent-fg: #f6f4ef;
  --positive: #1f6b3a;
  --warn: #a26b00;
  --bad: #8a1f1f;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", "Georgia", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --topbar-h: 56px;
  --nav-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* one-page layout */
}

/* ------- Top bar ------- */
.topbar {
  position: relative;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: 100%;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; }
.brand-logo {
  height: 18px;
  width: auto;
  display: block;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  height: 30px;
  width: 320px;
  flex: 0 0 auto;
  margin: 0 6px;
  transition: border-color 0.15s ease;
}
.search:focus-within { border-color: var(--ink); }
.search-icon { width: 14px; height: 14px; color: var(--ink-mute); margin-right: 8px; flex: 0 0 14px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; color: var(--ink); }
.search input::placeholder { color: var(--ink-mute); }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 6px;
  background: var(--bg);
}

.meta-label {
  color: var(--ink-mute);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  white-space: nowrap;
}
.signout-btn {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  height: 28px;
  padding: 0 10px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.signout-btn:hover { border-color: var(--line-strong); color: var(--ink); }

.bell-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.bell-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.bell-btn.has-unread { color: var(--ink); }
.bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--bad);
  color: white;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}
.bell-badge[hidden] { display: none !important; }
.bell-btn.bell-ok { color: var(--positive); border-color: rgba(31, 107, 58, 0.3); background: rgba(31, 107, 58, 0.05); }

.notifications {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.notifications[aria-hidden="false"] { pointer-events: auto; }
.notif-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0);
  transition: background 0.15s ease;
}
.notifications[aria-hidden="false"] .notif-scrim { background: rgba(10, 10, 10, 0.18); }
.notif-panel {
  position: absolute;
  top: calc(var(--topbar-h) + 6px);
  right: 14px;
  width: min(380px, 92vw);
  max-height: 70vh;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notifications[aria-hidden="false"] .notif-panel {
  transform: translateY(0);
  opacity: 1;
}
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px 8px 14px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.notif-tabs {
  display: flex;
  gap: 2px;
}
.notif-tab {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: 0;
  color: var(--ink-mute);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.notif-tab:hover { background: var(--bg-elev); color: var(--ink); }
.notif-tab.is-active {
  background: var(--accent);
  color: var(--accent-fg);
}
.notif-tab.is-active .notif-tab-count {
  background: rgba(255, 255, 255, 0.18);
  color: var(--accent-fg);
}
.notif-tab-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 1px 5px;
  min-width: 14px;
  text-align: center;
  letter-spacing: 0;
}
.notif-clear {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 11px;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.notif-clear:hover { color: var(--ink); }
.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.notif-empty {
  text-align: center;
  padding: 30px 18px;
  color: var(--ink-mute);
  font-size: 12px;
}
.notif-item {
  padding: 10px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 2px solid transparent;
  transition: background 0.1s ease;
}
.notif-item:hover { background: var(--bg-elev); }
.notif-item.unseen { border-left-color: var(--bad); background: var(--bg-elev); }
.notif-item-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
}
.notif-item-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
}
.notif-item-changes {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-top: 2px;
}
.notif-item-changes [data-color="ok"]   { color: var(--positive); font-weight: 500; }
.notif-item-changes [data-color="warn"] { color: var(--warn);     font-weight: 500; }
.notif-item-changes [data-color="bad"]  { color: var(--bad);      font-weight: 500; }
.notif-item-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
}

/* ------- Nav bar ------- */
.nav {
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }
.nav-spacer { flex: 1 1 auto; min-width: 14px; }
.nav-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-btn {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  height: 28px;
  min-width: 28px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-btn:hover:not(:disabled) { border-color: var(--line-strong); background: var(--bg); }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.nav-today { font-weight: 500; }
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0;
}
.nav-range {
  margin-left: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
}

.empty-jump {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.empty-jump-btn {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.empty-jump-btn:hover { opacity: 0.85; }

/* ------- Stock rail (collapsible search-driven stock lookup) ------- */
.stock-rail {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.stock-rail[hidden] { display: none; }
.stock-rail-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
  transition: background 0.1s ease;
}
.stock-rail-details > summary:hover { background: var(--bg-elev); }
.stock-rail-details > summary::-webkit-details-marker { display: none; }
.stock-rail-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.stock-rail-chevron {
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--ink-mute);
  border-bottom: 1px solid var(--ink-mute);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  display: inline-block;
  margin-bottom: 2px;
}
.stock-rail-details[open] .stock-rail-chevron { transform: rotate(45deg); }
.stock-rail-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.stock-rail-title .stock-rail-count {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--ink-mute);
  font-size: 10.5px;
  letter-spacing: 0;
}
.stock-list {
  display: flex;
  flex-direction: column;
  padding: 4px 24px 14px;
  max-height: 200px;
  overflow-y: auto;
}
.stock-item {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s ease;
  cursor: pointer;
}
.stock-item:last-child { border-bottom: 0; }
.stock-item:hover { background: var(--bg-elev); }
.stock-item-sku {
  flex: 0 0 60px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.stock-item-name {
  flex: 0 1 360px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stock-item-name mark {
  background: rgba(255, 222, 89, 0.55);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
/* Bundle badge slot — always reserved (60px) so stats column stays aligned
   across rows. Empty span when item isn't a bundle. */
.stock-badge-slot {
  margin-left: auto;
  flex: 0 0 60px;
  text-align: right;
  white-space: nowrap;
}
.stock-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 8.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(162, 107, 0, 0.08);
  color: #8a5a14;
  border: 1px solid rgba(162, 107, 0, 0.22);
}
.stock-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.stock-stats-secondary {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-left: 8px;
}
/* Bundles aren't physically stocked, so reserved + in stock are always 0
   and would just be noise. We hide them with visibility (not display) so
   the row still reserves the space — "available" stays in the same
   column position across bundle and non-bundle rows. */
.stock-item.is-bundle .stock-stats-secondary { visibility: hidden; }
.stock-stat { display: inline-flex; align-items: baseline; gap: 5px; }
.stock-stat-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.01em;
}
.stock-num,
.stock-avail {
  font-weight: 500;
  color: var(--ink);
  display: inline-block;
  min-width: 4ch;
  text-align: right;
}
.stock-sep { color: var(--ink-mute); opacity: 0.55; }
.stock-avail[data-state="ok"] { color: var(--positive); }
.stock-avail[data-state="low"] { color: var(--warn); }
.stock-avail[data-state="zero"] { color: var(--bad); }
.stock-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  padding: 12px;
}

/* ------- Country toggle (DK / US) — segmented mono control ------- */
.country-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  height: 28px;
  align-items: center;
  flex-shrink: 0;
}
.country-btn {
  background: transparent;
  border: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  height: 22px;
  padding: 0 9px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.country-btn:hover:not(.is-active) { color: var(--ink); background: var(--bg); }
.country-btn.is-active { background: var(--accent); color: var(--accent-fg); }
.country-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.country-dot--dk { background: #C8102E; }
.country-dot--us { background: #3C3B6E; }

/* ------- Filter pills (inline in nav bar) ------- */
.filter-pill {
  font: inherit;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  height: 28px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.filter-pill:hover {
  background: var(--bg-elev);
  color: var(--ink);
}
.filter-pill.is-active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.filter-pill.is-active .filter-pill-count {
  color: var(--accent-fg);
  opacity: 0.6;
}
.filter-pill-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  font-weight: 400;
}

/* ------- Calendar grid ------- */
.calendar {
  height: calc(100vh - var(--topbar-h) - var(--nav-h));
  padding: 18px 24px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  overflow: hidden;
}

.empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  text-align: center;
}
.empty-title {
  font-family: var(--font-serif);
  font-size: 22px;
  margin: 0;
}
.empty-sub {
  color: var(--ink-mute);
  margin: 6px 0 0;
}
.empty.error .empty-title { color: var(--bad); }

/* ------- Month column ------- */
.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.col.is-past { opacity: 0.55; }

.col-head {
  display: flex;
  align-items: baseline;
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.col-month {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.1;
}

/* US container header — container name on top, PO + month + warehouse + status below */
.col-head--container {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}
.col-head-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.col-container-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.col-container-meta .sep { margin: 0 4px; opacity: 0.5; }
.col-status {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.col-status[data-status="ok"]   { color: var(--positive); background: rgba(31, 107, 58, 0.08); border-color: rgba(31, 107, 58, 0.25); }
.col-status[data-status="warn"] { color: var(--warn);     background: rgba(162, 107, 0, 0.08); border-color: rgba(162, 107, 0, 0.25); }
.col-status[data-status="bad"]  { color: var(--bad);      background: rgba(138, 31, 31, 0.08); border-color: rgba(138, 31, 31, 0.25); }

.col { position: relative; }
.col-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  padding-bottom: 18px;
  margin-right: -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.col-body::-webkit-scrollbar { width: 6px; }
.col-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* Fade + chevron at bottom of column when there's more content below */
.col-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(246, 244, 239, 0), var(--bg) 70%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.col-fade::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.2px solid var(--ink-mute);
  border-bottom: 1.2px solid var(--ink-mute);
  transform: rotate(45deg);
  margin-bottom: 4px;
  display: block;
}
.col.has-overflow .col-fade { opacity: 1; }
.col.has-overflow.scrolled-bottom .col-fade { opacity: 0; }

/* ------- Tile (compact) ------- */
.tile {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease;
}
.tile:hover { border-color: var(--line-strong); }

.tile-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.tile-name {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tile-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-soft);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tile-sku {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tile-status {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tile-status[data-status="ok"] {
  color: var(--positive);
  background: rgba(31, 107, 58, 0.08);
  border-color: rgba(31, 107, 58, 0.25);
}
.tile-status[data-status="warn"] {
  color: var(--warn);
  background: rgba(162, 107, 0, 0.08);
  border-color: rgba(162, 107, 0, 0.25);
}
.tile-status[data-status="bad"] {
  color: var(--bad);
  background: rgba(138, 31, 31, 0.08);
  border-color: rgba(138, 31, 31, 0.25);
}

.tile-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.tile-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.tile-bar-fill {
  display: block;
  height: 100%;
  background: var(--positive);
  transition: width 0.2s ease;
}
.tile-bar-fill[data-state="low"] { background: var(--warn); }
.tile-bar-fill[data-state="zero"] { background: var(--bad); }

.tile-stats {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.tile-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.tile-stat-label {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.01em;
}
.tile-incoming,
.tile-avail {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.tile-incoming { color: var(--ink-soft); font-weight: 400; }
.tile-avail[data-state="ok"]   { color: var(--positive); }
.tile-avail[data-state="low"]  { color: var(--warn); }
.tile-avail[data-state="zero"] { color: var(--bad); }
.tile-sep { color: var(--ink-mute); }

/* ------- Highlight ------- */
mark {
  background: rgba(255, 222, 89, 0.55);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ------- Empty column state ------- */
.col-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
  text-align: center;
  padding: 24px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

/* ------- Detail panel (slides in from right) ------- */
.panel {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
.panel[aria-hidden="false"] { pointer-events: auto; }

.panel-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0);
  transition: background 0.2s ease;
}
.panel[aria-hidden="false"] .panel-scrim {
  background: rgba(10, 10, 10, 0.18);
}

.panel-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 96vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.06);
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel[aria-hidden="false"] .panel-card { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head-text { min-width: 0; flex: 1; }
.panel-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.panel-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.panel-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.panel-close {
  font: inherit;
  font-size: 14px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.panel-close:hover { border-color: var(--line-strong); color: var(--ink); }

.panel-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-card > .panel-section + .panel-section { border-top: 1px solid var(--line); }
.panel-section {
  padding: 18px 24px;
}
.panel-section[hidden] { display: none; }

/* Selected line: always visible at top, never cropped */
#panelSelectedSection { flex: 0 0 auto; }
/* Reservations: prominent middle block, scrolls if very long */
#panelReservationsSection {
  flex: 0 1 auto;
  overflow-y: auto;
  max-height: 45vh;
}
/* Other items on PO: bottom, can take remaining space and scroll */
#panelOtherSection {
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 80px;
  padding-bottom: 32px;
}

.panel-section-title {
  margin: 0 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
  font-weight: 500;
}

.panel-line {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
}
.panel-line code {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-weight: 400;
}

.panel-stats {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.panel-stats > div { display: flex; flex-direction: column; gap: 2px; }
.panel-stats dt {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  margin: 0;
}
.panel-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
}
.panel-stats dd[data-state="ok"]   { color: var(--positive); }
.panel-stats dd[data-state="low"]  { color: var(--warn); }
.panel-stats dd[data-state="zero"] { color: var(--bad); }

.panel-reservations {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel-reservation {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.panel-reservation-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.panel-reservation-meta {
  grid-column: 1 / 2;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mute);
}
.panel-reservation-qty {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  align-self: center;
  text-align: right;
  white-space: nowrap;
}
.panel-reservation-qty small {
  font-weight: 400;
  color: var(--ink-mute);
  margin-left: 3px;
}

.panel-reservations-empty {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}

.panel-other {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.panel-other-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: baseline;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  transition: border-color 0.15s ease;
}
.panel-other-row:hover { border-color: var(--line-strong); cursor: pointer; }
.panel-other-name { font-size: 12.5px; font-weight: 500; }
.panel-other-meta {
  grid-column: 1 / 2;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
}
.panel-other-qty {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  font-family: var(--font-mono);
  font-size: 12.5px;
  align-self: center;
  white-space: nowrap;
}
.panel-other-empty {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}

.tile { cursor: pointer; position: relative; }

.tile-watch {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink-mute);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  z-index: 1;
}
.tile:hover .tile-watch { opacity: 0.7; }
.tile-watch:hover { opacity: 1 !important; color: var(--ink); background: var(--bg); }
.tile.is-watched .tile-watch {
  opacity: 1;
  color: var(--warn);
}
.tile.is-watched .tile-watch svg { fill: var(--warn); }

.panel-watch {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.panel-watch:hover { border-color: var(--line-strong); color: var(--ink); }
.panel-watch.is-watched {
  color: var(--warn);
  background: rgba(162, 107, 0, 0.06);
  border-color: rgba(162, 107, 0, 0.3);
}
.panel-watch.is-watched svg { fill: var(--warn); }

/* ------- Responsive ------- */
@media (max-width: 1100px) {
  .calendar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { overflow: auto; }
  .calendar {
    grid-template-columns: 1fr;
    height: auto;
  }
  .topbar-inner { grid-template-columns: 1fr; gap: 10px; padding: 10px 18px; height: auto; }
  .topbar { height: auto; }
}
