/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg:        #0f1117;
  --surface:   #181c27;
  --surface2:  #1f2437;
  --border:    #2a2f45;
  --accent:    #4f7cff;
  --accent-h:  #3a65e8;
  --danger:    #e8455a;
  --warning:   #f5a623;
  --success:   #3ecf8e;
  --text:      #e8eaf0;
  --text-2:    #8a93b0;
  --text-3:    #555e7a;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Inter', sans-serif;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w: 220px;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.sidebar__icon {
  font-size: 1.4rem;
  color: var(--accent);
}

.sidebar__name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(79,124,255,0.15); color: var(--accent); }

.nav-item__icon { font-size: 1rem; }

.sidebar__footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.78rem;
  font-family: var(--mono);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 9;
}

.topbar__title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-box input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  width: 220px;
  outline: none;
  font-size: 0.88rem;
  transition: border-color 0.15s;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box input:focus { border-color: var(--accent); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }

.btn--primary  { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-h); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--surface2); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #c93349; }

.btn--icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn--icon:hover { color: var(--text); background: var(--surface2); }
.btn--icon.baixa:hover, .baixa-btn:hover { color: var(--success); border-color: var(--success); }
.btn--icon[disabled] { opacity: 0.35; cursor: not-allowed; }
.btn--icon.del:hover { color: var(--danger); border-color: var(--danger); }

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; padding: 2rem; }
.view.active { display: block; }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.stat-card--warning { border-color: rgba(245,166,35,0.35); }

.stat-card__label {
  font-size: 0.78rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.stat-card__value {
  font-size: 1.9rem;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-card--warning .stat-card__value { color: var(--warning); }

/* ============================================================
   SECTION TITLES
   ============================================================ */
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* ============================================================
   LOW STOCK LIST
   ============================================================ */
.low-stock-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.low-stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245,166,35,0.08);
  border: 1px solid rgba(245,166,35,0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.low-stock-item__name { font-weight: 600; }
.low-stock-item__qty {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--warning);
  font-weight: 600;
}

/* ============================================================
   RECENT LIST
   ============================================================ */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.recent-item__name { font-weight: 500; }
.recent-item__cat  { color: var(--text-3); font-size: 0.8rem; }
.recent-item__price { font-family: var(--mono); color: var(--success); font-size: 0.85rem; }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.select:focus { border-color: var(--accent); }
.select option { background: var(--surface2); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  font-weight: 700;
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }

.td-mono { font-family: var(--mono); font-size: 0.82rem; }
.td-name { font-weight: 600; }
.td-actions { display: flex; gap: 0.4rem; }

/* STATUS BADGE */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge--ok      { background: rgba(62,207,142,0.12); color: var(--success); }
.badge--low     { background: rgba(245,166,35,0.12); color: var(--warning); }
.badge--out     { background: rgba(232,69,90,0.12);  color: var(--danger);  }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-3);
  font-size: 0.9rem;
}

.hidden { display: none !important; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease;
}

.modal--sm { max-width: 360px; }

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

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal__title { font-size: 1rem; font-weight: 700; }

.modal__close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
  transition: color 0.15s;
}
.modal__close:hover { color: var(--text); }

.modal__body  { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* FORM */
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-input::placeholder { color: var(--text-3); }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,124,255,0.15);
}
.form-input.error { border-color: var(--danger); }

.form-textarea { resize: vertical; min-height: 70px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toast-in 0.2s ease;
}

.toast--success { border-color: var(--success); color: var(--success); }
.toast--error   { border-color: var(--danger);  color: var(--danger);  }

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

/* ============================================================
   MOVIMENTAÇÃO
   ============================================================ */
.modal--move { max-width: 560px; }

.move-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}

.move-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 0.5rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  font-family: var(--sans);
}
.move-tab:hover  { color: var(--text); }
.move-tab.active { background: var(--surface); color: var(--text); }

.move-panel { display: none; flex-direction: column; gap: 1rem; }
.move-panel.active { display: flex; }

.move-stock-info {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: var(--text-2);
}
.move-stock-info strong { color: var(--text); font-family: var(--mono); }

.btn--success      { background: var(--success); color: #0a2a1e; }
.btn--success:hover { background: #2fb87a; }
.btn--full { width: 100%; justify-content: center; padding: 0.65rem; font-size: 0.95rem; }

/* HISTÓRICO */
.historico-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
}

.historico-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.83rem;
}

.historico-item__tipo {
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tipo--entrada { background: rgba(62,207,142,0.12); color: var(--success); }
.tipo--saida   { background: rgba(232,69,90,0.12);  color: var(--danger);  }

.historico-item__info { display: flex; flex-direction: column; gap: 0.15rem; }
.historico-item__nota { color: var(--text-2); font-size: 0.78rem; }
.historico-item__qty  { font-family: var(--mono); font-weight: 700; font-size: 0.9rem; }

.qty--entrada { color: var(--success); }
.qty--saida   { color: var(--danger);  }
