@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root{
  /* palette */
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --ink: #2A2A28;
  --ink-soft: #6B675F;
  --line: #E7E2D6;

  --teal: #2E7D74;
  --teal-soft: #DCEEEA;
  --coral: #C85A4A;
  --coral-soft: #F7DCD6;
  --lavender: #7D74C8;
  --lavender-soft: #E4E1F7;
  --amber: #C88A2E;
  --amber-soft: #F6E7C9;
  --rose: #B5495B;
  --rose-soft: #F5DCE1;
  --blue: #3D7EBF;
  --blue-soft: #DCE9F7;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 3px rgba(40,35,20,0.06), 0 1px 2px rgba(40,35,20,0.04);
  --shadow-md: 0 8px 24px rgba(40,35,20,0.08);
  --shadow-lg: 0 20px 48px rgba(40,35,20,0.14);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  color:var(--ink);
  font-family:var(--font-body);
  font-size:15px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{font-family:var(--font-display);font-weight:600;margin:0;color:var(--ink);}
p{margin:0;}
button{font-family:inherit;cursor:pointer;}
input,select,textarea{font-family:inherit;}
::selection{background:var(--teal-soft);}

.hidden{display:none !important;}

/* ===================== SHELL ===================== */
.app-shell{
  max-width:1180px;
  margin:0 auto;
  padding:28px 24px 60px;
}

.app-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:22px;
}
.brand{display:flex;align-items:center;gap:12px;}
.brand h1{font-size:26px;letter-spacing:-0.01em;}
.tagline{color:var(--ink-soft);font-size:13px;margin-top:2px;}
.header-actions{display:flex;gap:10px;}
.icon-btn{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:999px;
  padding:8px 14px;
  font-size:13px;
  font-weight:600;
  color:var(--ink-soft);
  display:flex;align-items:center;gap:6px;
  box-shadow:var(--shadow-sm);
  transition:all .15s ease;
}
.icon-btn:hover{border-color:var(--teal);color:var(--teal);transform:translateY(-1px);}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;}
.dot-idle{background:#C9C3B3;}
.dot-live{background:var(--teal);box-shadow:0 0 0 3px var(--teal-soft);}

/* ===================== TABS ===================== */
.tabbar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:24px;
}
.tab{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:999px;
  padding:10px 16px;
  font-size:13.5px;
  font-weight:600;
  color:var(--ink-soft);
  display:flex;align-items:center;gap:7px;
  transition:all .15s ease;
  white-space:nowrap;
}
.tab-ico{font-size:14px;}
.tab:hover{border-color:var(--teal);color:var(--teal);}
.tab.active{
  background:linear-gradient(135deg,var(--teal),#245F58);
  border-color:transparent;
  color:#fff;
  box-shadow:0 6px 16px rgba(46,125,116,0.28);
}

/* ===================== PANELS ===================== */
.tab-panel{display:none;animation:fadeIn .25s ease;}
.tab-panel.active{display:block;}
@keyframes fadeIn{from{opacity:0;transform:translateY(4px);}to{opacity:1;transform:translateY(0);}}

.panel-head{
  display:flex;justify-content:space-between;align-items:flex-end;flex-wrap:wrap;gap:12px;
  margin-bottom:18px;
}
.panel-title{font-size:22px;}
.panel-sub{color:var(--ink-soft);font-size:13.5px;margin-top:4px;}

/* ===================== CARDS / GRID ===================== */
.card{
  background:var(--surface);
  border-radius:var(--radius-md);
  padding:20px;
  box-shadow:var(--shadow-sm);
  border:1px solid var(--line);
}
.card-lg{padding:24px;}
.grid{display:grid;gap:14px;}
.grid-2{grid-template-columns:repeat(2,1fr);}
.grid-3{grid-template-columns:repeat(3,1fr);}
.grid-4{grid-template-columns:repeat(4,1fr);}
.grid-5{grid-template-columns:repeat(5,1fr);}
@media(max-width:900px){.grid-3,.grid-4,.grid-5{grid-template-columns:repeat(2,1fr);}}
@media(max-width:560px){.grid-2,.grid-3,.grid-4,.grid-5{grid-template-columns:1fr;}}

.stat-card{
  border-radius:var(--radius-md);
  padding:18px 20px;
  position:relative;
  overflow:hidden;
}
.stat-card .stat-value{font-family:var(--font-display);font-size:30px;font-weight:600;line-height:1;}
.stat-card .stat-label{font-size:12.5px;color:var(--ink-soft);margin-top:8px;font-weight:600;text-transform:uppercase;letter-spacing:.03em;}
.stat-card.c-coral{background:var(--coral-soft);} .stat-card.c-coral .stat-value{color:var(--coral);}
.stat-card.c-teal{background:var(--teal-soft);} .stat-card.c-teal .stat-value{color:var(--teal);}
.stat-card.c-lavender{background:var(--lavender-soft);} .stat-card.c-lavender .stat-value{color:var(--lavender);}
.stat-card.c-amber{background:var(--amber-soft);} .stat-card.c-amber .stat-value{color:var(--amber);}
.stat-card.c-rose{background:var(--rose-soft);} .stat-card.c-rose .stat-value{color:var(--rose);}
.stat-card.c-blue{background:var(--blue-soft);} .stat-card.c-blue .stat-value{color:var(--blue);}
.stat-card.c-plain{background:var(--surface);border:1px solid var(--line);} .stat-card.c-plain .stat-value{color:var(--ink);}

/* section title inside card group */
.section-title{font-size:16px;margin-bottom:12px;display:flex;align-items:center;gap:8px;}
.section-block{margin-bottom:20px;}

/* ===================== PILL SELECTOR (period switch) ===================== */
.pill-switch{display:inline-flex;background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px;gap:2px;}
.pill-switch button{
  border:none;background:transparent;padding:8px 16px;border-radius:999px;font-weight:600;font-size:13px;color:var(--ink-soft);
}
.pill-switch button.active{background:var(--teal);color:#fff;}

.date-nav{display:flex;align-items:center;gap:10px;}
.date-nav button{background:var(--surface);border:1px solid var(--line);border-radius:10px;width:36px;height:36px;font-size:15px;box-shadow:var(--shadow-sm);}
.date-nav .date-label{font-weight:700;font-size:15px;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:8px 16px;box-shadow:var(--shadow-sm);}

/* ===================== FORM ELEMENTS ===================== */
.field{display:flex;flex-direction:column;gap:6px;}
.field label{font-size:11.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-soft);}
.field input,.field select,.field textarea{
  border:1px solid var(--line);border-radius:10px;padding:10px 12px;font-size:14px;background:var(--surface);color:var(--ink);
  width:100%;
}
.field input:focus,.field select:focus,.field textarea:focus{outline:2px solid var(--teal);outline-offset:1px;border-color:var(--teal);}
.field textarea{resize:vertical;min-height:70px;}
.field-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:14px;margin-bottom:14px;}
.range-row{display:flex;align-items:center;gap:12px;}
.range-row input[type=range]{flex:1;accent-color:var(--teal);}
.range-val{font-weight:700;min-width:28px;text-align:center;}

.btn-primary,.btn-secondary,.btn-danger{
  border-radius:12px;padding:11px 18px;font-weight:700;font-size:13.5px;border:none;transition:all .15s ease;
}
.btn-primary{background:linear-gradient(135deg,#3E9689,var(--teal));color:#fff;box-shadow:0 6px 16px rgba(46,125,116,0.25);}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 8px 20px rgba(46,125,116,0.32);}
.btn-secondary{background:var(--surface);color:var(--ink);border:1px solid var(--line);}
.btn-secondary:hover{border-color:var(--ink-soft);}
.btn-danger{background:var(--rose-soft);color:var(--rose);}
.btn-danger:hover{background:var(--rose);color:#fff;}
.btn-row{display:flex;gap:10px;flex-wrap:wrap;margin-top:4px;}
button:disabled{opacity:.5;cursor:not-allowed;}

/* ===================== PROGRESS BARS ===================== */
.bar-row{display:grid;grid-template-columns:90px 1fr 90px;align-items:center;gap:10px;margin-bottom:10px;font-size:13px;}
.bar-row .bar-label{color:var(--ink-soft);font-weight:600;}
.bar-track{height:9px;background:#EDE9DD;border-radius:999px;overflow:hidden;}
.bar-fill{height:100%;border-radius:999px;transition:width .4s ease;}
.bar-fill.ok{background:var(--teal);}
.bar-fill.over{background:var(--rose);}
.bar-row .bar-val{text-align:right;font-weight:700;font-variant-numeric:tabular-nums;font-size:12.5px;}

/* ===================== LISTS / TABLES ===================== */
.list-row{
  display:flex;justify-content:space-between;align-items:center;
  padding:12px 14px;background:var(--surface);border:1px solid var(--line);border-radius:12px;margin-bottom:8px;
}
.list-row .lr-main{font-weight:700;font-size:14px;}
.list-row .lr-sub{color:var(--ink-soft);font-size:12.5px;margin-top:2px;}
.list-row .lr-actions{display:flex;gap:8px;}
.list-row .lr-actions button{background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:6px 9px;font-size:12px;}
.list-row .lr-actions button:hover{border-color:var(--teal);color:var(--teal);}

.tag{display:inline-block;padding:4px 10px;border-radius:999px;font-size:11.5px;font-weight:700;}
.tag-ok{background:var(--teal-soft);color:var(--teal);}
.tag-warn{background:var(--amber-soft);color:var(--amber);}
.tag-danger{background:var(--rose-soft);color:var(--rose);}
.tag-neutral{background:#EDE9DD;color:var(--ink-soft);}

.empty-state{
  text-align:center;padding:36px 20px;color:var(--ink-soft);
}
.empty-state .es-ico{font-size:32px;margin-bottom:10px;}

/* ===================== FOOD LOG ===================== */
.food-search-box{position:relative;margin-bottom:12px;}
.food-search-box input{padding-left:38px;}
.food-search-box .fs-ico{position:absolute;left:12px;top:50%;transform:translateY(-50%);opacity:.5;}
.cuisine-filter{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;}
.cuisine-chip{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:6px 12px;font-size:12px;font-weight:600;color:var(--ink-soft);}
.cuisine-chip.active{background:var(--ink);color:#fff;border-color:var(--ink);}
.food-results{max-height:320px;overflow-y:auto;border:1px solid var(--line);border-radius:12px;}
.food-result-item{display:flex;justify-content:space-between;align-items:center;padding:11px 14px;border-bottom:1px solid var(--line);}
.food-result-item:last-child{border-bottom:none;}
.food-result-item:hover{background:var(--bg);}
.fri-name{font-weight:700;font-size:13.5px;}
.fri-meta{color:var(--ink-soft);font-size:11.5px;margin-top:2px;}
.fri-add{background:var(--teal);color:#fff;border:none;border-radius:8px;width:30px;height:30px;font-size:16px;font-weight:700;}

/* ===================== CHARTS (SVG) ===================== */
.chart-wrap{width:100%;overflow-x:auto;}
.chart-wrap svg{width:100%;height:auto;display:block;}
.chart-legend{display:flex;gap:16px;margin-top:10px;font-size:12px;color:var(--ink-soft);}
.legend-dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:5px;}

/* ===================== INFERENCE / INSIGHT BOX ===================== */
.insight-box{
  background:linear-gradient(135deg,var(--teal-soft),#F1F7EF);
  border:1px solid #CFE6DF;
  border-radius:var(--radius-md);
  padding:16px 18px;
  font-size:13.5px;
  line-height:1.65;
}
.insight-box b{color:var(--teal);}
.insight-box.warn{background:linear-gradient(135deg,var(--rose-soft),#FBEAEC);border-color:#EAC3CB;}
.insight-box.warn b{color:var(--rose);}

/* ===================== TOOLTIP ===================== */
[data-tooltip]{position:relative;}
.tt-icon{
  display:inline-flex;align-items:center;justify-content:center;
  width:15px;height:15px;border-radius:50%;background:#EDE9DD;color:var(--ink-soft);
  font-size:10px;font-weight:700;cursor:help;margin-left:5px;
}
.tooltip-layer{position:fixed;z-index:9999;pointer-events:none;}
.tooltip-bubble{
  position:absolute;background:var(--ink);color:#fff;padding:8px 12px;border-radius:8px;font-size:12px;
  max-width:230px;line-height:1.4;box-shadow:var(--shadow-lg);
}
.tooltip-bubble::after{content:"";position:absolute;bottom:-5px;left:16px;width:9px;height:9px;background:var(--ink);transform:rotate(45deg);}

/* ===================== TOAST ===================== */
.toast{
  position:fixed;bottom:26px;left:50%;transform:translateX(-50%) translateY(20px);
  background:var(--ink);color:#fff;padding:12px 20px;border-radius:12px;font-size:13.5px;font-weight:600;
  opacity:0;pointer-events:none;transition:all .25s ease;box-shadow:var(--shadow-lg);z-index:10000;
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}

/* ===================== HELP ACCORDION ===================== */
.help-item{border:1px solid var(--line);border-radius:12px;margin-bottom:10px;overflow:hidden;background:var(--surface);}
.help-q{padding:14px 16px;font-weight:700;font-size:13.5px;display:flex;justify-content:space-between;align-items:center;}
.help-a{padding:0 16px;max-height:0;overflow:hidden;transition:all .25s ease;color:var(--ink-soft);font-size:13.5px;line-height:1.6;}
.help-item.open .help-a{max-height:400px;padding:0 16px 16px;}
.help-item.open .help-q .chev{transform:rotate(90deg);}
.chev{transition:transform .2s ease;}

/* ===================== SETTINGS ===================== */
.settings-group{margin-bottom:24px;}
.settings-row{display:flex;justify-content:space-between;align-items:center;padding:13px 0;border-bottom:1px solid var(--line);}
.settings-row:last-child{border-bottom:none;}
.settings-row .sr-label{font-weight:700;font-size:13.5px;}
.settings-row .sr-sub{color:var(--ink-soft);font-size:12px;margin-top:2px;}
.switch{position:relative;width:44px;height:24px;background:#DDD6C4;border-radius:999px;transition:.2s;flex-shrink:0;}
.switch.on{background:var(--teal);}
.switch::after{content:"";position:absolute;top:2px;left:2px;width:20px;height:20px;background:#fff;border-radius:50%;transition:.2s;box-shadow:0 1px 3px rgba(0,0,0,.2);}
.switch.on::after{left:22px;}
.theme-swatches{display:flex;gap:10px;flex-wrap:wrap;}
.theme-swatch{width:38px;height:38px;border-radius:50%;border:2px solid transparent;cursor:pointer;}
.theme-swatch.selected{border-color:var(--ink);}

/* ===================== LOCK SCREEN ===================== */
.lock-screen{position:fixed;inset:0;background:var(--bg);display:flex;align-items:center;justify-content:center;z-index:20000;}
.lock-card{background:var(--surface);padding:36px 32px;border-radius:var(--radius-lg);box-shadow:var(--shadow-lg);text-align:center;max-width:320px;width:90%;}
.lock-icon{font-size:34px;margin-bottom:10px;}
.lock-card h2{font-size:20px;margin-bottom:6px;}
.lock-card p{color:var(--ink-soft);font-size:13px;margin-bottom:18px;}
.lock-card input{width:100%;padding:11px 14px;border:1px solid var(--line);border-radius:10px;margin-bottom:12px;text-align:center;}
.lock-card .btn-primary{width:100%;}
.lock-error{color:var(--rose);font-size:12.5px;margin-top:10px;}

/* ===================== FOOTER ===================== */
.app-footer{text-align:center;color:var(--ink-soft);font-size:11.5px;margin-top:40px;opacity:.8;}

/* checklist */
.checklist{display:flex;flex-direction:column;gap:8px;}
.check-item{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--bg);border-radius:10px;font-size:13px;}
.check-item input{width:17px;height:17px;accent-color:var(--teal);}
.check-item.done .ci-text{text-decoration:line-through;color:var(--ink-soft);}

/* small helper */
.muted{color:var(--ink-soft);}
.mb-10{margin-bottom:10px;}
.mb-16{margin-bottom:16px;}
.mb-20{margin-bottom:20px;}
.flex{display:flex;}
.flex-between{display:flex;justify-content:space-between;align-items:center;}
.gap-8{gap:8px;}
.text-right{text-align:right;}

@media(max-width:640px){
  .app-shell{padding:16px 12px 40px;}
  .grid-3,.grid-4,.grid-5{grid-template-columns:1fr 1fr;}
  .stat-card .stat-value{font-size:24px;}
}
