@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ─── VARIABLES ─────────────────────────────────────────── */
:root {
  --brand-900: #0a1628;
  --brand-800: #0f2040;
  --brand-700: #1a3560;
  --brand-600: #1e4080;
  --brand-400: #3b7dd8;
  --brand-300: #5b9ae8;
  --brand-100: #dbeafe;
  --brand-50:  #eff6ff;

  --accent:     #f0a500;
  --accent-lt:  #fef3c7;
  --accent-dk:  #b77800;

  --danger:     #dc2626;
  --danger-lt:  #fee2e2;
  --success:    #16a34a;
  --success-lt: #dcfce7;
  --warning:    #d97706;
  --warning-lt: #fef3c7;
  --info:       #0284c7;
  --info-lt:    #e0f2fe;

  --bg:         #f6f8fc;
  --surface:    #ffffff;
  --surface-2:  #f1f4f9;
  --border:     #e2e8f0;
  --border-2:   #cbd5e1;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.06);

  --sidebar-w: 240px;
  --header-h:  60px;
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brand-900);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar__logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar__logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar__logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar__logo-icon svg { width: 20px; height: 20px; color: var(--brand-900); }

.sidebar__logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1;
}

.sidebar__logo-sub {
  font-size: .65rem;
  color: rgba(255,255,255,.45);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
  padding: 12px 8px 6px;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  position: relative;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

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

.nav-link.active {
  color: #fff;
  background: rgba(59,125,216,.25);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .75rem;
  color: rgba(255,255,255,.3);
}

.sidebar__footer strong { color: rgba(255,255,255,.6); display: block; }

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

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

.topbar__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar__date {
  font-size: .8rem;
  color: var(--text-muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  color: var(--text-secondary);
}

.hamburger svg { width: 22px; height: 22px; }

/* ─── PAGE CONTENT ───────────────────────────────────────── */
.page {
  display: none;
  padding: 28px;
  flex: 1;
  animation: fadeSlideIn .25s ease;
}

.page.active { display: block; }

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

.page-header {
  margin-bottom: 24px;
}

.page-header__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text-primary);
}

.page-header__sub {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.card__header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card__body { padding: 20px 24px; }

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 0 var(--radius-lg) 0 60px;
  opacity: .06;
  background: var(--brand-400);
}

.stat-card--accent::after { background: var(--accent); }

.stat-card__label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card__value--accent { color: var(--accent-dk); }
.stat-card__value--brand  { color: var(--brand-600); }

.stat-card__sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--brand-700);
  color: #fff;
  border-color: var(--brand-700);
}
.btn--primary:hover { background: var(--brand-800); border-color: var(--brand-800); }

.btn--accent {
  background: var(--accent);
  color: var(--brand-900);
  border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-2);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text-primary); }

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

.btn--danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(220,38,38,.3);
}
.btn--danger-ghost:hover { background: var(--danger-lt); }

.btn--sm { padding: 5px 10px; font-size: .8rem; }
.btn--lg { padding: 12px 24px; font-size: 1rem; }
.btn--icon { padding: 7px; }

.btn:disabled { opacity: .5; pointer-events: none; }

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

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(59,125,216,.12);
}

.form-input.error,
.form-select.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.form-error {
  font-size: .78rem;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}
.form-error.visible { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--brand-50); }

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge--blue   { background: var(--brand-100); color: var(--brand-700); }
.badge--yellow { background: var(--accent-lt);  color: var(--accent-dk); }
.badge--green  { background: var(--success-lt); color: var(--success); }
.badge--gray   { background: var(--surface-2);  color: var(--text-secondary); }

/* ─── STOCK ENTRY CHECKLIST ──────────────────────────────── */
.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.ingredient-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  transition: all .15s;
  cursor: pointer;
}

.ingredient-item:hover { border-color: var(--brand-300); box-shadow: var(--shadow-sm); }

.ingredient-item.selected {
  border-color: var(--brand-400);
  background: var(--brand-50);
  box-shadow: 0 0 0 2px rgba(59,125,216,.12);
}

.ingredient-item__check {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}

.ingredient-item.selected .ingredient-item__check {
  background: var(--brand-600);
  border-color: var(--brand-600);
}

.ingredient-item.selected .ingredient-item__check svg {
  display: block;
}

.ingredient-item__check svg {
  display: none;
  width: 12px; height: 12px;
  color: #fff;
  stroke-width: 3;
}

.ingredient-item__info { flex: 1; min-width: 0; }
.ingredient-item__name {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ingredient-item__meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.ingredient-item__qty {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  width: 100%;
}
.ingredient-item.selected .ingredient-item__qty { display: flex; align-items: center; gap: 8px; }

.qty-input {
  width: 80px;
  padding: 5px 8px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color .15s;
}
.qty-input:focus { border-color: var(--brand-400); }

.qty-label { font-size: .8rem; color: var(--text-muted); }

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

.search-box {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.search-box svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
}
.search-box input:focus { border-color: var(--brand-400); }

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cat-tab {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  border: 1.5px solid var(--border-2);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}
.cat-tab:hover, .cat-tab.active {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
}

/* summary bar */
.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 28px;
  margin: 24px -28px -28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  z-index: 40;
}
.submit-bar__info { font-size: .875rem; color: var(--text-secondary); }
.submit-bar__info strong { color: var(--text-primary); font-size: 1rem; }
.submit-bar__cost { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; color: var(--accent-dk); }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.empty-state__title { font-weight: 700; font-size: 1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state__sub { font-size: .875rem; color: var(--text-muted); }

/* ─── DRAWER (ingredient form) ───────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  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: 0; bottom: 0;
  width: 420px; max-width: 95vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  z-index: 201;
  display: flex;
  flex-direction: column;
}
.drawer-overlay.open .drawer { transform: translateX(0); }

.drawer__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
}
.drawer__close {
  background: none; border: none; padding: 6px;
  color: var(--text-muted); border-radius: var(--radius-sm);
}
.drawer__close:hover { background: var(--surface-2); color: var(--text-primary); }
.drawer__close svg { width: 20px; height: 20px; }

.drawer__body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── TOAST ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--brand-900);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 360px;
  opacity: 0;
  transform: translateX(20px);
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
  pointer-events: all;
}
.toast--visible { opacity: 1; transform: translateX(0); }
.toast--success { border-left: 4px solid var(--success); }
.toast--error   { border-left: 4px solid var(--danger); }
.toast--warning { border-left: 4px solid var(--warning); }
.toast--info    { border-left: 4px solid var(--brand-300); }

.toast__icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast__icon svg { width: 100%; height: 100%; }
.toast--success .toast__icon { color: var(--success); }
.toast--error   .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info    .toast__icon { color: var(--brand-300); }

.toast__msg { flex: 1; font-size: .875rem; font-weight: 500; line-height: 1.4; }

.toast__close {
  background: none; border: none; padding: 2px;
  color: rgba(255,255,255,.5);
  flex-shrink: 0;
}
.toast__close svg { width: 14px; height: 14px; }
.toast__close:hover { color: #fff; }

/* ─── MODAL ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay--visible { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 400px; max-width: 90vw;
  transform: scale(.95) translateY(8px);
  transition: transform .2s cubic-bezier(.34,1.2,.64,1);
}
.modal-overlay--visible .modal { transform: scale(1) translateY(0); }

.modal__header { padding: 20px 24px 16px; }
.modal__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
}
.modal__body { padding: 0 24px 16px; font-size: .9rem; color: var(--text-secondary); line-height: 1.6; }
.modal__footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ─── SPINNER ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── REPORT PAGE ────────────────────────────────────────── */
.report-date-nav {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.report-date-nav input[type="date"] {
  padding: 7px 12px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  outline: none;
  background: var(--surface);
}
.report-date-nav input[type="date"]:focus { border-color: var(--brand-400); }

.cost-highlight {
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.cost-highlight__label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .6;
  margin-bottom: 6px;
}
.cost-highlight__value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.04em;
}
.cost-highlight__icon { opacity: .15; }
.cost-highlight__icon svg { width: 56px; height: 56px; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .hamburger { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .page { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .submit-bar { padding: 12px 16px; margin: 16px -16px -20px; }
  .ingredient-grid { grid-template-columns: 1fr; }

  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    display: none;
  }
  .sidebar-backdrop.open { display: block; }
}

/* ─── MISC ───────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-muted  { color: var(--text-muted); }
.font-bold   { font-weight: 700; }
.flex        { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.category-color {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
