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

:root {
  --bg:        #f4f4f0;
  --surface:   #ffffff;
  --border:    #e2e2dc;
  --border2:   #d0d0c8;
  --text:      #1a1a18;
  --text2:     #5a5a54;
  --text3:     #9a9a92;
  --accent:    #1a1a18;
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08);
  --font:      'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --sidebar-w: 220px;

  /* BU */
  --beleaf:      #16a34a;
  --hihango:     #ea580c;
  --foodservice: #2563eb;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── LAYOUT ────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo .brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: #fff;
}

.sidebar-logo .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 12px 20px 4px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.07);
}

.nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: #fff;
}

.nav-link .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
}

.sidebar-footer .user-email {
  color: rgba(255,255,255,.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  margin-bottom: 8px;
}

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

.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.2px;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ─── CARDS ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ─── METRIC CARDS ──────────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.metric-label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.5px;
  line-height: 1;
  color: var(--text);
}

.metric-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
}

/* ─── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaf8; }

.td-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { background: var(--bg); border-color: var(--text3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.btn-primary:hover { background: #333; border-color: #333; }

.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,26,24,.08);
}

input::placeholder { color: var(--text3); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ─── TOGGLE ─────────────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 20px;
  transition: .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}

.toggle input:checked + .toggle-slider { background: #16a34a; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ─── SEARCH ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

/* ─── FILTER TABS ────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.filter-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
}

.filter-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ─── DRAWER ─────────────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0; right: -480px; bottom: 0;
  width: 480px;
  background: var(--surface);
  z-index: 201;
  box-shadow: -4px 0 20px rgba(0,0,0,.12);
  transition: right .25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open { right: 0; }

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

.drawer-title {
  font-size: 15px;
  font-weight: 600;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── UPLOAD ZONE ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--text2);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: #fafaf8;
}

.upload-zone .upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone .upload-title { font-size: 14px; font-weight: 600; color: var(--text); }
.upload-zone .upload-sub { font-size: 12px; margin-top: 4px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text2);
}

.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 999;
  transform: translateY(20px);
  opacity: 0;
  transition: all .25s;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }
.toast-warning { background: #d97706; }

/* ─── LOADING ─────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text3);
  gap: 8px;
  font-size: 13px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ─── OP CARD ─────────────────────────────────────────────────────────────── */
.op-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}

.op-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.op-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.op-sku {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text2);
  white-space: nowrap;
}

.op-name { font-size: 14px; font-weight: 600; flex: 1; }
.op-meta { font-size: 12px; color: var(--text2); display: flex; gap: 16px; flex-wrap: wrap; }

/* ─── BATCH PILL ──────────────────────────────────────────────────────────── */
.batch-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin: 2px;
}

.batch-arroz   { background: #dcfce7; color: #15803d; }
.batch-feijao  { background: #fef3c7; color: #92400e; }
.batch-frango  { background: #ffedd5; color: #c2410c; }
.batch-default { background: #f1f5f9; color: #475569; }

/* ─── LOGIN ───────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  margin-bottom: 28px;
}

.login-logo .brand { font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.login-logo .brand span { color: var(--hihango); }
.login-logo .brand-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ─── PRINT ───────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .page-header, .btn, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .print-only { display: block !important; }

  .op-print-block {
    page-break-after: always;
    border: 1px solid #000;
    padding: 16px;
    font-size: 12px;
  }

  .op-print-block:last-child { page-break-after: auto; }
}

.print-only { display: none; }

/* ─── UTILS ───────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-2 { color: var(--text2); }
.text-3 { color: var(--text3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.opacity-40 { opacity: .4; }

/* ─── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-220px); transition: transform .25s; }
  .sidebar.mobile-open { transform: translateX(0); width: 220px; }
  .main { margin-left: 0; }
  .page-body { padding: 16px; }
}

/* ─── GOOGLE FONTS ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
