/* ═══════════════════════════════════════════════════════════════════
   CEDAR COFFEE — Design System
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --espresso:  #1C1410;
  --espresso2: #2D2018;
  --parchment: #F5EDD8;
  --parchment2:#EDE0C4;
  --olive:     #4A5C3A;
  --olive-lt:  #6B7F58;
  --amber:     #C47D2E;
  --amber-lt:  #D99B52;
  --slate:     #8B9EA8;
  --slate-lt:  #B8C8D0;
  --white:     #FFFFFF;
  --danger:    #C0392B;
  --success:   #2E7D52;
  --card-bg:   #FFFFFF;
  --page-bg:   #F0E8D4;
  --border:    rgba(28,20,16,0.10);
  --border-md: rgba(28,20,16,0.18);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(28,20,16,0.08);
  --shadow-md: 0 4px 16px rgba(28,20,16,0.12);
  --topbar-h: 56px;
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--page-bg);
  color: var(--espresso);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── LOGIN ──────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--espresso);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-icon {
  font-size: 36px;
  color: var(--amber);
  display: block;
  margin-bottom: 10px;
}
.login-brand h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: var(--espresso);
}
.login-brand p {
  font-size: 12px;
  color: var(--slate);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-error {
  background: rgba(192,57,43,0.08);
  border: 1px solid rgba(192,57,43,0.2);
  color: var(--danger);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11px;
  color: var(--slate);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── TOPBAR ─────────────────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--espresso);
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topbar-inner {
  display: flex; align-items: center;
  height: 100%; padding: 0 16px; gap: 12px;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-icon { font-size: 20px; color: var(--amber); }
.brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 17px; color: var(--parchment); letter-spacing: 0.02em;
}
#topbar-title { flex: 1; font-size: 13px; font-weight: 500; color: var(--slate-lt); text-align: center; }
.fab-inline {
  background: var(--amber); color: var(--white); border: none;
  border-radius: var(--r-sm); padding: 7px 14px;
  font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif;
  cursor: pointer; flex-shrink: 0; transition: background 0.15s;
}
.fab-inline:hover { background: var(--amber-lt); }

/* ── BOTTOM NAV ─────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h); background: var(--espresso);
  display: flex; border-top: 1px solid rgba(255,255,255,0.06); z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; color: var(--slate);
  font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 500;
  cursor: pointer; transition: color 0.15s;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--amber); }
.nav-item:hover { color: var(--parchment); }

/* ── SIDEBAR ────────────────────────────────────────────────────── */
#sidebar { display: none; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: var(--slate);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.12s; border: none; background: none;
  width: 100%; text-align: left; font-family: 'Inter', sans-serif;
  border-left: 3px solid transparent;
}
.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav-item:hover { color: var(--parchment); background: rgba(255,255,255,0.04); }
.sidebar-nav-item.active { color: var(--amber); border-left-color: var(--amber); background: rgba(196,125,46,0.08); }
.sidebar-user {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--parchment); }
.sidebar-user-role { font-size: 11px; color: var(--slate); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── MAIN CONTENT ───────────────────────────────────────────────── */
#page-content {
  margin-top: var(--topbar-h);
  margin-bottom: var(--nav-h);
  min-height: calc(100vh - var(--topbar-h) - var(--nav-h));
  padding: 16px;
}

/* ── PAGE HEADER ────────────────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-family: 'DM Serif Display', serif; font-size: 26px; line-height: 1.2; }
.page-header p  { font-size: 13px; color: var(--slate); margin-top: 4px; }

/* ── CARDS ──────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }
.card-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }

/* ── BADGES ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}
.badge-pending  { background: rgba(139,158,168,0.15); color: var(--slate); }
.badge-arrived  { background: rgba(196,125,46,0.15);  color: var(--amber); }
.badge-stored   { background: rgba(74,92,58,0.15);    color: var(--olive); }
.badge-process  { background: rgba(196,125,46,0.2);   color: #A0601A; }
.badge-complete { background: rgba(46,125,82,0.15);   color: var(--success); }
.badge-active   { background: rgba(196,125,46,0.15);  color: var(--amber); }

/* ── LIST ROWS ──────────────────────────────────────────────────── */
.list-row {
  display: flex; align-items: center; padding: 14px 16px; gap: 12px;
  cursor: pointer; transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover  { background: #FAF6EE; }
.list-row:active { background: var(--parchment2); }
.row-icon {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 18px;
}
.row-icon-espresso { background: var(--espresso); color: var(--amber); }
.row-icon-olive    { background: rgba(74,92,58,0.12); color: var(--olive); }
.row-icon-amber    { background: rgba(196,125,46,0.12); color: var(--amber); }
.row-info { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub   { font-size: 12px; color: var(--slate); margin-top: 2px; }
.row-right { text-align: right; flex-shrink: 0; }
.row-weight { font-size: 13px; font-weight: 600; }
.row-date   { font-size: 11px; color: var(--slate); margin-top: 2px; }

/* ── YIELD BAR ──────────────────────────────────────────────────── */
.yield-bar-wrap { margin-top: 10px; }
.yield-bar-label {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--slate); margin-bottom: 5px; font-weight: 500;
  flex-wrap: wrap; gap: 2px;
}
.yield-bar-track {
  height: 8px; background: var(--parchment2);
  border-radius: 4px; overflow: hidden; display: flex; gap: 1px;
}
.yield-seg-prime    { background: var(--olive); }
.yield-seg-peaberry { background: var(--amber-lt); }
.yield-seg-defects  { background: #C0733A; }
.yield-seg-loss     { background: var(--slate-lt); }

/* ── STAT GRID ──────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--slate); }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 28px; line-height: 1.1; margin-top: 4px; }
.stat-unit  { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--slate); font-weight: 400; }
.stat-delta { font-size: 11px; margin-top: 4px; font-weight: 500; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── FORMS ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--border-md); border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 14px;
  color: var(--espresso); background: var(--white);
  outline: none; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(196,125,46,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 20px; border: none; border-radius: var(--r-sm);
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-primary   { background: var(--amber);   color: var(--white); }
.btn-primary:hover   { background: var(--amber-lt); }
.btn-secondary { background: var(--espresso); color: var(--parchment); }
.btn-secondary:hover { opacity: 0.9; }
.btn-ghost     { background: transparent; color: var(--espresso); border: 1.5px solid var(--border-md); }
.btn-ghost:hover     { background: var(--parchment2); }
.btn-sm   { padding: 7px 13px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-row  { display: flex; gap: 10px; margin-top: 20px; }
.btn-row .btn { flex: 1; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── SECTION LABEL ──────────────────────────────────────────────── */
.section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--slate);
  margin: 20px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border-md); }

/* ── DETAIL ROWS ────────────────────────────────────────────────── */
.detail-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 12px; color: var(--slate); font-weight: 500; flex-shrink: 0; }
.detail-val { font-size: 13px; font-weight: 600; text-align: right; }

/* ── GRADE GRID ─────────────────────────────────────────────────── */
.grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grade-item {
  background: var(--parchment); border-radius: var(--r-sm);
  padding: 12px; border-left: 3px solid var(--border-md);
}
.grade-item.prime    { border-left-color: var(--olive); }
.grade-item.peaberry { border-left-color: var(--amber); }
.grade-item.defect   { border-left-color: var(--danger); }
.grade-item.neutral  { border-left-color: var(--slate); }
.grade-name { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--slate); }
.grade-kg   { font-size: 18px; font-weight: 700; margin-top: 4px; }
.grade-pct  { font-size: 11px; color: var(--slate); margin-top: 2px; }

/* ── SUPPLIER ───────────────────────────────────────────────────── */
.supplier-row { padding: 14px 16px; border-bottom: 1px solid var(--border); transition: background 0.12s; }
.supplier-row:last-child { border-bottom: none; }
.supplier-row:hover { background: #FAF6EE; }
.supplier-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.supplier-name { font-size: 14px; font-weight: 600; }
.supplier-pct  { font-size: 15px; font-weight: 700; color: var(--olive); }
.supplier-bar-track { height: 6px; background: var(--parchment2); border-radius: 3px; overflow: hidden; }
.supplier-bar-fill  { height: 100%; background: linear-gradient(90deg, var(--olive), var(--olive-lt)); border-radius: 3px; transition: width 0.6s ease; }
.supplier-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 11px; color: var(--slate); flex-wrap: wrap; }

/* ── STEP INDICATOR ─────────────────────────────────────────────── */
.step-indicator { display: flex; align-items: center; margin-bottom: 20px; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--parchment2); border: 2px solid var(--border-md);
  color: var(--slate); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s;
}
.step-dot.done   { background: var(--olive);  border-color: var(--olive);  color: var(--white); }
.step-dot.active { background: var(--amber); border-color: var(--amber); color: var(--white); }
.step-line { flex: 1; height: 2px; background: var(--border-md); }
.step-line.done { background: var(--olive); }

/* ── LORRY ID ───────────────────────────────────────────────────── */
.lorry-id { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--amber); letter-spacing: 0.05em; }

/* ── LOADING / ERROR ────────────────────────────────────────────── */
.loading-state { text-align: center; padding: 40px; color: var(--slate); font-size: 14px; }
.err { color: var(--danger); font-size: 13px; padding: 12px 0; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--slate); }
.empty-state .es-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--espresso); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; line-height: 1.5; }

/* ── MODAL ──────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(28,20,16,0.55);
  z-index: 200; align-items: flex-end; justify-content: center;
}
#modal-card {
  background: var(--white); border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%; max-width: 600px; max-height: 92vh;
  overflow-y: auto; animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
#modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
#modal-title { font-family: 'DM Serif Display', serif; font-size: 20px; }
#modal-close { background: none; border: none; font-size: 18px; color: var(--slate); cursor: pointer; padding: 4px; }
#modal-close:hover { color: var(--espresso); }
#modal-body { padding: 20px; }

/* ── TOAST ──────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--espresso); color: var(--parchment);
  padding: 10px 20px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  opacity: 0; transition: all 0.25s; pointer-events: none;
  z-index: 300; border-left: 3px solid var(--amber);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── DESKTOP ────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  #sidebar {
    display: block; position: fixed;
    top: 0; left: 0; bottom: 0; width: 220px;
    background: var(--espresso);
    border-right: 1px solid rgba(255,255,255,0.06);
    z-index: 100; overflow-y: auto;
  }
  #bottom-nav { display: none !important; }
  .topbar-inner { padding-left: 236px; }
  #page-content { margin-left: 220px; margin-bottom: 0; padding: 24px 32px; max-width: 1100px; }
  #modal-overlay { align-items: center; }
  #modal-card { border-radius: var(--r-lg); max-height: 85vh; margin-left: 110px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  #toast { bottom: 20px; }
  .login-wrap { background: var(--espresso); }
}
