/* =============================================
   RECIPE COST CALCULATOR — app.css
   App UI layer. Inherits tokens from ../styles.css
   Scoped under .rc-app so it never fights the
   marketing stylesheet.
   ============================================= */

.rc-app {
  --rc-gap: 18px;
  --rc-radius: 10px;
  --rc-pad: 18px;

  --rc-ok:    #3ddc84;
  --rc-warn:  #ffb32c;
  --rc-bad:   #ff5c5c;
  --rc-ok-bg:   rgba(61,220,132,.12);
  --rc-warn-bg: rgba(255,179,44,.12);
  --rc-bad-bg:  rgba(255,92,92,.12);

  --rc-line: rgba(204,232,244,.12);

  font-size: 15px;
  line-height: 1.55;
  display: block;
  padding: 0 24px 90px;
  background: var(--bg);
}

.rc-shell {
  max-width: var(--max-w);
  margin: 0 auto;
}

.rc-app *:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- FIRST RUN --- */
.rc-firstrun {
  border: 1px solid var(--border-hot);
  background: linear-gradient(180deg, var(--bg-card-2), var(--bg-card));
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 26px;
  box-shadow: 0 0 30px var(--neon-glow-s);
}
.rc-firstrun-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-bright);
  margin-bottom: 8px;
}
.rc-firstrun-text { color: var(--text-dim); max-width: 62ch; margin-bottom: 18px; }
.rc-firstrun-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.rc-firstrun-actions .btn { padding: 11px 20px; font-size: 15px; }

/* --- TABS --- */
.rc-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--rc-line);
  margin-bottom: 16px;
  padding-bottom: 1px;
  -webkit-overflow-scrolling: touch;
}
.rc-tab {
  flex: 0 0 auto;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
  border-radius: 6px 6px 0 0;
}
.rc-tab:hover { color: var(--text); background: rgba(0,212,255,.05); }
.rc-tab.is-active {
  color: var(--neon);
  border-bottom-color: var(--neon);
  background: rgba(0,212,255,.07);
}

/* --- STATUS BAR --- */
.rc-statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 30px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-dim);
}
.rc-statusbar:empty { display: none; }
.rc-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rc-ok); flex: 0 0 auto;
  box-shadow: 0 0 8px currentColor;
}
.rc-status-dot.is-off { background: var(--text-dim); box-shadow: none; }
.rc-statusbar .rc-spacer { flex: 1 1 auto; }

/* --- HEADINGS --- */
.rc-view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.rc-h1 {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.2;
  color: var(--text-bright);
}
.rc-h2 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-bright);
  margin-bottom: 12px;
}
.rc-h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--neon);
  margin-bottom: 10px;
}
.rc-sub { color: var(--text-dim); max-width: 72ch; }
.rc-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- CARDS / PANELS --- */
.rc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--rc-radius);
  padding: var(--rc-pad);
}
.rc-card + .rc-card { margin-top: var(--rc-gap); }
.rc-card-hot { border-color: var(--border-hot); box-shadow: 0 0 20px var(--neon-glow-s); }
.rc-card-warn { border-color: rgba(255,179,44,.4); background: linear-gradient(180deg, var(--rc-warn-bg), var(--bg-card)); }
.rc-card-bad  { border-color: rgba(255,92,92,.4);  background: linear-gradient(180deg, var(--rc-bad-bg), var(--bg-card)); }

.rc-grid { display: grid; gap: var(--rc-gap); }
.rc-grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.rc-grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.rc-grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.rc-stack { display: flex; flex-direction: column; gap: var(--rc-gap); }
.rc-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rc-row-tight { gap: 8px; }
.rc-spacer { flex: 1 1 auto; }

/* --- STAT TILES --- */
.rc-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--rc-radius);
  padding: 16px;
}
.rc-stat-label {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.rc-stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  color: var(--text-bright);
}
.rc-stat-value.is-ok   { color: var(--rc-ok); }
.rc-stat-value.is-warn { color: var(--rc-warn); }
.rc-stat-value.is-bad  { color: var(--rc-bad); }
.rc-stat-note { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.rc-stat-spark { margin-top: 10px; height: 34px; }

/* --- TABLES --- */
.rc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--rc-radius);
  background: var(--bg-card);
}
.rc-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
.rc-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rc-line);
  white-space: nowrap;
  background: var(--bg-card-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.rc-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rc-line);
  vertical-align: middle;
}
.rc-table tbody tr:last-child td { border-bottom: none; }
.rc-table tbody tr:hover { background: rgba(0,212,255,.04); }
.rc-table .rc-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-table .rc-shrink { width: 1%; white-space: nowrap; }

/* --- BADGES / PILLS --- */
.rc-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.rc-badge-neon { color: var(--neon); border-color: var(--border-hot); background: rgba(0,212,255,.08); }
.rc-badge-ok   { color: var(--rc-ok);   border-color: rgba(61,220,132,.4); background: var(--rc-ok-bg); }
.rc-badge-warn { color: var(--rc-warn); border-color: rgba(255,179,44,.4); background: var(--rc-warn-bg); }
.rc-badge-bad  { color: var(--rc-bad);  border-color: rgba(255,92,92,.4);  background: var(--rc-bad-bg); }

/* --- BUTTONS (compact variants on top of site .btn) --- */
.rc-app .btn { font-size: 14px; padding: 10px 18px; }
.rc-btn-sm { padding: 6px 12px !important; font-size: 13px !important; border-width: 1px !important; }
.rc-btn-icon {
  padding: 6px 9px !important;
  font-size: 14px !important;
  line-height: 1;
  border-width: 1px !important;
}
.rc-btn-danger {
  background: transparent;
  color: var(--rc-bad);
  border: 2px solid rgba(255,92,92,.45);
}
.rc-btn-danger:hover { background: var(--rc-bad-bg); border-color: var(--rc-bad); box-shadow: 0 0 18px rgba(255,92,92,.25); }
.rc-app .btn:disabled,
.rc-app button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* --- FORMS --- */
.rc-field { display: block; margin-bottom: 14px; }
.rc-label {
  display: block;
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
}
.rc-hint { font-size: 12px; color: var(--text-dim); margin-top: 5px; line-height: 1.45; }
.rc-input, .rc-select, .rc-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.rc-input:focus, .rc-select:focus, .rc-textarea:focus {
  outline: none;
  border-color: var(--border-hot);
  box-shadow: 0 0 0 3px var(--neon-glow-s);
}
.rc-input::placeholder, .rc-textarea::placeholder { color: rgba(204,232,244,.35); }
.rc-textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.rc-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--neon) 50%), linear-gradient(135deg, var(--neon) 50%, transparent 50%);
  background-position: calc(100% - 17px) center, calc(100% - 12px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.rc-input-sm { padding: 6px 9px; font-size: 13px; }
.rc-input-num { text-align: right; font-variant-numeric: tabular-nums; }
.rc-input-inline { width: 92px; display: inline-block; }
.rc-input.is-bad, .rc-select.is-bad { border-color: var(--rc-bad); }

.rc-field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.rc-field-row > .rc-field { flex: 1 1 160px; margin-bottom: 14px; }

.rc-check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14px; }
.rc-check input[type="checkbox"], .rc-check input[type="radio"] {
  width: 17px; height: 17px; margin-top: 2px; flex: 0 0 auto;
  accent-color: var(--neon); cursor: pointer;
}

/* --- SLIDERS --- */
.rc-slider-field { margin-bottom: 18px; }
.rc-slider-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 7px;
}
.rc-slider-value {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--neon);
  font-variant-numeric: tabular-nums;
}
.rc-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 5px; border-radius: 3px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.rc-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--neon); border: none; cursor: pointer;
  box-shadow: 0 0 12px var(--neon-glow);
}
.rc-range::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--neon); border: none; cursor: pointer;
  box-shadow: 0 0 12px var(--neon-glow);
}
.rc-range:disabled { opacity: .4; cursor: not-allowed; }

/* --- FILL / LEVEL BARS --- */
.rc-bar {
  height: 7px; border-radius: 4px; overflow: hidden;
  background: var(--bg-card-2); border: 1px solid var(--border);
}
.rc-bar-fill { height: 100%; background: var(--neon); transition: width .25s ease; }
.rc-bar-fill.is-warn { background: var(--rc-warn); }
.rc-bar-fill.is-bad  { background: var(--rc-bad); }
.rc-bar-fill.is-ok   { background: var(--rc-ok); }

/* Container fill slider used by calibration */
.rc-fill-visual {
  position: relative;
  width: 100%;
  max-width: 220px;
  height: 190px;
  margin: 0 auto 14px;
  border: 2px solid var(--border-hot);
  border-radius: 10px 10px 16px 16px;
  overflow: hidden;
  background: var(--bg-2);
}
.rc-fill-visual-liquid {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(0,212,255,.55), rgba(0,212,255,.28));
  border-top: 2px solid var(--neon);
  transition: height .2s ease;
}
.rc-fill-visual-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 26px; color: var(--text-bright);
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  pointer-events: none;
}
.rc-fraction-row { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }

/* --- IMAGES --- */
.rc-thumb {
  width: 44px; height: 44px; border-radius: 7px; object-fit: cover;
  background: var(--bg-card-2); border: 1px solid var(--border); flex: 0 0 auto;
}
.rc-thumb-lg { width: 96px; height: 96px; }
.rc-thumb-ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--text-dim);
}
.rc-imgpick { display: flex; align-items: center; gap: 12px; }
.rc-imgpick input[type="file"] { display: none; }

/* --- EMPTY STATE --- */
.rc-empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--rc-radius);
  background: rgba(11,18,37,.4);
}
.rc-empty-icon { font-size: 30px; margin-bottom: 10px; opacity: .75; }
.rc-empty-title { color: var(--text); font-weight: 600; margin-bottom: 5px; font-size: 15px; }
.rc-empty-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* --- MODAL --- */
.rc-modal-root {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(2,4,10,.78);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}
.rc-modal-root[hidden] { display: none; }
.rc-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-hot);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 70px rgba(0,0,0,.6), 0 0 40px var(--neon-glow-s);
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  margin: auto;
}
.rc-modal-wide { max-width: 960px; }
.rc-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rc-line);
  flex: 0 0 auto;
}
.rc-modal-title { font-family: var(--font-display); font-size: 17px; color: var(--text-bright); flex: 1 1 auto; }
.rc-modal-close {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.rc-modal-close:hover { color: var(--neon); background: rgba(0,212,255,.08); }
.rc-modal-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; }
.rc-modal-foot {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--rc-line);
  flex: 0 0 auto;
}

/* --- TOASTS --- */
.rc-toast-root {
  position: fixed; bottom: 20px; right: 20px; z-index: 600;
  display: flex; flex-direction: column; gap: 9px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 40px));
}
.rc-toast {
  background: var(--bg-card-2);
  border: 1px solid var(--border-hot);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  pointer-events: auto;
  animation: rcToastIn .2s ease;
}
.rc-toast.is-ok  { border-left-color: var(--rc-ok); }
.rc-toast.is-bad { border-left-color: var(--rc-bad); }
.rc-toast.is-warn{ border-left-color: var(--rc-warn); }
@keyframes rcToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --- CHARTS --- */
.rc-chart { width: 100%; display: block; overflow: visible; }
.rc-chart-wrap { position: relative; }
.rc-chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rc-chart-title { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 2px; }
.rc-chart-note { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.rc-chart-tip {
  position: fixed;
  z-index: 700;
  pointer-events: none;
  background: var(--bg-card-2);
  border: 1px solid var(--border-hot);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0,0,0,.55);
  max-width: 240px;
  line-height: 1.45;
}
.rc-chart-tip[hidden] { display: none; }
.rc-chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--text-dim); }
.rc-legend-item { display: flex; align-items: center; gap: 6px; }
.rc-legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }

/* --- DISCLAIMER --- */
.rc-disclaimer {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  border-left: 2px solid var(--border-hot);
  padding: 8px 0 8px 12px;
  margin-top: 14px;
}

/* --- LIST ROWS --- */
.rc-listrow {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rc-line);
}
.rc-listrow:last-child { border-bottom: none; }
.rc-listrow-main { flex: 1 1 auto; min-width: 0; }
.rc-listrow-title { color: var(--text-bright); font-weight: 500; }
.rc-listrow-sub { font-size: 12.5px; color: var(--text-dim); }
.rc-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- MISC --- */
.rc-mono { font-variant-numeric: tabular-nums; }
.rc-dim { color: var(--text-dim); }
.rc-bright { color: var(--text-bright); }
.rc-ok-text { color: var(--rc-ok); }
.rc-warn-text { color: var(--rc-warn); }
.rc-bad-text { color: var(--rc-bad); }
.rc-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.rc-divider { height: 1px; background: var(--rc-line); margin: 18px 0; border: none; }
.rc-loading { text-align: center; padding: 40px; color: var(--text-dim); }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .rc-app { padding: 0 18px 70px; }
  .rc-h1 { font-size: 22px; }
  .rc-grid-2, .rc-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .rc-app { padding: 0 14px 60px; font-size: 14.5px; }
  .rc-view-head { flex-direction: column; align-items: stretch; }
  .rc-head-actions .btn { flex: 1 1 auto; text-align: center; }
  .rc-modal-root { padding: 0; align-items: flex-end; }
  .rc-modal { max-width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .rc-grid-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .rc-toast-root { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .rc-firstrun { padding: 20px; }
}

@media (max-width: 420px) {
  .rc-app { padding: 0 11px 50px; }
  .rc-grid-4 { grid-template-columns: 1fr 1fr; }
  .rc-stat-value { font-size: 21px; }
  .rc-tab { padding: 10px 12px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .rc-app *, .rc-modal, .rc-toast { animation: none !important; transition: none !important; }
}
