  :root {
    --paper: #f2efe6;
    --card: #fffdf8;
    --ink: #232b1f;
    --muted: #6d7364;
    --line: #ddd6c4;
    --field: #faf7ee;
    --green: #2f5d36;
    --green-deep: #24482a;
    --green-soft: #e6efdf;
    --amber: #8f5e09;
    --amber-soft: #faf0d7;
    --red: #b13328;
    --red-soft: #fbe9e5;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    background: var(--paper);
    background-image: radial-gradient(circle at 15% -10%, #e9ecdd 0%, transparent 45%);
    color: var(--ink);
    line-height: 1.45;
  }

  .wrap { max-width: 1180px; margin: 0 auto; padding: 34px 24px 56px; }

  /* ===== Masthead ===== */
  .overline {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--green); margin-bottom: 7px;
  }
  h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px;
  }
  h1 .ver {
    font-size: 0.8rem; font-weight: 700; color: var(--green);
    background: var(--green-soft); border-radius: 999px; padding: 3px 10px;
    vertical-align: middle; margin-left: 8px; letter-spacing: 0.04em;
  }
  .subtitle { color: var(--muted); font-size: 0.95rem; max-width: 62ch; }
  .rule { height: 3px; background: var(--green); width: 64px; margin: 18px 0 22px; border-radius: 2px; }

  /* ===== Tabs ===== */
  .tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
  .tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--card); cursor: pointer; font-size: 0.88rem; font-weight: 600;
    color: var(--muted); transition: border-color 120ms ease, color 120ms ease;
  }
  .tab:hover { border-color: var(--green); color: var(--green); }
  .tab.active { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
  .tab .tab-x {
    border: none; background: none; cursor: pointer; font-size: 0.85rem;
    color: inherit; opacity: 0.55; padding: 0; line-height: 1;
  }
  .tab .tab-x:hover { opacity: 1; }
  .tab-add { border-style: dashed; color: var(--green); background: transparent; }

  /* ===== Layout ===== */
  .layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-areas: "input side" "contrib side";
    gap: 20px; align-items: start;
  }
  .area-input   { grid-area: input; }
  .area-side    { grid-area: side; }
  .area-contrib { grid-area: contrib; }
  @media (max-width: 960px) {
    .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "input" "side" "contrib"; }
    .side-inner { position: static !important; box-shadow: none !important; }
  }

  /* ===== Panels ===== */
  .panel {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; padding: 20px;
  }
  .panel-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
  }
  .panel-head h2, .panel > h2 {
    font-family: Georgia, serif; font-size: 1.15rem; font-weight: 600;
  }
  .hint, .contrib-note { color: var(--muted); font-size: 0.8rem; }
  .side-inner { position: sticky; top: 20px; box-shadow: 0 12px 32px rgba(36, 60, 41, 0.10); }

  /* ===== Input table ===== */
  .table-wrap { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-size: 0.87rem; }
  th, td {
    padding: 7px 9px; border-bottom: 1px solid var(--line);
    white-space: nowrap; text-align: left;
  }
  thead th {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--muted); border-bottom-width: 2px;
  }
  tbody tr:nth-child(even) { background: #f7f4ea; }
  td.num, th.num { text-align: right; }
  td input {
    width: 82px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
    font-size: 0.87rem; background: var(--field); text-align: right;
    font-variant-numeric: tabular-nums;
    transition: border-color 100ms ease, background 100ms ease;
  }
  td input:focus {
    outline: none; border-color: var(--green); background: #fff;
    box-shadow: 0 0 0 3px var(--green-soft);
  }
  td input.name { width: 190px; text-align: left; }
  td input.em { width: 102px; }
  td input.neg { border-color: var(--red); background: var(--red-soft); }

  .row-btn {
    border: none; background: none; cursor: pointer; font-size: 0.9rem;
    padding: 4px 6px; border-radius: 6px; color: var(--muted);
  }
  .row-btn:hover { background: var(--green-soft); color: var(--green); }
  .row-del { color: var(--red); }
  .row-del:hover { background: var(--red-soft); color: var(--red); }

  .lib-hint { margin-top: 10px; font-size: 0.76rem; color: var(--muted); }

  /* ===== Inklusi meter ===== */
  .meter-block { margin-top: 14px; }
  .meter-top { display: flex; justify-content: space-between; font-size: 0.83rem; color: var(--muted); margin-bottom: 6px; }
  .meter-top strong { font-variant-numeric: tabular-nums; color: var(--ink); }
  .meter { height: 8px; border-radius: 4px; background: var(--green-soft); overflow: hidden; }
  .meter span {
    display: block; height: 100%; width: 0; border-radius: 4px;
    background: var(--amber); transition: width 160ms ease, background 160ms ease;
  }
  .meter span.ok { background: var(--green); }

  .banner {
    margin-top: 12px; padding: 9px 13px; border-radius: 9px;
    font-size: 0.84rem; border: 1px solid transparent; line-height: 1.4;
  }
  .banner.warn { background: var(--amber-soft); color: var(--amber); border-color: #ecd7a4; }
  .banner.good { background: var(--green-soft); color: var(--green-deep); border-color: #cadcca; }
  .banner.bad  { background: var(--red-soft); color: var(--red); border-color: #f0c4bc; }

  /* ===== Buttons ===== */
  .btn {
    padding: 7px 14px; border: 1px solid var(--line); border-radius: 9px;
    background: var(--card); cursor: pointer; font-size: 0.85rem; font-weight: 600;
    color: var(--ink); transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
  }
  .btn:hover { border-color: var(--green); color: var(--green); }
  .btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
  .btn-primary:hover { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }
  .actions { display: flex; gap: 8px; flex-wrap: wrap; }

  /* ===== Totals sidebar ===== */
  .stat-row { display: block; padding: 11px 0; border-bottom: 1px solid var(--line); }
  .stat-row:last-child { border-bottom: none; }
  .stat-row.is-ok dd   { color: var(--green-deep); }
  .stat-row.is-low dd  { color: var(--red); }
  .stat-row.is-warn dd { color: var(--amber); }
  .stat-top { display: flex; justify-content: space-between; align-items: baseline; }
  .stat-top dt { font-size: 0.86rem; color: var(--muted); font-weight: 600; }
  .stat-top dt .unit { font-weight: 400; font-size: 0.78rem; margin-left: 4px; }
  .stat-top dd { font-family: Georgia, serif; font-size: 1.45rem; font-variant-numeric: tabular-nums; }
  .stat-ref { margin-top: 5px; display: flex; gap: 8px; align-items: center; font-size: 0.72rem; }
  .badge {
    font-size: 0.68rem; font-weight: 700; padding: 2px 8px;
    border-radius: 999px; white-space: nowrap;
  }
  .badge.ok      { background: var(--green-soft); color: var(--green-deep); }
  .badge.low     { background: var(--red-soft);   color: var(--red); }
  .badge.warn    { background: var(--amber-soft); color: var(--amber); }
  .badge.neutral { background: #ececea;           color: var(--muted); }
  .ref-txt { color: var(--muted); line-height: 1.3; }
  .formula {
    margin-top: 14px; padding-top: 12px; border-top: 2px dotted var(--line);
    font-size: 0.78rem; color: var(--muted);
  }
  .formula code { font-family: Consolas, monospace; font-size: 0.78rem; color: var(--green-deep); }

  .c-ok   { color: var(--green-deep); }
  .c-warn { color: var(--amber); }
  .c-low  { color: var(--red); }

  .prediksi { margin-top: 14px; padding: 13px 14px; border-radius: 11px; border: 1px dashed var(--line); background: #f8f5ea; }
  .prediksi .lbl { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
  .prediksi .row-line { display: flex; justify-content: space-between; font-size: 0.84rem; }
  .prediksi .main-val { font-family: Georgia, serif; font-size: 1.2rem; }

  .side-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }

  /* ===== Literature & hasil ===== */
  .lit-list { margin: 4px 0 0; padding-left: 20px; }
  .lit-list li { font-size: 0.82rem; margin-bottom: 9px; line-height: 1.45; }
  .lit-list li .src { color: var(--muted); }
  .lit-list a { color: var(--green); }

  /* ===== Uji data penelitian ===== */
  .uji-h { font-family: Georgia, serif; font-size: 0.98rem; margin: 14px 0 8px; }
  .uji-note { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }
  .uji-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
  .uji-controls label { font-size: 0.82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
  input.uji-num, select.uji-dec {
    width: 64px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px;
    font-size: 0.82rem; background: var(--field); text-align: right;
    font-variant-numeric: tabular-nums;
  }
  select.uji-dec { text-align: left; }
  input.uji-num:focus, select.uji-dec:focus, input.uji-nama:focus, input.uji-unit:focus {
    outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
  }
  .uji-var { border: 1px solid var(--line); border-radius: 11px; padding: 14px 14px 10px; margin-top: 14px; background: #fdfbf4; }
  .uji-var-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
  input.uji-nama {
    width: 210px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
    font-size: 0.9rem; font-weight: 600; background: var(--field); font-family: Georgia, serif;
  }
  input.uji-unit {
    width: 110px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
    font-size: 0.82rem; background: var(--field); color: var(--muted);
  }
  .uji-var td input { width: 88px; }
  .uji-ket { margin-top: 8px; font-size: 0.8rem; }

  footer {
    margin-top: 26px; text-align: center; font-size: 0.76rem; color: var(--muted);
  }
