/* styles.css — Aladdin Time Control. Big + high-contrast (Boss vision rule). */
:root {
  --orange: #E75100;
  --cream: #f7f2ea;
  --card: #fffaf2;
  --dark: #2f2117;
  --green: #1f9d55;
  --yellow: #f0a500;
  --red: #d8432e;
  --muted: #7a6a58;
  --radius: 14px;
  --shadow: 0 4px 14px rgba(47, 33, 23, 0.12);
  font-size: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--cream);
  color: var(--dark);
  -webkit-text-size-adjust: 100%;
}

/* ---------- Header ---------- */
header.app-bar {
  background: var(--orange);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-bar h1 { font-size: 1.45rem; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.app-bar .scope { font-size: 0.95rem; opacity: 0.95; }
.app-bar select {
  font-size: 1rem; padding: 6px 8px; border-radius: 8px; border: none; background: #fff; color: var(--dark);
}

/* ---------- Stats strip ---------- */
.stats { display: flex; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 16px; min-width: 92px; text-align: center;
}
.stat .n { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.stat .l { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat.alert { background: var(--red); color: #fff; }
.stat.alert .l { color: #ffe; }

/* ---------- Action banner (alarms 5.2) ---------- */
#banner {
  display: none; background: var(--red); color: #fff; padding: 14px 18px;
  font-size: 1.15rem; font-weight: 700; position: sticky; top: 56px; z-index: 15;
}
#banner.show { display: block; }
#banner.flash { animation: flash 1s steps(2, start) infinite; }
@keyframes flash { 50% { background: #a02d1d; } }

/* ---------- Buttons ---------- */
button {
  font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
  border: none; border-radius: 10px; padding: 12px 16px; background: var(--orange); color: #fff;
  min-height: 44px;
}
button.secondary { background: #fff; color: var(--dark); border: 2px solid var(--dark); }
button.ghost { background: transparent; color: var(--dark); border: 2px solid var(--muted); }
button:active { transform: translateY(1px); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.primary-actions { padding: 4px 16px 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.primary-actions button { flex: 1 1 auto; font-size: 1.1rem; padding: 16px; }

/* ---------- Pan cards ---------- */
#cards { padding: 0 16px 28px; display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { #cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1180px) { #cards { grid-template-columns: 1fr 1fr 1fr; } }

.pan {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 12px solid var(--green); padding: 16px; position: relative;
}
.pan.yellow { border-left-color: var(--yellow); }
.pan.red { border-left-color: var(--red); }
.pan.red.flash { animation: cardflash 1s steps(2, start) infinite; }
@keyframes cardflash { 50% { background: #ffe3dd; } }

.pan .item { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px; }
.pan .meta { font-size: 0.92rem; color: var(--muted); margin-bottom: 10px; }
.pan .countdown { font-size: 2.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pan .status-word {
  display: inline-block; font-size: 0.95rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 4px 10px; border-radius: 999px; margin-top: 8px; color: #fff;
}
.status-word.safe { background: var(--green); }
.status-word.warn { background: var(--yellow); color: #3a2c00; }
.status-word.now { background: var(--red); }
.pan .times { font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.pan .card-actions { margin-top: 14px; }
.pan .nontcs { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.badge-exempt { background: var(--muted); color:#fff; padding:2px 8px; border-radius:999px; font-size:0.75rem; }

/* ---------- Line Mode (5.9) ---------- */
body.line-mode { font-size: 21px; }
body.line-mode .pan .item { font-size: 2rem; }
body.line-mode .pan .countdown { font-size: 3.4rem; }
body.line-mode .stats, body.line-mode .pan .times, body.line-mode .pan .meta { display: none; }

/* ---------- Dialogs ---------- */
dialog {
  border: none; border-radius: 16px; padding: 0; max-width: 560px; width: 92vw;
  box-shadow: 0 12px 50px rgba(0,0,0,0.35);
}
dialog::backdrop { background: rgba(47,33,23,0.55); }
.dlg-head { background: var(--orange); color: #fff; padding: 16px 20px; font-size: 1.25rem; font-weight: 800; }
.dlg-body { padding: 20px; display: grid; gap: 14px; }
.dlg-foot { padding: 14px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid #eee; }
label.field { display: grid; gap: 5px; font-weight: 700; font-size: 0.95rem; }
input, select, textarea {
  font-family: inherit; font-size: 1.1rem; padding: 12px; border: 2px solid #d8ccba;
  border-radius: 10px; background: #fff; color: var(--dark);
}
textarea { min-height: 120px; }
.warn-temp { color: var(--red); font-weight: 800; font-size: 0.95rem; }

/* ---------- Inspector mode + SOP (5.5) ---------- */
.sop-panel {
  background: #fff; border: 2px solid var(--orange); border-radius: var(--radius);
  padding: 16px; margin: 16px; white-space: pre-wrap; font-size: 0.95rem; line-height: 1.45;
}
.sop-panel h2 { margin: 0 0 8px; color: var(--orange); }
.log-controls { padding: 0 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
table.log { width: calc(100% - 32px); margin: 12px 16px 30px; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.log th, table.log td { padding: 9px 10px; text-align: left; font-size: 0.85rem; border-bottom: 1px solid #eee; }
table.log th { background: var(--dark); color: #fff; }
tr.open-item { background: #ffe3dd; font-weight: 700; }
.pill { padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; color: #fff; }
.pill.STARTED { background: var(--green); }
.pill.REPLACED { background: var(--orange); }
.pill.DISCARDED { background: var(--red); }
.pill.SERVED { background: var(--muted); }
.pill.PAST_LIMIT { background: #6b1108; }

.hidden { display: none !important; }

/* ---------- Print label (5.1) ----------
   Configured for: Brother QL-820NWB + DK-2205 continuous 62mm roll.
   Label area = 62mm wide x 40mm tall per sticker. */
#label-print { display: none; }
@media print {
  @page { size: 62mm 40mm; margin: 0; }
  body * { visibility: hidden; }
  #label-print, #label-print * { visibility: visible; }
  #label-print {
    display: block; position: absolute; top: 0; left: 0; width: 62mm; height: 40mm;
    padding: 2mm 2.5mm; color: #000; font-family: system-ui, sans-serif; overflow: hidden;
  }
  #label-print .li-item { font-size: 13pt; font-weight: 800; margin-bottom: 2pt; line-height: 1.05; }
  #label-print .li-row { font-size: 9.5pt; margin: 1pt 0; }
  #label-print .li-discard { font-size: 13pt; font-weight: 800; border: 1.5pt solid #000; padding: 2pt 3pt; margin: 2pt 0; }
  #label-print .li-small { font-size: 6.5pt; line-height: 1.15; }
}
