/* PropTool — shared stylesheet
   Light theme, engineering-clean. Inspired by ZEMAX/CODE V clarity conventions:
   high-contrast text (no greyed-out "disabled-looking" labels), clear sectioning. */
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1c2430;
  --ink-strong: #0b1118;
  --muted: #34465c;            /* secondary text — dark enough to read clearly, never "disabled-looking" */
  --line: #d6dee8;
  --accent: #0a6cbd;           /* primary blue */
  --accent-2: #0e7a5f;         /* secondary green (OK) */
  --warn: #b8860b;
  --bad: #c0392b;
  --ok-bg: #e7f6ef;
  --warn-bg: #fdf3e0;
  --bad-bg: #fbeae8;
  --shadow: 0 1px 3px rgba(20,30,45,.08), 0 6px 18px rgba(20,30,45,.06);
  --radius: 10px;
  --header-h: 116px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial,
               "Microsoft YaHei", "Noto Sans CJK SC", "Malgun Gothic", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(180deg, #0c2233 0%, #0a1c2b 100%);
  color: #eef4fb;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.header-top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 18px;
}
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.brand .logo { font-weight: 800; font-size: 20px; letter-spacing: .5px; color: #fff; }
.brand .sub { font-size: 12px; color: #9fb6cc; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 7px;
  padding: 8px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-home { background: #1f8a4c; color: #fff; }
.btn-home:hover { background: #186f3d; text-decoration: none; }
.btn-email { background: transparent; color: #cfe6ff; border-color: #2f6f9e; }
.btn-email:hover { background: #13405f; text-decoration: none; }
.lang-wrap { display: flex; align-items: center; gap: 6px; }
.lang-wrap label { font-size: 12px; color: #9fb6cc; }
#langSelect {
  background: #102a3d; color: #eef4fb; border: 1px solid #2f6f9e;
  border-radius: 7px; padding: 7px 8px; font-size: 13px; cursor: pointer;
}
/* unit toggle */
.unit-wrap {
  display: inline-flex; border: 1px solid #2f6f9e; border-radius: 7px; overflow: hidden;
}
.unit-btn {
  background: #102a3d; color: #cfe0ef; border: none; padding: 8px 11px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.unit-btn + .unit-btn { border-left: 1px solid #2f6f9e; }
.unit-btn.active { background: var(--accent); color: #fff; }
/* ---------- Nav ---------- */
.site-nav {
  display: flex; gap: 2px; flex-wrap: wrap;
  padding: 0 12px 8px; background: #0a1c2b;
}
.site-nav a {
  color: #cfe0ef; font-size: 13px; padding: 7px 12px; border-radius: 6px; font-weight: 600;
}
.site-nav a:hover { background: #16364f; text-decoration: none; }
.site-nav a.active { background: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.page-title { font-size: 24px; font-weight: 800; color: var(--ink-strong); margin: 4px 0 2px; }
.page-desc { color: var(--muted); margin: 0 0 18px; max-width: 760px; }
.disclaimer {
  background: #fff7e6; border: 1px solid #f0d294; color: #6b4e07;
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin: 0 0 18px;
}

/* ---------- Cards / grid ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.grid { display: grid; gap: 16px; }
.cards-home { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.home-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; transition: transform .12s, border-color .12s;
  display: flex; flex-direction: column; gap: 6px;
}
.home-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.home-card h3 { margin: 0; font-size: 16px; color: var(--ink-strong); }
.home-card p { margin: 0; color: var(--muted); font-size: 13px; }
.home-card .go { margin-top: 6px; color: var(--accent); font-weight: 700; font-size: 13px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.schema-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.schema-row { display: flex; flex-direction: column; gap: 5px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.schema-row strong { font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.schema-row input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--muted); }
.field input, .field select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; background: #fff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.primary { background: var(--accent); color: #fff; border: none; padding: 11px 18px; font-size: 14px; font-weight: 700; }
.primary:hover { background: #085a9c; }
.secondary { background: #eef2f7; color: var(--ink); border: 1px solid var(--line); padding: 11px 18px; font-size: 14px; font-weight: 600; }
.secondary:hover { background: #e2e8f0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- Results ---------- */
.results { margin-top: 18px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.result-item {
  background: #f8fafc; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 12px;
}
.result-item .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.result-item .v { font-size: 18px; font-weight: 800; color: var(--ink-strong); margin-top: 2px; }
.result-item .u { font-size: 12px; color: var(--muted); font-weight: 500; }
/* Status badges — unambiguous OK / WARN / CRIT semantics (ZEMAX/CODE V style) */
.status-ok { color: var(--accent-2); font-weight: 800; background: var(--ok-bg); padding: 1px 8px; border-radius: 5px; }
.status-warn { color: #8a6304; font-weight: 800; background: var(--warn-bg); padding: 1px 8px; border-radius: 5px; }
.status-bad { color: #a3271b; font-weight: 800; background: var(--bad-bg); padding: 1px 8px; border-radius: 5px; }
/* Standalone status badge component */
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 6px; }
.badge-ok { color: var(--accent-2); background: var(--ok-bg); }
.badge-warn { color: #8a6304; background: var(--warn-bg); }
.badge-bad { color: #a3271b; background: var(--bad-bg); }
.note { margin-top: 14px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; }
.note-edit { width: 100%; box-sizing: border-box; font: 12px sans-serif; color: var(--ink-strong); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; resize: vertical; background: var(--bg); }
.note-edit:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.section-h { font-size: 14px; font-weight: 800; color: var(--ink-strong); text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 12px; }

/* v42-1: Kaplan persisted selection-history list */
.sr-sel-history { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.sr-sel-history .sr-hist-head { font-size: 12px; font-weight: 800; color: var(--ink-strong); margin-bottom: 6px; }
.sr-sel-history .sr-hist-empty { font-size: 11px; color: var(--muted); font-style: italic; }
.sr-sel-history .sr-hist-item { font-size: 12px; color: var(--ink); padding: 4px 6px; border-radius: 5px; cursor: pointer; }
.sr-sel-history .sr-hist-item:hover { background: var(--accent-bg); }
.sr-sel-history .sr-hist-item.active { background: #cfe8ff; font-weight: 700; color: #0b3d66; }
.sr-sel-history .sr-hist-clear { margin-top: 8px; font-size: 11px; padding: 3px 10px; }

/* ---------- Disabled / inactive state — explicit, never confused with plain text ---------- */
button:disabled, .btn:disabled, input:disabled, select:disabled,
.is-disabled {
  opacity: .55; cursor: not-allowed; filter: grayscale(.4);
  border-style: dashed !important;
}
/* a clearly-disabled secondary button: muted border + dashed + not-allowed */
.secondary:disabled { background: #f1f4f8; color: #7d8a9a; border-color: #cdd6e0; }
/* focus ring kept strong for keyboard users */
.primary:focus, .secondary:focus, button:focus, input:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}

/* ---------- Two-column tool layout ---------- */
.tool-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .tool-layout { grid-template-columns: 1fr; } }

/* ---------- Tables (data manager) ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { background: #f0f4f8; font-weight: 700; color: var(--ink); }
tr:hover td { background: #f8fafc; }
.tag { display: inline-block; background: #e7f0fb; color: var(--accent); border-radius: 5px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
/* v14-4: Δη_o pairwise heat-map matrix */
table.heat { width: auto; margin-top: 8px; font-size: 12px; border-collapse: collapse; }
table.heat th, table.heat td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
table.heat th { background: #f0f4f8; font-weight: 700; color: var(--ink); white-space: nowrap; }
table.heat td.diag { background: #eef2f7; color: var(--muted); font-weight: 700; }
table.heat td.hcell { cursor: pointer; }
table.heat td.hcell:hover, table.heat td.diag:hover { filter: brightness(1.12); }
table.heat td.sel { outline: 3px solid #34465c; outline-offset: -3px; }
/* v26-4: reverse-cluster outline — cells whose pair belongs to the closest |Δ| cluster */
table.heat td.cluster { outline: 2px solid #c0392b; outline-offset: -2px; box-shadow: inset 0 0 0 1px rgba(192,57,43,0.35); }
table.topn { width: auto; margin-top: 8px; font-size: 12px; border-collapse: collapse; }
table.topn th, table.topn td { border: 1px solid var(--line); padding: 6px 12px; text-align: center; }
table.topn th { background: #f0f4f8; font-weight: 700; color: var(--ink); white-space: nowrap; }
table.topn td:first-child { color: var(--muted); font-weight: 700; }

/* ---------- Chart canvas ---------- */
.chart-wrap { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
canvas { width: 100%; height: auto; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 18px; text-align: center; color: var(--muted); font-size: 12px; }
