/* OGPS brand colors, matching the palette sampled from the logo for
   Quartermaster: charcoal #3C4548, teal #79B4AE, cream #F8F7E9,
   forest green #498258, burnt orange #D26E3D. */
:root {
  color-scheme: dark;  /* tells the browser this surface is dark, so native
                           controls (number-input spinners, checkboxes,
                           scrollbars) render in light-on-dark by default --
                           without this, some browsers render dark-on-dark
                           spinner arrows that are invisible against our
                           equally-dark input backgrounds */
  --bg: #1E2224;
  --panel: #2A3033;
  --ink: #F8F7E9;
  --muted: #A9B3B1;
  --line: #3C4548;
  --accent: #D26E3D;
  --teal: #79B4AE;
  --good: #6FBF83;
  --good-bg: rgba(73, 130, 88, 0.25);
  --bad: #E0685C;
  --bad-bg: rgba(224, 104, 92, 0.18);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 2px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.5px; }
.brand img { height: 36px; width: 36px; border-radius: 50%; }

.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.topbar nav a:hover { color: var(--teal); }
.reset-form { display: inline; }
.reset-form button {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; color: var(--muted); cursor: pointer;
}

main { max-width: 1400px; margin: 24px auto; padding: 0 20px 90px; }

.workspace {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
}
.load-panel { position: sticky; top: 16px; }
.sizing-panel fieldset:last-child { margin-bottom: 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .load-panel { position: static; }
}

.recalc-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--panel);
  border-top: 2px solid var(--line);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.25);
}
.live-status {
  margin-right: auto;
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.2s;
}
.live-status-pulse { color: var(--teal); }

.remove-row-btn {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 6px;
}
.remove-row-btn:hover { color: var(--bad); }

.toggle-cell { text-align: center; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--line); border-radius: 999px; transition: background 0.15s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 14px; width: 14px; left: 2px; bottom: 2px;
  background: var(--ink); border-radius: 50%; transition: transform 0.15s;
}
.switch input:checked + .slider { background: var(--good); }
.switch input:checked + .slider::before { transform: translateX(16px); }

tr.row-disabled { opacity: 0.45; }
tr.row-disabled .row-total-w, tr.row-disabled .row-total-wh { text-decoration: line-through; }

.auth-card {
  max-width: 380px; margin: 60px auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 28px 30px;
}
.auth-card h1 { margin-bottom: 4px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 6px; }
.auth-brand img { height: 90px; width: 90px; }
.auth-brand h1 { margin: 0; text-transform: uppercase; letter-spacing: 0.5px; }
.auth-card form, .stacked-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.auth-card label, .stacked-form label {
  display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted);
}
.auth-card input, .stacked-form input[type="text"], .stacked-form input[type="password"] {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.95rem;
  background: var(--bg); color: var(--ink);
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 6px !important; }

.form-error { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; }
.form-success { color: var(--good); background: var(--good-bg); padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; }

.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-fields { flex-direction: row !important; flex-wrap: wrap; align-items: flex-end; }
.inline-fields label { min-width: 160px; }

button.danger { border-color: var(--bad); color: var(--bad); }
button.danger:hover { background: var(--bad-bg); }

.section-spacer { margin-top: 28px; }

.project-card { margin-bottom: 18px; }
.project-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.project-header h2 { margin: 0; flex: 1; }
.owner-tag { font-size: 0.8rem; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.version-actions { display: flex; gap: 8px; }

.view-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.view-filter a {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 0.88rem;
}
.view-filter a.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

h1 { font-size: 1.6rem; margin-bottom: 4px; color: var(--ink); }
h2 { font-size: 1.15rem; margin: 0 0 10px; color: var(--ink); }

.hint { color: var(--muted); font-size: 0.9rem; margin-top: 0; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }

.table-scroll { overflow-x: auto; }
.load-table {
  table-layout: fixed;   /* explicit colgroup widths, not browser guesswork --
                             auto-layout sized columns differently enough
                             across Safari/Chrome/Firefox to clip content */
  min-width: 820px;      /* below this, scroll horizontally rather than squeeze */
}

.load-table input, .load-table select {
  width: 100%; padding: 4px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 4px;
}
.load-table .readout { color: var(--teal); text-align: right; font-weight: 600; }
.load-table tfoot th, .load-table tfoot td { border-top: 2px solid var(--accent); font-weight: 600; }
.subtotal td { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.load-notes-row td { padding-top: 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.notes-input {
  width: 100%; resize: vertical; min-height: 54px; padding: 6px 8px;
  line-height: 1.4;   /* Safari clips a textarea's text without an explicit
                          line-height -- its row-height calculation doesn't
                          match the rendered font metrics, sometimes enough
                          to trigger its own scrollbar and crop the line */
  background: var(--bg); color: var(--muted); border: 1px dashed var(--line);
  border-radius: 4px; font-family: inherit; font-size: 0.85rem;
}
.notes-input:focus { color: var(--ink); border-style: solid; }

.report .notes-row td { color: var(--muted); font-style: italic; font-size: 0.9rem; border-top: none; }
.report .excluded-row td { color: var(--muted); text-decoration: line-through; }
.report .excluded-row.notes-row td { text-decoration: none; } /* keep the note itself readable */
.excluded-tag { font-style: italic; text-decoration: none; font-size: 0.85em; }

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: var(--panel);
}
fieldset.toggle-fieldset { background: var(--panel); }
legend { font-weight: 600; padding: 0 6px; color: var(--teal); }
legend label { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--teal); }

fieldset label {
  display: inline-block;
  margin: 6px 16px 6px 0;
  font-size: 0.9rem;
  color: var(--muted);
}
fieldset label input, fieldset label select {
  display: block;
  margin-top: 2px;
  padding: 4px 6px;
  width: 160px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
fieldset label input[readonly] {
  color: var(--teal);
  background: var(--panel);
  border-style: dashed;
}

.readout-line { margin-top: 8px; font-size: 0.92rem; color: var(--ink); }
.readout-line.big { font-size: 1.05rem; }
.readout-line strong { color: var(--teal); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

.load-summary {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; margin-bottom: 16px; font-size: 0.95rem;
}

.actions { margin-top: 16px; display: flex; gap: 10px; }
button, .button-link {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-size: 0.95rem; text-decoration: none;
  color: var(--ink); display: inline-block;
}
button.primary, .button-link.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

.meta-form {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
}
.meta-form input, .meta-form textarea {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink);
}
.meta-form input { flex: 1 1 200px; }
.meta-form textarea { flex: 1 1 100%; min-height: 50px; }

.report { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; }
.report-header h1 { margin-bottom: 12px; }
.meta-table th { width: 90px; color: var(--muted); font-weight: 600; }
.report section { margin: 22px 0; }
.report-table.kv th { width: 240px; color: var(--muted); font-weight: 600; }
.notes { white-space: pre-wrap; color: var(--muted); }

.verdict { border-radius: 8px; padding: 16px 20px; margin: 18px 0; }
.verdict-good { background: var(--good-bg); color: var(--good); }
.verdict-bad { background: var(--bad-bg); color: var(--bad); }
.verdict h2 { margin: 0 0 4px; color: inherit; }
.verdict p { margin: 0; }

.report-pdf { border: none; padding: 0; }

/* The PDF is rendered by WeasyPrint straight to paper, so it stays on a
   light background for print/readability even though the app UI is dark. */
.report-pdf, .report-pdf * {
  background: #fff !important;
  color: #1b2430 !important;
}
.report-pdf .verdict-good { background: #e6f4ea !important; color: #1a7f37 !important; }
.report-pdf .verdict-bad { background: #fbe9e7 !important; color: #b3261e !important; }
.report-pdf th, .report-pdf td { border-bottom: 1px solid #d9dee3 !important; }

@media print {
  .topbar, .meta-form { display: none; }
  main { max-width: 100%; margin: 0; padding: 0; }
  .report, body { background: #fff !important; color: #1b2430 !important; }
}
