/* FA004 Freezer Map - visual identity: ice blue + navy, frost-white bins, find spotlight */
:root {
  --ice: #A8DADC;
  --ice-deep: #7FC4C8;
  --ice-pale: #DDF1F2;
  --navy: #1D3557;
  --navy-deep: #12233B;
  --navy-soft: #2C4C78;
  --frost: #FBFDFE;
  --frost-edge: #E3EEF1;
  --ink: #16273F;
  --ink-muted: #4E617A;
  --warn: #E8A33A;
  --warn-ink: #6A4400;
  --danger: #C4453D;
  --spot: #FFF3B0;
  --spot-glow: rgba(255, 243, 176, 0.85);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(29, 53, 87, 0.18);
  --focus: 3px solid #F4A261;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--ice-pale) 0%, #EEF7F8 40%, #F6FAFB 100%);
  min-height: 100vh;
  line-height: 1.4;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: var(--focus); outline-offset: 2px; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--navy); color: #fff; padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between;
  padding: 18px clamp(12px, 3vw, 32px) 14px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; background: var(--frost); padding: 2px; }
.brand h1 { font-size: 1.5rem; letter-spacing: 0.01em; }
.tagline { margin: 2px 0 0; color: var(--ice); font-size: 0.9rem; }
.find { flex: 1 1 320px; max-width: 520px; }
.find label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--ice); margin-bottom: 4px; }
.find-row { display: flex; gap: 8px; }
.find input {
  flex: 1; padding: 10px 14px; border-radius: 999px; border: 2px solid var(--ice-deep);
  background: var(--frost); color: var(--ink); min-width: 0;
}
.find input:focus { border-color: var(--spot); }
.find .help { margin: 6px 0 0 12px; font-size: 0.8rem; color: var(--ice); }
.topbar .btn.ghost { color: #fff; border-color: var(--ice-deep); }

.status { min-height: 1.4em; margin: 10px clamp(12px, 3vw, 32px) 0; font-size: 0.92rem; color: var(--navy-soft); }
.status.is-error { color: var(--danger); font-weight: 600; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px;
  padding: 12px clamp(12px, 3vw, 32px) 24px; max-width: 1280px; margin: 0 auto;
}
@media (min-width: 820px) {
  .layout { grid-template-columns: minmax(300px, 5fr) minmax(320px, 6fr); align-items: start; }
}

.map-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.map-head h2 { font-size: 1.15rem; color: var(--navy); }
.overview { margin: 0; font-size: 0.88rem; color: var(--ink-muted); }

/* ---------- the freezer ---------- */
.freezer {
  position: relative;
  background: linear-gradient(180deg, var(--navy-soft), var(--navy) 18%, var(--navy-deep));
  border-radius: 22px; padding: 10px 14px 14px;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(168, 218, 220, 0.25);
}
.freezer-lid {
  height: 26px; margin: -10px -14px 12px; border-radius: 22px 22px 6px 6px;
  background: linear-gradient(180deg, #3A5F8F, var(--navy-soft));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.lid-hinge { width: 64px; height: 6px; border-radius: 3px; background: var(--ice); opacity: 0.85; }
.freezer-base { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.vent { width: 34px; height: 5px; border-radius: 3px; background: var(--ice-deep); opacity: 0.5; }

.bins { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, rgba(168, 218, 220, 0.16), rgba(168, 218, 220, 0.05));
  border-radius: 14px; border: 1px solid rgba(168, 218, 220, 0.25); }
.bin-slot { margin: 0; }

.bin {
  position: relative; width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 12px 14px; min-height: 60px;
  color: var(--ink); background: linear-gradient(180deg, #FFFFFF, var(--frost) 55%, var(--frost-edge));
  border: 2px solid var(--frost-edge); border-radius: var(--radius);
  box-shadow: 0 3px 0 #BFD9DC, 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease, filter 160ms ease;
}
.bin:hover { transform: translateX(4px); }
.bin.is-open { transform: translateX(12px); border-color: var(--ice-deep); box-shadow: 0 3px 0 var(--ice-deep), 0 10px 20px rgba(0, 0, 0, 0.3); }
.bin.is-open::after {
  content: ""; position: absolute; left: -14px; top: 50%; width: 0; height: 0; transform: translateY(-50%);
  border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-right: 10px solid var(--ice);
}
.bin.is-empty .bin-name { color: var(--ink-muted); }
.bin-handle { display: block; width: 26px; height: 8px; border-radius: 4px; background: var(--navy); opacity: 0.85; }
.bin.kind-shelf .bin-handle { width: 26px; height: 4px; background: var(--ice-deep); }
.bin.kind-drawer { padding-top: 14px; padding-bottom: 14px; }
.bin.kind-drawer .bin-handle { width: 34px; height: 10px; border-radius: 5px; box-shadow: inset 0 2px 0 rgba(255,255,255,0.35); }
.bin.kind-door { background: linear-gradient(90deg, var(--ice-pale), var(--frost) 30%); border-style: dashed; }
.bin.kind-door .bin-handle { width: 8px; height: 26px; border-radius: 4px; background: var(--ice-deep); }
.bin-name { font-weight: 700; font-size: 1.02rem; }
.bin-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.badge { font-size: 0.74rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--ice-pale); color: var(--navy); white-space: nowrap; }
.badge.warn { background: #FFE9C4; color: var(--warn-ink); }
.badge.hit { background: var(--navy); color: var(--spot); }

/* find spotlight */
.freezer.is-finding .bin.is-dim { opacity: 0.42; filter: saturate(0.4); }
.bin.is-lit {
  border-color: var(--spot); background: linear-gradient(180deg, #FFFDF0, #FFF9DB 60%, #FFF3B0);
  box-shadow: 0 0 0 4px var(--spot-glow), 0 0 28px 8px var(--spot-glow), 0 6px 14px rgba(0, 0, 0, 0.18);
  animation: spot-pulse 1.6s ease-in-out infinite;
}
.beam {
  position: absolute; left: -14px; top: -6px; bottom: -6px; width: 0; pointer-events: none;
}
.beam::before {
  content: ""; position: absolute; right: 100%; top: -40%; height: 180%; width: 140px; margin-right: -6px;
  background: linear-gradient(90deg, rgba(255, 243, 176, 0), rgba(255, 243, 176, 0.55));
  clip-path: polygon(0 45%, 100% 0, 100% 100%, 0 55%);
}
@keyframes spot-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--spot-glow), 0 0 22px 6px var(--spot-glow), 0 6px 14px rgba(0, 0, 0, 0.18); }
  50% { box-shadow: 0 0 0 6px var(--spot-glow), 0 0 36px 12px var(--spot-glow), 0 6px 14px rgba(0, 0, 0, 0.18); }
}

.map-actions { margin-top: 12px; }

/* manage bins */
.manage-bins { margin-top: 12px; padding: 14px; background: var(--frost); border: 1px solid var(--frost-edge); border-radius: var(--radius); }
.manage-bins h3 { font-size: 1rem; color: var(--navy); margin-bottom: 8px; }
.bin-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
.bin-form .error { grid-column: 1 / -1; }
.bin-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bin-row { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 6px; align-items: center; }
.bin-row input { min-width: 0; }
.bin-row-kind { font-size: 0.74rem; color: var(--ink-muted); width: 62px; }
@media (max-width: 480px) {
  .bin-form { grid-template-columns: 1fr 1fr; }
  .bin-form .btn { grid-column: 1 / -1; }
  .bin-row { grid-template-columns: 1fr 1fr 1fr; }
  .bin-row input { grid-column: 1 / -1; }
  .bin-row-kind { grid-column: 1 / -1; width: auto; }
}

/* ---------- panel ---------- */
.panel {
  background: var(--frost); border: 1px solid var(--frost-edge); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 4px 16px rgba(29, 53, 87, 0.08); min-height: 240px;
}
.panel-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); margin-bottom: 10px; }
.sub-title { font-size: 1.2rem; color: var(--navy); }
.meta { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.bin-head { margin-bottom: 10px; }
.empty { padding: 12px 6px; }
.empty-lead { font-size: 1.15rem; font-weight: 700; color: var(--navy); margin: 0 0 6px; }
.empty p { margin: 0 0 12px; }
.muted { color: var(--ink-muted); font-size: 0.92rem; padding: 8px 0; }

.item-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  padding: 10px 12px; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--frost-edge);
  border-left: 5px solid var(--ice-deep);
}
.item.level-aging { border-left-color: var(--warn); }
.item.level-long { border-left-color: var(--danger); background: #FFF8F3; }
.item.level-unknown { border-left-color: #B9C4D1; }
.item-main { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item-name { font-weight: 700; }
.item-qty { font-variant-numeric: tabular-nums; color: var(--navy-soft); white-space: nowrap; }
.item-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.84rem; color: var(--ink-muted); margin-top: 2px; }
.item-sub .where { color: var(--navy); font-weight: 600; }
.item-sub .where::before { content: "\2192  "; }
.item.level-long .age { color: var(--danger); font-weight: 600; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.move-select { padding: 4px 6px; border-radius: 6px; border: 1px solid #B9C4D1; background: #fff; font-size: 0.85rem; }

/* forms */
.item-form { border-top: 1px dashed var(--ice-deep); padding-top: 12px; }
.item-form h4 { font-size: 1rem; color: var(--navy); margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.88rem; }
.optional { font-weight: 400; color: var(--ink-muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr; } }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  padding: 8px 10px; border: 1px solid #B9C4D1; border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%; min-width: 0;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: #FFF6F5; }
.error { margin: 0; color: var(--danger); font-size: 0.84rem; min-height: 0; }
.error:empty { display: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* buttons */
.btn {
  padding: 8px 14px; border-radius: 999px; border: 2px solid var(--navy); background: #fff; color: var(--navy);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--ice-pale); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-soft); }
.btn.ghost { background: transparent; border-color: var(--ice-deep); color: var(--navy); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #FFF0EE; }
.btn.small { padding: 4px 10px; font-size: 0.84rem; border-width: 1.5px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* toolbar + import */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 8px clamp(12px, 3vw, 32px) 20px; max-width: 1280px; margin: 0 auto; }
.import-panel { max-width: 720px; margin: 0 auto 32px; padding: 16px; background: var(--frost); border: 1px solid var(--frost-edge); border-radius: var(--radius); }
.import-panel h2 { font-size: 1.05rem; color: var(--navy); margin-bottom: 4px; }
.import-panel .help { margin: 0 0 10px; font-size: 0.88rem; color: var(--ink-muted); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; resize: vertical; }

.print-sheet { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .bin:hover, .bin.is-open { transform: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar, .status, .layout, .toolbar, .import-panel, .skip-link { display: none !important; }
  .print-sheet { display: block; padding: 16px; font-size: 12pt; }
  .print-sheet h1 { font-size: 18pt; margin-bottom: 8pt; }
  .print-sheet h2 { font-size: 13pt; margin: 12pt 0 4pt; border-bottom: 1px solid #000; }
  .print-sheet ul { margin: 0; padding-left: 18pt; }
}
