:root {
    --navy: #1E2761;
    --navy-2: #273572;
    --navy-3: #324384;
    --ice: #CADCFC;
    --bg: #F4F7FE;
    --muted: #5B6B8C;
    --green: #1B7A4B;
    --green-bg: #E4F5EC;
    --amber: #B45309;
    --amber-bg: #FDF2E4;
    --red: #B3261E;
    --red-bg: #FBE9E7;
    --card: #FFFFFF;
    --radius: 14px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--navy);
    line-height: 1.5;
    padding-bottom: 4rem;
  }
  .wrap { max-width: 960px; margin: 0 auto; padding: 0 1rem; }

  header { background: var(--navy); color: #fff; padding: 1.6rem 0 1.9rem; }
  .brand { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .9rem; }
  .brand .logo { font-size: 1.25rem; font-weight: 800; letter-spacing: .02em; }
  .brand .proto { font-size: .72rem; background: var(--navy-3); color: var(--ice); padding: .15rem .55rem; border-radius: 99px; letter-spacing: .06em; }
  header h1 { font-size: clamp(1.35rem, 4vw, 1.9rem); font-weight: 800; max-width: 34ch; }
  header p.sub { color: var(--ice); margin-top: .45rem; font-size: .95rem; max-width: 62ch; }

  main { margin-top: -0.9rem; }
  .card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: 0 3px 14px rgba(30,39,97,.08);
    padding: 1.25rem 1.3rem; margin-bottom: 1.1rem;
  }
  .card h2 { font-size: .8rem; letter-spacing: .12em; color: var(--muted); font-weight: 700; text-transform: uppercase; margin-bottom: .8rem; display: flex; align-items: center; position: relative; }
  .help {
    flex: 0 0 auto; margin-left: auto; width: 1.4rem; height: 1.4rem; border-radius: 50%;
    border: 1.5px solid var(--navy-3); color: var(--navy-3); background: #fff;
    font-weight: 800; font-size: .85rem; padding: 0; line-height: 1; cursor: help;
  }
  .help:hover { background: var(--ice); }
  .tip-pop {
    display: none;
    position: absolute; right: 0; top: 1.9rem; z-index: 30;
    background: var(--navy); color: #fff; padding: .75rem .9rem; border-radius: 10px;
    font-size: .82rem; line-height: 1.5; max-width: 360px;
    box-shadow: 0 8px 24px rgba(30,39,97,.3);
    text-transform: none; letter-spacing: normal; font-weight: 400; text-align: left;
  }
  .help:hover + .tip-pop, .tip-pop:hover, .tip-pop.open { display: block; }
  @media (max-width: 560px) { .tip-pop { max-width: 82vw; } }

  /* verdict */
  #verdict { border-left: none; }
  .verdict-line { display:flex; gap: .75rem; align-items: flex-start; padding: .8rem .9rem; border-radius: 10px; margin-bottom: .6rem; }
  .verdict-line:last-child { margin-bottom: 0; }
  .verdict-line .dot { flex: 0 0 auto; width: .95rem; height: .95rem; border-radius: 50%; margin-top: .3rem; }
  .verdict-line h3 { font-size: 1rem; font-weight: 700; }
  .verdict-line p { font-size: .88rem; margin-top: .15rem; }
  .v-ok   { background: var(--green-bg); } .v-ok .dot { background: var(--green);} .v-ok h3 { color: var(--green); }
  .v-warn { background: var(--amber-bg); } .v-warn .dot { background: var(--amber);} .v-warn h3 { color: var(--amber); }
  .v-over { background: var(--red-bg); } .v-over .dot { background: var(--red);} .v-over h3 { color: var(--red); }
  .v-info { background: var(--bg); } .v-info .dot { background: var(--muted);} .v-info h3 { color: var(--navy); }

  /* meters */
  .meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
  .meter h3 { font-size: .85rem; font-weight: 700; display: flex; justify-content: space-between; }
  .meter h3 .val { font-variant-numeric: tabular-nums; }
  .bar { height: .65rem; background: #E4EAF7; border-radius: 99px; margin: .45rem 0 .3rem; overflow: hidden; }
  .bar > div { height: 100%; border-radius: 99px; transition: width .4s; }
  .bar .ok { background: var(--green); } .bar .warn { background: var(--amber); } .bar .over { background: var(--red); }
  .meter small { color: var(--muted); font-size: .78rem; }

  /* tax */
  .tax-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; text-align: center; }
  .tax-box { background: var(--bg); border-radius: 10px; padding: .9rem .6rem; }
  .tax-box .big { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
  .tax-box.hl { background: var(--navy); color: #fff; }
  .tax-box.hl small { color: var(--ice); }
  .tax-box small { display: block; color: var(--muted); font-size: .76rem; margin-top: .15rem; }

  /* actions */
  #actions li { list-style: none; display: flex; gap: .6rem; padding: .45rem 0; font-size: .92rem; align-items: flex-start; }
  #actions li::before { content: "→"; font-weight: 800; color: var(--amber); flex: 0 0 auto; }
  #actions li.done::before { content: "✓"; color: var(--green); }

  /* form */
  form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: .7rem; }
  label { font-size: .74rem; font-weight: 700; color: var(--muted); display: block; margin-bottom: .2rem; }
  input, select, textarea, button {
    font: inherit; border: 1.5px solid #D7E0F5; border-radius: 8px;
    padding: .5rem .6rem; width: 100%; background: #fff; color: var(--navy);
  }
  input:focus, select:focus, textarea:focus { outline: 2px solid var(--ice); border-color: var(--navy-3); }
  button { cursor: pointer; font-weight: 700; width: auto; padding: .55rem 1.1rem; }
  .btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
  .btn-ghost { background: #fff; color: var(--navy); }
  .btn-sm { padding: .3rem .7rem; font-size: .8rem; }
  .btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
  textarea { min-height: 90px; font-size: .85rem; }
  details { margin-top: .8rem; }
  summary { cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--navy-3); }

  /* table */
  table { width: 100%; border-collapse: collapse; font-size: .85rem; }
  th, td { padding: .45rem .5rem; text-align: left; border-bottom: 1px solid #E4EAF7; }
  th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .pill { font-size: .7rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; white-space: nowrap; }
  .pill.ex { background: var(--green-bg); color: var(--green); }
  .pill.tx { background: var(--amber-bg); color: var(--amber); }
  .pill.hm { background: #EDE7F6; color: #5E35B1; }
  .del { background: none; border: none; color: var(--red); font-weight: 800; padding: 0 .4rem; }
  td input.ed, td select.ed { padding: .25rem .35rem; font-size: .83rem; border-width: 1px; background: transparent; }
  td input.ed:hover, td select.ed:hover { background: #fff; border-color: var(--navy-3); }
  td input.ed[type="date"] { width: 8.6rem; }
  td input.ed[type="number"] { width: 5.6rem; text-align: right; }
  td select.ed { width: auto; }
  .import-hint { font-size: .8rem; color: var(--muted); margin: .35rem 0 .5rem; }
  .or-sep { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .08em; margin: 1rem 0 .7rem; text-transform: uppercase; }
  .or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: #D7E0F5; }
  .empty { color: var(--muted); font-size: .88rem; text-align: center; padding: 1rem 0; }

  footer { margin-top: 1.6rem; color: var(--muted); font-size: .76rem; }
  footer .wrap { border-top: 1px solid #D7E0F5; padding-top: 1rem; }
  .settings { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
  .settings input { width: 5.2rem; padding: .25rem .45rem; font-size: .85rem; }
  @media (max-width: 560px) { .card { padding: 1rem .9rem; } }

/* ---- mobile polish & sticky summary (R1 hardening) ---- */
#sticky-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: var(--navy); color: #fff;
  display: none; align-items: center; gap: .6rem;
  padding: .5rem .95rem; font-size: .85rem;
  box-shadow: 0 2px 12px rgba(30, 39, 97, .35);
}
#sticky-bar.show { display: flex; }
#sticky-bar .dot { width: .8rem; height: .8rem; border-radius: 50%; flex: 0 0 auto; }
#sticky-bar .dot.ok { background: var(--green); }
#sticky-bar .dot.warn { background: var(--amber); }
#sticky-bar .dot.over { background: var(--red); }
#sticky-bar .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
#sticky-bar .tax { margin-left: auto; color: var(--ice); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 560px) {
  input, select, textarea { min-height: 44px; }          /* comfortable touch targets */
  .btn-row button { flex: 1 1 auto; min-height: 44px; }  /* full-width tap buttons */
  td input.ed, td select.ed { min-height: 38px; }
  th, td { padding: .45rem .35rem; }
}

footer nav { margin-bottom: .6rem; font-size: .82rem; }
footer nav a { color: var(--navy-3); font-weight: 700; text-decoration: none; margin-right: 1rem; }
footer nav a:hover { text-decoration: underline; }
