
/* ── Reset & Root ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f5f0;
  --surface:   #ffffff;
  --raised:    #eef0ea;
  --border:    #dde0d8;
  --border2:   #c8ccbf;
  --text:      #1e2218;
  --dim:       #7d8578;
  --green:     #2d7a00;
  --green-dim: #3d9600;
  --green-glow:rgba(45,122,0,.08);
  --amber:     #a06000;
  --red:       #c0001a;
  --mono:      ui-monospace, 'Cascadia Code', 'Fira Mono', 'Consolas', 'Menlo', monospace;
  --cond:      'Arial Narrow', 'Liberation Sans Narrow', Impact, 'Franklin Gothic Medium', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

/* scanline overlay removed for light theme */

/* ── Layout ───────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100%; }

/* ── Header ───────────────────────────────────────────── */
header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  position: relative;
}

header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--green);
}

.wordmark {
  font-family: var(--cond);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .12em;
  color: var(--green);
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}

.wordmark span {
  color: var(--dim);
  font-weight: 400;
  font-size: 14px;
  margin-left: 4px;
  letter-spacing: .05em;
}

.header-ticker {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: .06em;
  display: flex;
  gap: 20px;
}

.ticker-item { display: flex; align-items: center; gap: 6px; }
.ticker-item strong { color: var(--text); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border2);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
}

.status-pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dim);
  transition: background .3s, box-shadow .3s;
}
.status-pip.online  { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-pip.offline { background: var(--red); }

/* ── Body ─────────────────────────────────────────────── */
.body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────── */
aside {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-label {
  font-family: var(--cond);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
}

#item-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}

#item-list::-webkit-scrollbar { width: 3px; }
#item-list::-webkit-scrollbar-thumb { background: var(--border2); }

.item-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  padding: 7px 8px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .1s, border-color .1s;
}

.item-entry:hover   { background: var(--raised); }
.item-entry.active  { background: var(--green-glow); border-left-color: var(--green); }
.item-entry.active .ie-name { color: var(--green); }

.ie-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  transition: color .1s;
}

.ie-badge {
  font-size: 10px;
  color: var(--dim);
  background: var(--border);
  padding: 1px 5px;
  white-space: nowrap;
}

.ie-total {
  grid-column: 1 / -1;
  font-size: 10px;
  color: var(--dim);
  margin-top: 2px;
}

.ie-total strong { color: var(--green-dim); }

.no-items {
  padding: 20px 12px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.9;
  text-align: center;
}

/* ── Main panel ───────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.main::-webkit-scrollbar { width: 4px; }
.main::-webkit-scrollbar-thumb { background: var(--border2); }

/* ── Welcome ──────────────────────────────────────────── */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 40px;
}

.bigmark {
  font-family: var(--cond);
  font-size: 96px;
  font-weight: 900;
  color: var(--border);
  line-height: 1;
  letter-spacing: -.02em;
  user-select: none;
}

.welcome-screen p {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--dim);
  text-transform: uppercase;
}

/* ── Detail ───────────────────────────────────────────── */
.detail { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.det-label {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}

.det-name {
  font-family: var(--cond);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}

.det-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--dim);
}

.det-meta strong { color: var(--green); font-weight: 500; }

.detail-controls { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Panel ────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
}

.panel > .panel-header { background: var(--raised); }
.panel-body { padding: 14px; }

/* ── Stock table ──────────────────────────────────────── */
.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stock-table th {
  text-align: left;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
  padding: 0 12px 8px;
  font-family: var(--cond);
}

.stock-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}

.stock-table tbody tr { transition: background .08s; }
.stock-table tbody tr:hover { background: var(--raised); }

.td-loc  { color: var(--text); font-weight: 500; }
.td-qty  { color: var(--green); font-weight: 600; font-size: 13px; }
.td-unit { color: var(--dim); font-size: 10px; }
.td-acts { text-align: right; white-space: nowrap; }

.row-btns { opacity: 0; transition: opacity .1s; display: inline-flex; gap: 4px; }
.stock-table tbody tr:hover .row-btns { opacity: 1; }

.no-stock-row td {
  padding: 24px 12px;
  text-align: center;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: .06em;
}

/* ── Move form ────────────────────────────────────────── */
.move-form {
  display: grid;
  grid-template-columns: 1fr 1fr 120px auto;
  gap: 10px;
  align-items: end;
}

/* ── Fields ───────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  font-family: var(--cond);
  font-weight: 700;
}

input, select {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 9px;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  border-radius: 0;
  -webkit-appearance: none;
}

input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-glow);
}

input::placeholder { color: var(--dim); }
input[readonly]    { opacity: .5; cursor: not-allowed; }

select option { background: #141714; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  font-family: var(--cond);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 7px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .1s, color .1s, border-color .1s;
  user-select: none;
  border-radius: 0;
}

.btn:active { opacity: .75; }

.btn-green   { background: var(--green); color: #0a0c0a; border-color: var(--green); }
.btn-green:hover { background: #96ed00; border-color: #96ed00; }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border2); }
.btn-outline:hover { background: var(--raised); border-color: var(--dim); }

.btn-ghost   { background: transparent; color: var(--dim); padding: 4px 8px; font-size: 11px; }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); border: 1px solid var(--border2); }

.btn-red     { background: transparent; color: var(--red); border-color: rgba(255,62,62,.3); }
.btn-red:hover { background: rgba(255,62,62,.1); }

.btn-amber   { background: transparent; color: var(--amber); border-color: rgba(255,184,0,.3); }
.btn-amber:hover { background: rgba(255,184,0,.1); }

.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.78);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in .12s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--green);
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,.85);
  animation: modal-in .15s ease;
}

@keyframes modal-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-title {
  font-family: var(--cond);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title::before {
  content: '';
  display: block;
  width: 4px; height: 18px;
  background: var(--green);
  flex-shrink: 0;
}

.modal-form { display: flex; flex-direction: column; gap: 12px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── Toasts ───────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--raised);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--green);
  padding: 9px 14px;
  font-size: 11px;
  color: var(--text);
  max-width: 300px;
  animation: t-in .18s ease forwards, t-out .2s 2.8s ease forwards;
}

.toast.err  { border-left-color: var(--red);   }
.toast.warn { border-left-color: var(--amber); }

@keyframes t-in  { from { opacity:0; transform:translateX(12px); } to { opacity:1; transform:translateX(0); } }
@keyframes t-out { to   { opacity:0; transform:translateX(12px); } }

/* ── Spinner ──────────────────────────────────────────── */
.spin {
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid var(--border2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .5s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Voice button ─────────────────────────────────────── */
.btn-voice {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
.btn-voice:hover { background: var(--raised); color: var(--text); }
.btn-voice.listening {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(192,0,26,.18);
  animation: mic-pulse 1s ease-in-out infinite;
}
.btn-voice.unsupported { opacity: .35; cursor: not-allowed; }

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(192,0,26,.18); }
  50%       { box-shadow: 0 0 0 7px rgba(192,0,26,.08); }
}

/* ── Voice overlay ────────────────────────────────────── */
#voice-overlay {
  position: fixed; inset: 0;
  background: rgba(244,245,240,.92);
  backdrop-filter: blur(4px);
  z-index: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: fade-in .15s ease;
}

.voice-ring {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 28px;
  animation: mic-pulse 1s ease-in-out infinite;
  cursor: pointer;
  user-select: none;
}

.voice-transcript {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  min-height: 24px;
  text-align: center;
  max-width: 320px;
  padding: 0 20px;
}

.voice-hint {
  font-size: 11px;
  color: var(--dim);
  text-align: center;
  max-width: 300px;
  line-height: 1.7;
  padding: 0 20px;
}

.voice-hint strong { color: var(--text); }


/* ══════════════════════════════════════════════════════════
   MOBILE  (≤ 640 px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* Hide desktop elements */
  .header-ticker  { display: none; }
  .header-right > .btn-outline { display: none; } /* sign-out moved to mobile nav */
  aside           { display: none; }               /* replaced by mobile catalog tab */

  header {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    height: 48px;
  }

  .wordmark { font-size: 18px; }

  /* Body fills all remaining height above the bottom nav */
  .body { flex-direction: column; }

  .main { flex: 1; overflow-y: auto; }

  /* ── Bottom nav bar ──────────────────────────────────── */
  #mobile-nav {
    display: flex;
    flex-shrink: 0;
    height: 56px;
    background: var(--surface);
    border-top: 1px solid var(--border2);
    z-index: 100;
  }

  .mnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--dim);
    font-family: var(--cond);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 0;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }

  .mnav-btn svg { width: 20px; height: 20px; }

  .mnav-btn.active { color: var(--green); }
  .mnav-btn.active svg { stroke: var(--green); }

  /* ── Mobile catalog panel ────────────────────────────── */
  #mobile-catalog {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
  }

  #mobile-catalog.visible { display: flex; }

  #mobile-catalog .panel-header {
    padding: 12px 16px;
    background: var(--raised);
    border-bottom: 1px solid var(--border2);
  }

  #mobile-catalog #item-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
  }

  #mobile-catalog .item-entry {
    padding: 12px 16px;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }

  #mobile-catalog .item-entry.active {
    background: var(--green-glow);
    border-left: 3px solid var(--green);
  }

  .ie-name  { font-size: 14px; }
  .ie-badge { font-size: 11px; padding: 2px 7px; }

  /* ── Main panel (detail tab) ─────────────────────────── */
  .main.mobile-hidden { display: none; }
  .main.mobile-visible { display: flex; }

  .detail { padding: 16px; gap: 16px; }

  .det-name { font-size: 28px; }

  .detail-head { flex-direction: column; gap: 12px; }
  .detail-controls { width: 100%; justify-content: flex-end; }

  /* ── Stock table mobile ───────────────────────────────── */
  .stock-table th, .stock-table td { padding: 10px 10px; }
  .row-btns { opacity: 1; }  /* always visible on touch */

  /* ── Move form stacks vertically ─────────────────────── */
  .move-form {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .move-form > *:last-child {
    grid-column: 1 / -1;
  }

  /* ── Modals full-screen on mobile ────────────────────── */
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    margin: 0;
    border-radius: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: slide-up .2s ease;
  }

  @keyframes slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  .modal-overlay { align-items: flex-end; }

  /* ── FAB for new item ────────────────────────────────── */
  #mobile-fab {
    display: flex;
    position: fixed;
    bottom: 68px;
    right: 16px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--green);
    color: #0a0c0a;
    border: none;
    font-size: 26px;
    font-weight: 300;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0,0,0,.18);
    cursor: pointer;
    z-index: 200;
    transition: background .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
  }

  #mobile-fab:active { background: #96ed00; }

  /* Hide desktop + NEW ITEM button */
  header .btn-green { display: none; }

  /* ── Toasts wider on mobile ──────────────────────────── */
  #toasts { left: 12px; right: 12px; bottom: 68px; }
  .toast  { font-size: 12px; padding: 10px 14px; }

  /* ── Voice overlay hint smaller ──────────────────────── */
  .voice-hint { font-size: 10px; }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 641px) {
  #mobile-nav          { display: none; }
  #mobile-catalog      { display: none; }
  #mobile-locs-catalog { display: none; }
  #mobile-fab          { display: none; }
}


/* ── Sidebar view toggle ──────────────────────────────── */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 4px;
  font-family: var(--cond);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.sidebar-tab:hover { color: var(--text); }
.sidebar-tab.active { color: var(--green); border-bottom-color: var(--green); }

/* ── Location entry in sidebar ────────────────────────── */
.loc-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  padding: 7px 8px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .1s, border-color .1s;
}
.loc-entry:hover  { background: var(--raised); }
.loc-entry.active { background: var(--green-glow); border-left-color: var(--green); }
.loc-entry.active .le-name { color: var(--green); }

.le-name  { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.le-count { font-size: 10px; color: var(--dim); background: var(--border); padding: 1px 5px; white-space: nowrap; }
.le-total { grid-column: 1 / -1; font-size: 10px; color: var(--dim); margin-top: 2px; }
.le-total strong { color: var(--green-dim); }

/* ── Location detail panel ────────────────────────────── */
.det-loc-name {
  font-family: var(--cond);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}

@media (max-width: 640px) {
  .det-loc-name { font-size: 28px; }
  #mnav-locs.active { color: var(--green); }
  #mnav-locs.active svg { stroke: var(--green); }
  #mobile-locs-catalog { display: none; flex-direction: column; flex: 1; overflow: hidden; }
  #mobile-locs-catalog.visible { display: flex; }
  #mobile-locs-catalog .panel-header { padding: 12px 16px; background: var(--raised); border-bottom: 1px solid var(--border2); }
  #mobile-locs-catalog #loc-list-mobile { flex: 1; overflow-y: auto; padding: 4px 0; }
  #mobile-locs-catalog .loc-entry { padding: 12px 16px; border-left: none; border-bottom: 1px solid var(--border); }
  #mobile-locs-catalog .loc-entry.active { background: var(--green-glow); border-left: 3px solid var(--green); }
}

