/* PREPP design system — clean, modern, fast, calm. Substantial whitespace,
   one accent color, no dashboard clutter. (spec section 53) */

:root {
  --ink: #1c1b19;
  --ink-soft: #55524c;
  --ink-faint: #8a867d;
  --paper: #fbfaf7;
  --paper-raised: #ffffff;
  --line: #e7e3da;
  --line-soft: #f0ede5;
  --accent: #b3402a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e6e0;
  --good: #4a7a4a;
  --good-soft: #e7f0e3;
  --warn: #b5791a;
  --warn-soft: #faedd6;
  --low: #8a866f;
  --low-soft: #ecebe3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 4px 16px rgba(28, 27, 25, 0.04);
  --shadow-lift: 0 10px 28px rgba(28, 27, 25, 0.10), 0 2px 8px rgba(28, 27, 25, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 12px; color: var(--ink-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--ink-faint); }
.mono { font-variant-numeric: tabular-nums; }

/* --- App shell ---------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--paper-raised);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 10px 22px; }
.brand-icon { height: 22px; width: auto; flex-shrink: 0; }
.brand-mark { font-weight: 750; font-size: 1.25rem; letter-spacing: 0.02em; }
.brand-restaurant { font-size: 0.78rem; color: var(--ink-faint); padding: 0 10px 14px; }
.topbar-brand { display: flex; align-items: center; gap: 7px; }
.topbar-brand .brand-icon { height: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.nav a:hover { background: var(--line-soft); }
.nav a.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 18px; text-align: center; opacity: 0.8; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 650; font-size: 0.8rem; flex-shrink: 0;
}
.user-meta { line-height: 1.25; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.74rem; color: var(--ink-faint); text-transform: capitalize; }
.logout-link { font-size: 0.78rem; color: var(--ink-faint); margin-left: auto; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.content { padding: 28px 32px 96px; max-width: 1080px; }
.content.narrow { max-width: 640px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header .eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 650; margin-bottom: 2px; }

/* --- Cards / stats -------------------------------------------------------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-header h2, .card-header h3 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; border-top: 3px solid var(--accent-soft);
  transition: border-top-color 0.15s ease, box-shadow 0.15s ease;
}
.stat:hover { border-top-color: var(--accent); box-shadow: var(--shadow-lift); }
.stat .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.stat .label { font-size: 0.8rem; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.next-order-card { border: 1px solid var(--line); border-top: 3px solid var(--accent); }
.next-order-card .eyebrow { color: var(--accent); }
.next-order-amount { font-size: 2.4rem; font-weight: 750; letter-spacing: -0.02em; margin: 2px 0 4px; }
.next-order-meta { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 18px; }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 0.92rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #96351f; box-shadow: 0 6px 16px rgba(179, 64, 42, 0.28); transform: translateY(-1px); }
.btn-secondary { background: var(--paper-raised); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--line-soft); border-color: var(--ink-faint); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--paper-raised); border-color: #e0b8ae; color: var(--accent); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 20px; font-size: 1.02rem; border-radius: var(--radius); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Forms ------------------------------------------------------------- */
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.95rem; background: var(--paper-raised); color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.help { font-size: 0.78rem; color: var(--ink-faint); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.checkbox-row input { width: auto; }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: inherit; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--line-soft); }

/* --- Badges / alerts ---------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 0.74rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-high { background: var(--good-soft); color: var(--good); }
.badge-medium { background: var(--warn-soft); color: var(--warn); }
.badge-low { background: var(--low-soft); color: var(--low); }
.badge-owner { background: var(--accent-soft); color: var(--accent); }
.badge-manager { background: var(--good-soft); color: var(--good); }
.badge-employee { background: var(--low-soft); color: var(--ink-soft); }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); font-size: 0.88rem; }
.alert-item.severity-warning { background: var(--warn-soft); border-color: #edd9ad; }
.alert-item.severity-info { background: var(--line-soft); }
.alert-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--ink-faint); }
.alert-item.severity-warning .alert-dot { background: var(--warn); }

.flash { padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.9rem; border: 1px solid transparent; }
.flash-success { background: var(--good-soft); color: var(--good); border-color: #c9dcc2; }
.flash-error { background: var(--accent-soft); color: var(--accent); border-color: #e6c3b8; }

.empty-state { text-align: center; padding: 44px 20px; color: var(--ink-faint); }

/* --- Login ---------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1100px 560px at 50% -8%, var(--accent-soft) 0%, transparent 62%), var(--paper);
}
.auth-card { width: 100%; max-width: 380px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow-lift); }
.auth-brand { display: flex; align-items: center; gap: 9px; font-size: 1.6rem; font-weight: 750; margin-bottom: 2px; }
.auth-brand .brand-icon { height: 28px; }
.auth-tagline { color: var(--ink-faint); margin-bottom: 24px; font-size: 0.92rem; }
.auth-switch { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 0.86rem; color: var(--ink-soft); text-align: center; }

/* --- Animated welcome splash (shown once per browser session, on auth pages) --- */
.welcome-splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1100px 560px at 50% -8%, var(--accent-soft) 0%, transparent 62%), var(--paper);
  animation: prepp-splash-out 0.6s ease 2s forwards;
}
.welcome-splash img {
  width: min(64vw, 280px);
  animation: prepp-splash-in 0.75s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes prepp-splash-in {
  from { opacity: 0; transform: scale(0.82) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes prepp-splash-out {
  from { opacity: 1; visibility: visible; }
  to { opacity: 0; visibility: hidden; }
}

/* --- Inventory counting (mobile-first) -------------------------------------- */
.count-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.count-progress-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.count-progress-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.2s; }
.count-progress-label { font-size: 0.82rem; color: var(--ink-faint); font-weight: 600; white-space: nowrap; }

.count-card { text-align: center; padding: 36px 24px; }
.count-storage { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.count-product-name { font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.count-vendor { color: var(--ink-faint); font-size: 0.88rem; margin-bottom: 28px; }
.count-stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 10px; }
.count-stepper button {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper-raised); font-size: 1.6rem; font-weight: 600; color: var(--ink);
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.count-stepper button:hover { border-color: var(--accent); }
.count-stepper button:active { background: var(--line-soft); transform: scale(0.94); }
.count-value-wrap { display: flex; flex-direction: column; align-items: center; min-width: 130px; }
.count-value {
  font-size: 3rem; font-weight: 750; width: 100%; text-align: center; border: none; background: transparent;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.count-value:focus { outline: none; }
.count-unit { color: var(--ink-faint); font-size: 0.9rem; margin-top: -6px; }
.count-quickset { display: flex; gap: 8px; justify-content: center; margin: 18px 0 8px; flex-wrap: wrap; }
.count-quickset button { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper-raised); font-size: 0.82rem; cursor: pointer; }
.count-nav { display: flex; gap: 10px; margin-top: 28px; }
.count-nav .btn { flex: 1; }
.count-save-indicator { font-size: 0.76rem; color: var(--ink-faint); margin-top: 14px; }

.storage-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.storage-tile {
  display: block; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; text-decoration: none; color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.storage-tile:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.storage-tile .count { color: var(--ink-faint); font-size: 0.8rem; margin-top: 4px; }

/* --- Order recommendation table ------------------------------------------- */
.order-line-qty { width: 74px; padding: 6px 8px; text-align: right; }
.why-link { font-size: 0.8rem; }
.confidence-note { font-size: 0.78rem; color: var(--ink-faint); }

.total-bar {
  position: sticky; bottom: 0; background: var(--paper-raised); border-top: 1px solid var(--line);
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 16px;
}
.total-bar .amount { font-size: 1.4rem; font-weight: 750; }

/* --- Utility --------------------------------------------------------------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 0.76rem; padding: 3px 9px; border-radius: 99px; background: var(--line-soft); color: var(--ink-soft); transition: background 0.12s ease, color 0.12s ease; }
a.tag:hover { background: var(--line); text-decoration: none; }
.tag-active, a.tag-active:hover { background: var(--accent); color: var(--accent-ink); }
.eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 650; }
.eyebrow a { color: inherit; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(28,27,25,0.35); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--paper-raised); border-radius: var(--radius); padding: 24px; max-width: 420px; width: 100%; box-shadow: var(--shadow); }

/* --- Mobile ------------------------------------------------------------- */
.mobile-tabbar { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 20px 16px 84px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--paper-raised);
    border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around; z-index: 10;
  }
  .mobile-tabbar a { color: var(--ink-faint); text-decoration: none; font-size: 0.72rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 10px; }
  .mobile-tabbar a.active { color: var(--accent); font-weight: 650; }
  .mobile-tabbar .nav-icon { font-size: 1.15rem; }
  .count-value { font-size: 2.6rem; }
  .count-stepper button { width: 60px; height: 60px; }
}
