:root {
  --bg:        #f9f6f0;
  --surface:   #ffffff;
  --surface2:  #f4f0e8;
  --border:    #e0d8cc;
  --accent:    #534340;
  --accent2:   #bb9981;
  --danger:    #a0493a;
  --success:   #5a7a4a;
  --warn:      #c47c2e;
  --text:      #2e2420;
  --muted:     #8a7a6e;
  --green:     #c5d8a4;
  --cream:     #f4fcd9;
  --sidebar-w: 240px;
  --font-head: 'Playfair Display', serif;
  --font-body: 'Lato', sans-serif;
  --font-mono: 'Lato', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
#sidebar {
  width: var(--sidebar-w);
  background: var(--accent);
  border-right: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.logo-icon { font-size: 22px; display: flex; align-items: center; }
.logo-text {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: #f4fcd9;
  line-height: 1.3;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 12px 0;
}
.nav-links li { position: relative; }
.nav-links a {
  display: block;
  padding: 10px 20px;
  color: rgba(244,252,217,0.7);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: #f4fcd9; background: rgba(255,255,255,0.08); }
.nav-links a.active {
  color: #f4fcd9;
  background: rgba(255,255,255,0.12);
  border-left: 3px solid #c5d8a4;
}
.nav-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 8px; }

/* ---- MAIN CONTENT ---- */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ---- CARDS / STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.stat-value {
  font-family: 'Roboto Slab', serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- TABLE ---- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); background: var(--surface2); }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-pending       { background: #f4e8cc; color: #8a5c20; }
.badge-in_production { background: #dcebd4; color: #3d6030; }
.badge-ready_to_ship { background: #d4eaf7; color: #1a5c8a; }
.badge-shipped       { background: #e8e8e8; color: #555; }
.badge-cancelled     { background: #f0d5d0; color: var(--danger); }
.badge-low        { background: #f5e0c0; color: var(--warn); }
.badge-ok         { background: #dcebd4; color: var(--success); }
.badge-stage      { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: var(--accent); color: #f4fcd9; font-weight: 700; }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface2); }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---- MODAL ---- */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
#modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer;
}
#modal-close:hover { color: var(--text); }
.modal-title {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ---- TOAST ---- */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 12px 20px;
  font-size: 13px;
  z-index: 2000;
  animation: slideIn 0.2s ease;
}
#toast.hidden { display: none; }
#toast.error { border-left-color: var(--danger); }
#toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- MISC ---- */
.section-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
  margin-top: 24px;
}
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}
.actions-cell { display: flex; gap: 6px; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

/* Barcode scanner input highlight */
input.barcode-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(83,67,64,0.15);
}