:root {
  --bg: #0A0A0A;
  --surface: #000000;
  --ink: #FAFAFA;
  --text-sec: #A1A1AA;
  --line: #27272A;
  --line-focus: #52525B;
  --primary: #EDEDED;
  --primary-ink: #0A0A0A;
  --active: #FAFAFA;
  
  --success: #4ADE80;
  --pending: #FBBF24;
  --error: #F87171;
  --info: #60A5FA;
  
  --radius-sm: 4px;
  --radius-lg: 6px;
  --radius-full: 9999px;
  
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  
  --status-height: 28px;
  --nav-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Geist', sans-serif;
  background-color: #000;
  color: var(--ink);
  display: flex;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.semana-badge {
  font-size: 0.6rem;
  font-family: 'Geist Mono', monospace;
  background: rgba(251,191,36,0.12);
  color: var(--pending);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  letter-spacing: 0.04em;
  margin-left: 4px;
}

/* ── Status Bar ─────────────────────────────────────────────── */
.status-bar {
  height: var(--status-height);
  background-color: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sec);
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  cursor: pointer;
}
.status-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
}
.status-dot.success { background-color: var(--success); box-shadow: 0 0 4px var(--success); }
.status-dot.pending { background-color: var(--pending); box-shadow: 0 0 4px var(--pending); animation: blink 1s infinite; }
.status-dot.error   { background-color: var(--error);   box-shadow: 0 0 4px var(--error); }

@keyframes blink { 0%,100% { opacity:1 } 50% { opacity:0.3 } }

/* ── Views ──────────────────────────────────────────────────── */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.view.active { display: flex; }

.view-header {
  padding: var(--space-3) var(--space-3) 0;
  flex-shrink: 0;
}
.view-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--space-3);
}
.view-subtitle {
  font-size: 0.75rem;
  color: var(--text-sec);
  margin-top: -10px;
  margin-bottom: var(--space-3);
  font-family: 'Geist Mono', monospace;
}

.view-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  padding-bottom: calc(var(--nav-height) + var(--space-3));
  -webkit-overflow-scrolling: touch;
}
.view-content::-webkit-scrollbar { display: none; }

/* ── Bottom Nav ─────────────────────────────────────────────── */
.bottom-nav {
  height: var(--nav-height);
  background-color: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.625rem;
  font-family: 'Geist Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sec);
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn svg { width: 20px; height: 20px; stroke-width: 1.5; }
.nav-btn.active { color: var(--ink); }
.nav-btn.active svg { stroke: var(--ink); }

/* ── Item Row (tela de pedido) ──────────────────────────────── */
.item-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}
.item-row:last-child { border-bottom: none; }

.item-info { flex: 1; min-width: 0; }
.item-nome {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-meta {
  font-size: 0.6875rem;
  font-family: 'Geist Mono', monospace;
  color: var(--text-sec);
  margin-top: 2px;
}
.item-meta .need { color: var(--pending); }
.item-meta .ok   { color: var(--success); }

.item-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.item-input {
  width: 54px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: 'Geist Mono', monospace;
  font-size: 0.9375rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.item-input:focus { border-color: var(--line-focus); }
.item-input.changed { border-color: var(--pending); }
.item-input.ok      { border-color: var(--success); }

.item-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.item-badge.pedir { background: rgba(251,191,36,0.1); color: var(--pending); border: 1px solid rgba(251,191,36,0.2); }
.item-badge.ok    { background: rgba(74,222,128,0.1); color: var(--success); border: 1px solid rgba(74,222,128,0.2); }

/* ── Seção de pedido ────────────────────────────────────────── */
.section-label {
  font-size: 0.65rem;
  font-family: 'Geist Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-sec);
  margin-bottom: var(--space-2);
  margin-top: var(--space-3);
}
.section-label:first-child { margin-top: 0; }

/* ── Botões ─────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); width: 100%; }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger  { background: transparent; color: var(--error); border: 1px solid rgba(248,113,113,0.3); }
.btn-sm { height: 32px; font-size: 0.75rem; padding: 0 var(--space-2); }

/* ── Pedido gerado (resumo) ─────────────────────────────────── */
.pedido-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.pedido-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}
.pedido-titulo { font-size: 0.8125rem; font-weight: 600; }
.pedido-data   { font-size: 0.6875rem; font-family: 'Geist Mono', monospace; color: var(--text-sec); }
.pedido-linha  { font-size: 0.8125rem; color: var(--ink); padding: 3px 0; display: flex; justify-content: space-between; align-items: center; }
.pedido-linha .qtd { font-family: 'Geist Mono', monospace; color: var(--pending); font-weight: 600; }

/* ── Config item row ────────────────────────────────────────── */
.cfg-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}
.cfg-row:last-child { border-bottom: none; }
.cfg-nome { flex: 1; min-width: 0; }
.cfg-nome-text { font-size: 0.875rem; color: var(--ink); }
.cfg-unit { font-size: 0.6875rem; color: var(--text-sec); font-family: 'Geist Mono', monospace; }
.cfg-input {
  width: 54px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: 'Geist Mono', monospace;
  font-size: 0.9rem;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
}
.cfg-input:focus { border-color: var(--line-focus); }
.cfg-del {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sec);
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: none; background: none;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cfg-del:active { color: var(--error); }

/* ── Add item form ──────────────────────────────────────────── */
.add-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin-top: var(--space-3);
}
.form-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-2); }
.form-row:last-child { margin-bottom: 0; }
.form-input {
  flex: 1;
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: 'Geist', sans-serif;
  font-size: 0.875rem;
  padding: 0 var(--space-2);
  outline: none;
}
.form-input:focus { border-color: var(--line-focus); }
.form-input::placeholder { color: var(--text-sec); }
.form-input.sm { width: 70px; flex: none; }

/* ── Histórico entries ──────────────────────────────────────── */
.hist-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
  overflow: hidden;
}
.hist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hist-date { font-size: 0.8125rem; font-weight: 500; }
.hist-count { font-size: 0.6875rem; font-family: 'Geist Mono', monospace; color: var(--text-sec); }
.hist-body { padding: 0 var(--space-3) var(--space-2); display: none; }
.hist-body.open { display: block; }
.hist-item-line { font-size: 0.8125rem; padding: 2px 0; display: flex; justify-content: space-between; }
.hist-item-line .qtd { font-family: 'Geist Mono', monospace; color: var(--pending); }

/* ── Empty / Loading ────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) 0;
  color: var(--text-sec);
  font-size: 0.875rem;
}
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--line-focus) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Modal ──────────────────────────────────────────────────── */
#modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: var(--space-4);
}
#modal-box {
  background: #18181B;
  border: 1px solid var(--line-focus);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  width: 100%;
  max-width: 320px;
}
#modal-msg { font-size: 0.9375rem; margin-bottom: var(--space-3); line-height: 1.5; }
.modal-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: absolute;
  bottom: calc(var(--nav-height) + var(--space-3));
  left: var(--space-3); right: var(--space-3);
  background: #27272A;
  border: 1px solid var(--line-focus);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  font-size: 0.8125rem;
  text-align: center;
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { border-color: rgba(74,222,128,0.3); color: var(--success); }
#toast.error   { border-color: rgba(248,113,113,0.3); color: var(--error); }

/* ── Resumo bar ─────────────────────────────────────────────── */
.resumo-bar {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  font-size: 0.75rem;
  font-family: 'Geist Mono', monospace;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.resumo-bar .hl { color: var(--pending); font-weight: 600; }
.resumo-bar .ok { color: var(--success); }

/* ── Loading view ───────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-3);
  color: var(--text-sec);
  font-size: 0.8125rem;
  font-family: 'Geist Mono', monospace;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
