/* ═══════════════════════════════════════════════════════════
   DAIRY SUITE — Shared Stylesheet
   Design tokens + common components used by all pages.
   Each calculator imports this, then adds its own small
   <style> block for product-specific overrides.
═══════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────── */
:root {
  /* Brand */
  --accent:     #d4781e;
  --accent-lt:  #f5e6d3;
  --accent-dk:  #a85c12;

  /* Surfaces */
  --bg:         #faf9f7;
  --surface:    #ffffff;
  --surface2:   #f4f1ec;
  --border:     #e8e2d9;

  /* Text */
  --text:       #1a1a1a;
  --textm:      #555;
  --textl:      #888;

  /* Status */
  --ok:         #2e7d52;
  --ok-bg:      #e8f5ee;
  --err:        #c0392b;
  --err-bg:     #fdecea;
  --warn:       #e67e22;
  --warn-bg:    #fef3e2;

  /* Layout */
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.06);

  /* Typography */
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'SF Mono', 'Fira Code', monospace;
}

[data-theme="night"] {
  --bg:         #121212;
  --surface:    #1e1e1e;
  --surface2:   #2a2a2a;
  --border:     #333;
  --text:       #e8e8e8;
  --textm:      #aaa;
  --textl:      #666;
  --accent-lt:  #2a1a08;
  --shadow:     0 2px 12px rgba(0,0,0,.4);
}

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

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  background: var(--accent);
  color: #fff;
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-header .back-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.page-header h1 {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
}
.page-header .sub {
  font-size: 11px;
  opacity: .8;
  display: block;
  font-weight: 400;
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
#theme-toggle {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

/* ── Page body ───────────────────────────────────────────── */
.page-body {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 100px;  /* room for FAB */
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  background: var(--surface2);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Form controls ───────────────────────────────────────── */
.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}
.field label {
  font-size: 11px;
  color: var(--textm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.field input,
.field select {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field .unit {
  font-size: 11px;
  color: var(--textl);
  margin-top: 2px;
}

/* ── Results table ───────────────────────────────────────── */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.result-table thead th {
  background: var(--accent);
  color: #fff;
  padding: 6px 8px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
}
.result-table thead th:first-child { text-align: left; }
.result-table tbody tr:nth-child(even) { background: var(--surface2); }
.result-table tbody td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.result-table tbody td:first-child { text-align: left; font-weight: 500; }
.result-table tfoot td {
  padding: 7px 8px;
  font-weight: 700;
  text-align: right;
  border-top: 2px solid var(--accent);
  background: var(--accent-lt);
}
.result-table tfoot td:first-child { text-align: left; }

/* ── Cost rows ───────────────────────────────────────────── */
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cost-row:last-child { border-bottom: none; }
.cost-row .label { color: var(--textm); }
.cost-row .val   { font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ── Status pills ────────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.pill-ok   { background: var(--ok-bg);   color: var(--ok);   }
.pill-err  { background: var(--err-bg);  color: var(--err);  }
.pill-warn { background: var(--warn-bg); color: var(--warn); }

/* ── FSSAI compliance row ────────────────────────────────── */
.fssai-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0 0;
}
.fssai-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--textm);
}
.fssai-item .check { font-size: 13px; }

/* ── FAB (Save button) ───────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 568px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 15px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(212,120,30,.4);
  transition: background .15s, opacity .15s;
  z-index: 200;
}
.fab:disabled { opacity: .5; cursor: not-allowed; }
.fab:active:not(:disabled) { background: var(--accent-dk); }

/* ── Sync badge ──────────────────────────────────────────── */
.sync-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 600;
}
.sync-badge.synced  { background: var(--ok-bg);   color: var(--ok);  }
.sync-badge.saving  { background: var(--warn-bg);  color: var(--warn); }
.sync-badge.error   { background: var(--err-bg);   color: var(--err);  }

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  font-size: 36px;
  margin-bottom: 8px;
}
.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  font-size: 12px;
  color: var(--textl);
  margin-bottom: 24px;
}
.login-msg {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.login-msg.show { display: block; }
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}
.btn-primary:hover  { background: var(--accent-dk); }
.btn-primary:active { background: var(--accent-dk); }

/* ── Hub / app grid ──────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}
.app-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s, transform .1s;
  box-shadow: var(--shadow-sm);
}
.app-tile:active {
  transform: scale(.97);
  box-shadow: none;
}
.app-tile .icon { font-size: 32px; }
.app-tile .name { font-size: 13px; font-weight: 600; text-align: center; }
.app-tile .desc { font-size: 11px; color: var(--textl); text-align: center; }

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 480px) {
  .field-row .field { min-width: 160px; }
}
