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

:root {
  --green:       #2d6a4f;
  --green-light: #40916c;
  --green-pale:  #d8f3dc;
  --green-faint: #f0faf2;
  --ink:         #1a1a1a;
  --ink-2:       #444;
  --ink-3:       #777;
  --border:      #e0e0e0;
  --bg:          #f8f8f6;
  --white:       #ffffff;
  --red:         #c0392b;
  --red-pale:    #fdecea;
  --amber:       #b7791f;
  --amber-pale:  #fef3cd;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-lg:   0 4px 16px rgba(0,0,0,.10);
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ──────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 600; color: var(--ink); }
h2 { font-size: 1.2rem; font-weight: 600; color: var(--ink); }
h3 { font-size: 1rem; font-weight: 600; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ── Layout ──────────────────────────────────────────────────── */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.nav-brand span { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.nav-link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--green-pale); color: var(--green); }
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-3);
}

.container { max-width: 1100px; margin: 0 auto; padding: 2rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.breadcrumb { font-size: 12px; color: var(--ink-3); margin-bottom: 0.5rem; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--green); }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-body { padding: 1.25rem; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.stat-card .label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--green); line-height: 1.2; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green); color: white; border-color: var(--green); }
.btn-primary:hover { background: var(--green-light); border-color: var(--green-light); color: white; }
.btn-outline { background: white; color: var(--ink-2); border-color: var(--border); }
.btn-outline:hover { border-color: var(--ink-3); color: var(--ink); background: var(--bg); }
.btn-danger { background: white; color: var(--red); border-color: #e8c6c3; }
.btn-danger:hover { background: var(--red-pale); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 7px; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

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

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  transition: border-color .15s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--green-light); box-shadow: 0 0 0 3px rgba(64,145,108,.12); }
.form-control::placeholder { color: #bbb; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--green-faint); }
.td-num { text-align: right; font-variant-numeric: tabular-nums; font-family: 'Courier New', monospace; }

/* ── Phase Table (recipe) ────────────────────────────────────── */
.phase-section { margin-bottom: 1.5rem; }
.phase-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--green-pale);
  border-radius: 6px 6px 0 0;
  border: 1px solid #b7e4c7;
  border-bottom: none;
}
.phase-badge {
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .5px;
}
.phase-name { font-weight: 600; font-size: 13px; color: var(--green); }
.phase-table { border: 1px solid #b7e4c7; border-radius: 0 0 6px 6px; overflow: hidden; }
.phase-table th { background: #e8f5ed; }
.phase-table tr:hover td { background: var(--green-faint); }

/* ── Recipe Editor ───────────────────────────────────────────── */
.phase-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: white;
}
.phase-editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.phase-editor-body { padding: 12px; }
.ing-row {
  display: grid;
  grid-template-columns: 2fr 120px 1.5fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.ing-row input { margin-bottom: 0; }

/* ── AI Procedure ────────────────────────────────────────────── */
.procedure-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.procedure-header {
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.procedure-steps { padding: 16px; }
.step-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.step-num {
  min-width: 26px;
  height: 26px;
  background: var(--green);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-text { line-height: 1.6; color: var(--ink-2); }
.procedure-empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--ink-3);
}
.procedure-empty .icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: .3; }

.feedback-area { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--bg); }

/* ── Kg Scaler ───────────────────────────────────────────────── */
.scaler-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.scaler-bar label { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.scaler-input { width: 120px; }
.scaler-info { font-size: 12px; color: var(--ink-3); margin-left: auto; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: .3px;
}
.badge-green { background: var(--green-pale); color: var(--green); }
.badge-amber { background: var(--amber-pale); color: var(--amber); }
.badge-gray { background: #f0f0f0; color: var(--ink-3); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error { background: var(--red-pale); color: var(--red); border: 1px solid #f5c6c3; }
.alert-success { background: var(--green-pale); color: var(--green); border: 1px solid #b7e4c7; }

/* ── Login ───────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f5ed 0%, #f0faf2 50%, #f8f8f6 100%);
}
.login-card {
  width: 360px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.25rem; color: var(--green); margin-top: 0.5rem; }
.login-logo p { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--ink-3);
}
.empty-state .icon { font-size: 3rem; opacity: .2; margin-bottom: 0.75rem; }
.empty-state p { font-size: 14px; margin-bottom: 1.5rem; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #ccc;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Customer Grid ───────────────────────────────────────────── */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.customer-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.customer-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--green-light);
  text-decoration: none;
}
.customer-card-name { font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.customer-card-meta { font-size: 12px; color: var(--ink-3); }
.customer-card-count { margin-top: 12px; }

/* ── Recipe List ─────────────────────────────────────────────── */
.recipe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  transition: background .1s;
}
.recipe-row:last-child { border-bottom: none; }
.recipe-row:hover { background: var(--green-faint); }
.recipe-row-name { font-weight: 500; font-size: 14px; }
.recipe-row-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.recipe-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Info Grid (recipe view) ─────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}
.info-item { }
.info-item .key { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }
.info-item .val { font-size: 14px; color: var(--ink); margin-top: 2px; }

/* ── Search ──────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 8px; }
.search-bar .form-control { flex: 1; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  body { background: white; font-size: 11px; }
  .no-print, nav, .nav, .btn, button { display: none !important; }
  .container { padding: 0; max-width: 100%; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .page-break { page-break-before: always; }
  a { color: inherit; }
}

