/* app.css — Stock'd shell + components, matching the ordering app's look. */

/* ---- shell ---- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--bg2), #0a0710);
  border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin: 6px 8px 14px; color: var(--text); }
.brand .falogo {
  width: 42px; height: 42px; flex: none; object-fit: contain;
  filter: drop-shadow(0 0 7px rgba(147, 51, 234, .5));
  animation: faGlow 2.8s ease-in-out infinite;
}
.brand .wm { display: inline-flex; flex-direction: column; line-height: 1.04; letter-spacing: .01em; font-size: 16px; }
.brand .wm small { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .03em; margin-top: 1px; }

.syncpill {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 12px;
  padding: 4px 11px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; width: fit-content;
}
.syncpill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
body.offline .syncpill .dot { background: var(--red); }

.nav {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 11px; color: var(--muted); font-weight: 600; cursor: pointer;
}
.nav:hover { background: var(--panel); }
.nav.active { background: var(--panel2); color: var(--text); }
.nav .ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.nav .ic svg { width: 19px; height: 19px; display: block; }
.nav.active .ic { color: var(--accent); }
.navbadge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 800;
  border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.side .spacer { flex: 1; }
.side .me { padding: 8px; font-size: 13px; }
.side .me b { display: block; font-size: 13.5px; }
.side .me span { color: var(--muted); font-size: 11.5px; }
.side .me button { margin-top: 6px; }

.main { padding: 26px 30px; animation: slideup .35s ease; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.h1 { font-size: 24px; font-weight: 800; margin: 0; }
.sub { color: var(--muted); font-size: 13px; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); animation: pop .3s ease;
}
.tile .n { font-size: 30px; font-weight: 800; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile.hot .n { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tile.low .n { color: var(--amber); }
.tile.dead .n { color: var(--muted); }
.tile.go .n { color: var(--green); }
.tile.bad .n { color: var(--red); }
.tile.new .n { color: var(--new); }
.tile.click { cursor: pointer; }
.tile.click:hover { border-color: var(--accent); }

/* ---- cards / sections ---- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px;
}
.card .cardhead {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card .cardhead h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
.card .cardbody { padding: 14px 16px; }
.sectiontitle { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin: 22px 0 10px; }

/* ---- tables ---- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel);
}
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.rowlink { cursor: pointer; }
table.list tr.rowlink:hover td { background: var(--panel2); }
.tablescroll { max-height: 62vh; overflow: auto; }

/* ---- chips / pills ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .14s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.chip:hover { transform: translateY(-1px); border-color: var(--accent); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.pill.expected { background: rgba(157, 147, 181, .14); color: var(--muted); }
.pill.received { background: rgba(26, 143, 196, .16); color: #6cc4ea; }
.pill.matching { background: rgba(167, 139, 250, .16); color: var(--new); }
.pill.awaiting_signoff { background: rgba(192, 132, 252, .16); color: var(--accent); }
.pill.on_hold { background: rgba(251, 146, 60, .16); color: var(--hold); }
.pill.crating { background: rgba(224, 179, 255, .14); color: var(--accent2); }
.pill.shipped { background: rgba(45, 212, 168, .14); color: var(--green); }
.pill.closed { background: rgba(157, 147, 181, .14); color: var(--muted); }
.pill.open { background: rgba(255, 92, 116, .15); color: var(--red); }
.pill.investigating { background: rgba(251, 191, 36, .15); color: var(--amber); }
.pill.resolved { background: rgba(45, 212, 168, .14); color: var(--green); }
.pill.ok { background: rgba(45, 212, 168, .14); color: var(--green); }
.pill.warn { background: rgba(251, 191, 36, .15); color: var(--amber); }
.pill.bad { background: rgba(255, 92, 116, .15); color: var(--red); }
.pill.grey { background: rgba(157, 147, 181, .14); color: var(--muted); }

/* ---- forms / dialogs / toast ---- */
.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: block; margin-bottom: 12px; min-width: 0; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; width: min(480px, 94vw); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(3, 2, 6, .7); }
dialog h2 { margin: 0 0 14px; font-size: 16px; font-weight: 800; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); padding: 12px 18px;
  border-radius: 12px; box-shadow: var(--shadow); animation: pop .25s; z-index: 50; max-width: 90vw;
}
.toast.bad { border-color: var(--red); }

.otp {
  font-family: var(--mono); font-size: 17px; background: var(--bg2);
  border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; text-align: center; letter-spacing: .06em; margin: 10px 0;
}

.placeholder {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.placeholder b { display: block; color: var(--text); margin-bottom: 4px; }

/* ---- variance colouring ---- */
.var-zero { color: var(--muted); }
.var-plus { color: var(--amber); font-weight: 700; }
.var-minus { color: var(--red); font-weight: 700; }

/* ---- gates checklist ---- */
.gate { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; }
.gate.done { opacity: .6; }
.gate .glabel { flex: 1; font-weight: 600; }
.gate .gmeta { font-size: 11.5px; color: var(--muted); }

/* ---- journal ---- */
.journal-narrative { font-size: 15.5px; line-height: 1.75; max-width: 74ch; }
.journal-narrative p { margin: 0 0 14px; }
.journal-heading { font-size: 20px; font-weight: 800; margin: 0 0 2px; }
.daychips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 18px; }

/* ---- stat bars (dashboard, FA style) ---- */
.hbar { display: grid; grid-template-columns: 220px 1fr 90px; align-items: center; gap: 12px; padding: 7px 0; font-size: 13.5px; }
.hbar .track { height: 12px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--new); }
.hbar b { text-align: right; font-family: var(--mono); }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: min(400px, 94vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 30px 28px; box-shadow: var(--shadow); animation: pop .3s ease;
}
.remember { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; font-size: 13.5px; color: var(--muted); }
.remember input { width: auto; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .side .nav { padding: 8px 10px; }
  .brand { margin: 0 8px 0 0; }
  .syncpill, .side .me span { display: none; }
  .main { padding: 18px 14px; }
  .hbar { grid-template-columns: 130px 1fr 80px; }
}
