/* Reusable pieces: cards, fields, chips, badges, tables, result boxes, modal, help text. */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 26px; margin-bottom: 16px; box-shadow: var(--shadow); scroll-margin-top: 86px;
}
.card > h2 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.2px; }
.card > h2 .n {
  background: var(--ink); color: #fff; border-radius: 10px; min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800;
}
.card > .desc { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; max-width: 90ch; }

.grid { display: grid; gap: 14px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.setgrid { display: grid; gap: 13px 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 188px)); justify-content: start; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px 18px; margin: 0 0 16px; background: var(--soft); }
fieldset legend { padding: 0 8px; color: var(--teal-d); font-weight: 800; font-size: 13px; }
.row2 { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row2 .fld { flex: 1; min-width: 150px; max-width: 380px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

.filebox { display: block; border: 2px dashed var(--teal); border-radius: 14px; padding: 20px; text-align: center; background: var(--soft); cursor: pointer; transition: background .15s, border-color .15s; }
.filebox.has-file { padding: 12px 16px; border-style: solid; border-width: 1.5px; }
.filebox.has-file .muted { display: none; }
.filebox:hover, .filebox.is-over { background: var(--chip); }
.filebox .title { font-size: 15px; font-weight: 700; color: var(--teal-d); }

.note { background: var(--soft); border: 1px solid var(--line); border-inline-start: 3px solid var(--teal); border-radius: 11px; padding: 11px 15px; font-size: 12.5px; margin-top: 12px; }
.note.formula { white-space: pre-line; font-family: Consolas, "Courier New", monospace; line-height: 2; text-align: left; color: var(--teal-d); direction: ltr; unicode-bidi: isolate; }

/* chips + badges */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--chip); color: var(--teal-d); border-radius: 20px; padding: 5px 13px; font-size: 12px; font-weight: 600; }
.chip b { font-weight: 800; }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.badge { border-radius: 20px; padding: 3px 11px; font-weight: 700; font-size: 11.5px; display: inline-block; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-bad { color: var(--warn); background: var(--warn-bg); }
.b-amber { color: var(--amber); background: var(--amber-bg); }
.exchip { display: inline-flex; gap: 6px; align-items: center; background: var(--amber-bg); color: var(--amber); border: 0; border-radius: 9px; padding: 4px 10px; font-size: 12px; font-weight: 600; margin: 0 0 4px 6px; }
.exchip b { color: var(--ink); }
.exclbar { margin-bottom: 12px; }
.exclbar .head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; margin-bottom: 8px; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
.tablewrap.tall { max-height: min(68vh, 620px); overflow-y: auto; }
.tablewrap.tall thead th { position: sticky; top: 0; z-index: 2; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--soft2); font-weight: 700; font-size: 12.5px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--soft); }
/* the include column stays visible when a wide table scrolls */
th.colend, td.colend { position: sticky; inset-inline-end: 0; z-index: 1; box-shadow: 6px 0 8px -6px rgba(15, 39, 71, .1); }
th.colend { background: var(--soft2); z-index: 3; }
td.colend { background: var(--card); }
.tablewrap.tall thead th.colend { z-index: 4; }
tr:hover td.colend, tr.control td.colend { background: var(--soft); }
tr.rowexcl td.colend { background: #f2f1f6; }
td.name { font-weight: 800; }
td.final { font-weight: 800; color: var(--teal-d); font-size: 15px; }
td.vol { font-weight: 800; font-size: 15px; }
td.cvbad { background: var(--warn-bg); color: var(--warn); font-weight: 800; }
td.wcell { cursor: pointer; }
td.wcell:hover { background: var(--chip); }
td .struck { text-decoration: line-through; opacity: .55; }
tr.control td { color: var(--muted); background: var(--soft); font-style: italic; }
tr.rowexcl td { opacity: .5; background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(120, 120, 140, .05) 6px, rgba(120, 120, 140, .05) 12px); }
tr.rowexcl td.name { opacity: .75; }
.dropnote { color: var(--accent); font-size: 12px; }

/* editable dilution cells */
input.cellinput { width: 76px; padding: 5px 7px; font-size: 13.5px; border: 1.5px solid #d3dcec; border-radius: 8px; font-weight: 600; }
td.editcell { background: rgba(14, 154, 167, .05); }
td.editcell.edited { background: rgba(214, 69, 111, .07); }
th.editcol { color: var(--teal-d); }
.achok { color: var(--ok); font-weight: 800; }
.achwarn { color: var(--amber); font-weight: 800; }

/* loading calculator results */
.resultbox { background: var(--soft); border: 1px solid var(--line); border-radius: 15px; padding: 16px; text-align: center; }
.resultbox .lbl { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.resultbox .big { font-size: 30px; font-weight: 800; color: var(--teal-d); line-height: 1.1; }
.resultbox .un { color: var(--muted); font-size: 12px; }

.chart { margin-bottom: 14px; }
.chart svg { width: 100%; max-width: 640px; height: auto; display: block; }

/* exclusion-reason dialog */
.modal { position: fixed; inset: 0; background: rgba(17, 18, 24, .5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal .box { background: #fff; border-radius: 18px; padding: 22px 22px 18px; width: min(440px, 100%); box-shadow: 0 18px 50px rgba(20, 22, 45, .3); }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .row { display: flex; gap: 10px; margin-top: 14px; }

/* help text */
.help h3 { color: var(--teal-d); font-size: 16px; margin: 20px 0 6px; }
.help p, .help li { font-size: 14px; line-height: 1.75; }
.help .f { background: var(--chip); color: var(--teal-d); border-radius: 7px; padding: 2px 8px; font-size: 13px; unicode-bidi: isolate; direction: ltr; display: inline-block; font-weight: 600; }
.help ul, .help ol { margin: 6px 0; padding-inline-start: 22px; }
.help ol li { margin-bottom: 4px; }
