:root {
  --bg: #0f1217;
  --bg2: #161b23;
  --card: #1b2130;
  --card2: #202839;
  --line: #2b3548;
  --text: #e8edf5;
  --muted: #98a4b8;
  --accent: #f5a524;
  --accent2: #ffc85c;
  --good: #3fd08a;
  --warn: #ffb454;
  --bad: #ff6b6b;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--body);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.4; font-family: var(--body); }
a { color: var(--accent2); }
code { background: var(--bg2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
h1 { font-family: var(--display); font-size: 1.7rem; margin: 0; letter-spacing: .5px; text-transform: uppercase; font-weight: 700; line-height: 1; }
h2 { font-family: var(--display); font-size: 1.3rem; margin: 0; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
h3 { font-family: var(--display); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
table, .stat .v, .num, .pill { font-variant-numeric: tabular-nums; }
small { color: var(--muted); font-size: .8rem; display: block; margin-top: 4px; }
.hint { color: var(--muted); font-size: .85rem; }
.unit { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: linear-gradient(180deg, #151a23, #10141b);
  border-bottom: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 1.9rem; }
.sub { color: var(--muted); font-size: .8rem; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 60px; display: grid; gap: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; }

.grid.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px 22px; }
.field > span:first-child, .lf > span { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.field.check { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.field.check > span { text-transform: none; letter-spacing: 0; color: var(--text); font-size: .95rem; margin: 0; }
.field.check small { flex-basis: 100%; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.gap { gap: 16px; flex-wrap: wrap; margin-top: 12px; }

input[type=range] { flex: 1; accent-color: var(--accent); min-width: 110px; }
.num, .sel {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: .95rem; min-width: 0;
}
.num { width: 110px; }
.num.small { width: 78px; }
.sel { max-width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 14px; cursor: pointer; font-size: .92rem; transition: background .15s, transform .05s;
}
.btn:hover { background: #283245; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #1a1200; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 10px; font-size: .8rem; }
.btn.icon { padding: 6px 10px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg { background: transparent; color: var(--muted); border: 0; padding: 8px 14px; cursor: pointer; }
.seg.active { background: var(--accent); color: #1a1200; font-weight: 600; }
.pill { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: .8rem; color: var(--accent2); }

.presets { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* lines */
.lines { display: grid; gap: 10px; }
.line { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.line-main { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.lf { display: flex; flex-direction: column; }
.lf.grow { flex: 1 1 260px; }
.lf .sel { width: 100%; }
.stepper { display: flex; align-items: center; }
.stepper button { width: 34px; height: 36px; background: var(--bg2); color: var(--text); border: 1px solid var(--line); cursor: pointer; font-size: 1.1rem; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper .num { border-radius: 0; text-align: center; width: 64px; }
.line-info { margin-top: 8px; color: var(--muted); font-size: .85rem; display: flex; gap: 14px; flex-wrap: wrap; }
.line-info b { color: var(--text); font-weight: 600; }
.line-info .ok { color: var(--good); }
.line-info .low { color: var(--warn); }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

/* summary */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .6px; }
.stat .v { font-family: var(--display); font-size: 1.7rem; font-weight: 700; margin-top: 2px; color: var(--accent2); line-height: 1.1; }
.stat .s { color: var(--muted); font-size: .78rem; margin-top: 2px; }

.warnings:empty { display: none; }
.warn { background: #2a2416; border: 1px solid #6b5220; color: #ffd98a; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: .9rem; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 12px; flex-wrap: wrap; }
.tab { background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; font-size: .95rem; }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; background: var(--card); }
th:first-child, td:first-child { text-align: left; }
td.l, th.l { text-align: left; }
tr.total td { font-weight: 700; color: var(--accent2); border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.importer { margin-bottom: 18px; }
.importer h3 { margin: 6px 0 8px; font-size: 1rem; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.importer h3 .addr { color: var(--muted); font-weight: 400; font-size: .85rem; }
.copy { margin-left: auto; }
.recipe-card { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.recipe-card h4 { margin: 0 0 4px; font-size: .95rem; }
.recipe-card ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }

.notes ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.notes li { margin-bottom: 6px; }
footer { color: var(--muted); font-size: .8rem; text-align: center; padding-top: 8px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #1a1200; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); z-index: 50; }

/* mode */
body.simple .adv-only { display: none !important; }

@media (max-width: 640px) {
  .top { padding: 10px 12px; }
  main { padding: 12px 10px 50px; }
  .card { padding: 12px; }
  .stat .v { font-size: 1.15rem; }
}
