/* Visual identity – Material Design 3 (see the M3 layer at the end of this file):
 *   tonal colour roles from a blue seed (#0061A4), Roboto type scale, M3 shape scale (4 / 8 / 12 / 16 / 28 px, full),
 *   state layers on hover / press, Material Symbols Rounded icons in the navigation drawer.
 *   Status colours are M3 custom colours (success / warning / error); trade chips keep the BS 1710 service colours. */
:root {
  /* M3 colour roles (light scheme) */
  --md-primary: #0061a4; --md-on-primary: #fff; --md-primary-container: #d1e4ff; --md-on-primary-container: #001d36;
  --md-secondary: #535f70; --md-on-secondary: #fff; --md-secondary-container: #d7e3f7; --md-on-secondary-container: #101c2b;
  --md-tertiary: #6b5778; --md-tertiary-container: #f2daff; --md-on-tertiary-container: #251431;
  --md-error: #ba1a1a; --md-on-error: #fff; --md-error-container: #ffdad6; --md-on-error-container: #410002;
  --md-surface: #f8f9ff; --md-on-surface: #191c20; --md-on-surface-variant: #43474e;
  --md-surface-container-lowest: #fff; --md-surface-container-low: #f2f3fa; --md-surface-container: #eceef4;
  --md-surface-container-high: #e6e8ee; --md-surface-container-highest: #e0e2e8;
  --md-outline: #73777f; --md-outline-variant: #c3c7cf;
  --md-inverse-surface: #2e3135; --md-inverse-on-surface: #eff0f7; --md-inverse-primary: #9ecaff;
  --md-scrim: rgba(0, 0, 0, .32);
  /* M3 elevation */
  --md-elev-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --md-elev-2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --md-elev-3: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 8px 3px rgba(0, 0, 0, .15);
  /* M3 shape scale */
  --md-shape-xs: 4px; --md-shape-s: 8px; --md-shape-m: 12px; --md-shape-l: 16px; --md-shape-xl: 28px; --md-shape-full: 999px;

  /* older names used by the rules below, mapped onto the M3 roles */
  --bg: var(--md-surface-container-low); --card: var(--md-surface-container-lowest); --ink: var(--md-on-surface); --muted: var(--md-on-surface-variant);
  --line: var(--md-surface-container-highest); --rule: var(--md-outline-variant);
  --nav: var(--md-surface-container-low); --nav-ink: var(--md-on-surface-variant); --accent: var(--md-primary); --accent-2: var(--md-on-primary-container);
  --tag: var(--md-tertiary-container); --tag-ink: var(--md-on-tertiary-container);
  --sel-bg: var(--md-secondary-container); --sel-line: var(--md-inverse-primary); --hover: #eef0f6;
  --green: #2b6a2f; --green-bg: #cfebcb; --amber: #775a00; --amber-bg: #fde7a8;
  --red: var(--md-error); --red-bg: var(--md-error-container); --orange: #8b5000; --orange-bg: #ffdcbe;
  --blue: var(--md-primary); --blue-bg: var(--md-primary-container);
  --slate: var(--md-on-surface-variant); --grey-bg: var(--md-surface-container-high);
  --radius: var(--md-shape-m);
  --font: "Roboto", "Segoe UI", system-ui, "Microsoft JhengHei UI", "Microsoft JhengHei", "PingFang HK", "Noto Sans TC", sans-serif;
  --mono: "Roboto Mono", Consolas, monospace;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
#app { display: flex; min-height: 100vh; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 18px; margin: 2px 0 6px; } h3 { font-size: 15px; margin: 0 0 12px; } h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code { font-family: Consolas, monospace; font-size: 12px; background: var(--grey-bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Sidebar */
.sidebar { width: 236px; background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; color: #fff; }
.brand small { display: block; color: var(--nav-ink); font-size: 11px; }
.logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 8px; gap: 2px; flex: 1; }
.sidebar nav a { color: var(--nav-ink); text-decoration: none; padding: 9px 12px; border-radius: 7px; display: flex; align-items: center; gap: 8px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a.nav-locked { opacity: .55; }
.count { margin-left: auto; background: #f0a500; color: #1b2430; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.link { background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; font: inherit; padding: 0; }

/* Main */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.proj small { display: block; color: var(--muted); }
.proj-edit { background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin: -3px -7px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.proj-edit:hover { border-color: var(--line); background: var(--bg, rgba(0,0,0,.03)); }
.me { display: flex; align-items: center; gap: 10px; }
.switch-label { font-size: 11px; color: var(--muted); }
.me select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fffbea; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.content { padding: 22px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sub-h { margin: 22px 0 10px; }

/* Cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi small { color: var(--muted); } .kpi b { font-size: 28px; }
.bar, .cellbar { height: 6px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.bar i, .cellbar i { display: block; height: 100%; background: var(--accent); }
.cellbar { width: 60px; display: inline-block; vertical-align: middle; margin-right: 6px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.clickable { cursor: pointer; } .clickable:hover td { background: var(--hover); }
.mini { width: 100%; border-collapse: collapse; } .mini th, .mini td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }
.row-denied td { background: #fff5f4; }
.empty { padding: 24px; text-align: center; }
.note { display: flex; align-items: center; gap: 6px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.amber { background: var(--amber-bg); color: var(--amber); } .badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.grey { background: var(--grey-bg); color: var(--slate); }
.badge.solid-green { background: var(--green); color: #fff; } .badge.solid-slate { background: var(--slate); color: #fff; }
.role-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--grey-bg); color: var(--slate); margin-left: 4px; }
.role-intern { background: #e8f0fe; color: #1a56c4; } .role-ae { background: #e6f6f6; color: #0b6f6f; } .role-engineer { background: #eef7e8; color: #3b7a1f; }
.role-se { background: #fdf1d8; color: #8a5600; } .role-pm { background: #f3e8fd; color: #6a2bb0; } .role-admin { background: #1b2430; color: #fff; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.chip.done { background: var(--green-bg); color: var(--green); font-weight: 600; } .chip.review { background: var(--amber-bg); color: var(--amber); }
.chip.returned { background: var(--red-bg); color: var(--red); } .chip.todo { background: var(--grey-bg); color: var(--muted); }
.act { font-family: Consolas, monospace; font-size: 11.5px; font-weight: 700; color: var(--slate); }
.act-approve { color: var(--green); } .act-return, .act-delete, .act-denied { color: var(--red); } .act-submit, .act-revise { color: var(--accent-2); }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #c5ccd6; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); } .btn.primary:hover { background: var(--accent-2); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.danger { background: #fff; color: var(--red); border-color: #f1c2bc; }
.btn.danger-outline { color: var(--red); border-color: #f1c2bc; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.locked { background: #f3f4f6; color: #9aa3ae; border-style: dashed; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600; }

/* Tasks */
.tasks { list-style: none; padding: 0; margin: 0 0 12px; }
.tasks li { padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tasks li:hover { background: var(--hover); } .tasks small { color: var(--muted); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,37,55,.45); display: flex; justify-content: center; align-items: flex-start; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: 820px; }
.modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-f { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.x { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.badges { display: flex; gap: 6px; }
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.meta > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .meta small { color: var(--muted); }
.meta .span2 { grid-column: span 4; }
.path { display: inline-flex; gap: 6px; align-items: center; padding: 6px 8px; font-size: 12.5px; word-break: break-all; }
.rev { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.note-text { margin: 6px 0; color: var(--slate); }
.files { list-style: none; padding: 0; margin: 6px 0 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.files li span { flex: 1; } .files small { color: var(--muted); }
.review { border-left: 3px solid var(--line); padding: 6px 10px; margin-bottom: 8px; }
.review.approved { border-color: var(--green); } .review.returned { border-color: var(--red); background: #fff8f7; }
.review p { margin: 4px 0 0; }
.review-box { background: var(--hover); border: 1px solid var(--sel-line); border-radius: 8px; padding: 12px; margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.review-box label { font-weight: 600; font-size: 13px; }
textarea, input[type=text], input:not([type]), select { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.form .span2 { grid-column: span 2; }
.form label.inline { flex-direction: row; align-items: center; font-weight: 400; }
.form label.inline input { width: auto; }

/* Stepper */
.stepper { display: flex; align-items: center; margin: 6px 0 16px; }
.step { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--grey-bg); font-size: 11px; font-weight: 700; }
.step.done { color: var(--green); } .step.done i { background: var(--green); color: #fff; }
.step.current { color: var(--amber); font-weight: 600; } .step.current i { background: #f0a500; color: #fff; }
.step.bad { color: var(--red); font-weight: 600; } .step.bad i { background: var(--red); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--line); margin: 0 8px; min-width: 16px; }

/* Folders */
.folders { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.tree { padding: 10px; }
.troot, .tnode { display: flex; align-items: center; gap: 7px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.tnode { padding-left: 26px; font-size: 13px; }
.troot small, .tnode small { margin-left: auto; color: var(--muted); }
.troot:hover, .tnode:hover { background: #f1f5f8; }
.troot.active, .tnode.active { background: var(--sel-bg); color: var(--accent-2); }
.tdesc { font-size: 11.5px; color: var(--muted); padding: 0 8px 4px 31px; }
.tsep { height: 1px; background: var(--line); margin: 10px 0; }
.folder-search { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.folder-search input { flex: 1; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.folder-search input:focus { outline: 2px solid var(--sel-line); border-color: var(--accent); }
.tree-scroll { max-height: 62vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.tcaret { background: none; border: 0; cursor: pointer; color: var(--muted); width: 16px; padding: 0; font-size: 12px; flex-shrink: 0; }
.tcaret:hover { color: var(--accent-2); }
.tcaret-space { width: 16px; flex-shrink: 0; }
.tgroup-sub { padding-top: 0; }
.tgroup-sub button { border-style: dashed; }
.tgroup { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); padding: 2px 6px 10px; }
.tgroup button { border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer; color: var(--slate); }
.tgroup button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tnode > span:not(.tcounts) { display: flex; flex-direction: column; min-width: 0; }
.tdesc-inline { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcounts { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.tcounts small { margin-left: 0 !important; }
.tpend, .tret { font-size: 10.5px; font-weight: 700; border-radius: 9px; padding: 0 6px; line-height: 16px; }
.tpend { background: #f0a500; color: #1b2430; } .tret { background: var(--red); color: #fff; }
.tlegend { font-size: 11px; color: var(--muted); padding: 12px 8px 2px; display: flex; align-items: center; gap: 4px; }
.troot.open, .tnode.open { color: var(--accent-2); }
.eq-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--hover); }
.eq-card > div:first-child { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 3px; }
.eq-tag { font-size: 16px; }
.eq-levels { display: flex; gap: 8px; flex-wrap: wrap; }
.eq-levels > div { display: flex; align-items: center; gap: 2px; }
.folder-tabs { margin: 0; padding: 0 10px; }
.row-pending td { background: #fffbef; }
.files-cell div { white-space: nowrap; font-size: 12.5px; display: flex; align-items: center; gap: 4px; }
.folder-path { padding: 10px 12px; border-bottom: 1px solid var(--line); font-family: Consolas, monospace; font-size: 12.5px; display: flex; gap: 6px; align-items: center; background: #fafbfc; }

/* Roles matrix */
.matrix td.c, .matrix th { text-align: center; }
.matrix th:first-child { text-align: left; }
.matrix td:first-child { min-width: 280px; }
.matrix .mine { background: #fffbea !important; }
.matrix tr.grp td { background: #f1f4f7; font-weight: 700; font-size: 12px; color: var(--slate); text-transform: uppercase; letter-spacing: .04em; }
.matrix input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.matrix select { width: auto; font-size: 12px; padding: 4px; }
.pkey { font-size: 10.5px; color: var(--muted); }
.yes { color: var(--green); font-weight: 700; } .no { color: #c9ced6; }
.rules li { margin-bottom: 6px; }

/* Equipment list */
.uid { font-family: Consolas, monospace; font-size: 11.5px; color: #3b5b7a; background: #eaf1f8; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.ref-chip { display: inline-flex; align-items: center; margin: 2px 4px 2px 0; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; white-space: nowrap; overflow: hidden; }
.ref-chip i { font-style: normal; background: var(--grey-bg); color: var(--slate); padding: 1px 6px; font-size: 11px; border-right: 1px solid var(--line); }
.ref-chip { padding-right: 6px; } .ref-chip i { margin-right: 6px; }
.table td.refs { min-width: 200px; }
.table td.c { text-align: center; }
.filters { display: flex; gap: 10px; margin-bottom: 12px; }
.filters input { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.filters select { width: auto; min-width: 180px; }
.refs-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fafbfc; }
.refs-h { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.ref-row { display: grid; grid-template-columns: 220px 1fr 1fr 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
/* T&C levels */
.lv { display: inline-block; font-family: Consolas, monospace; font-weight: 700; font-size: 11.5px; background: var(--nav); color: #fff; border-radius: 4px; padding: 1px 6px; margin-right: 4px; }
.chip.partial { background: #e6f2fb; color: #1a5f99; }
.levels-legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.lvl-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.lvl-card .lv { align-self: flex-start; }
.lvl-name { font-weight: 400; white-space: normal; display: block; max-width: 120px; margin: 0 auto; }
.table th.c { text-align: center; }
.tc-level { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.tc-level-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tc-level-h .chip { margin-left: auto; }
.tc-level .mini td { border-bottom: 1px dashed var(--line); }
.tc-level .mini td.r { text-align: right; }
.small { font-size: 12px; }
.card-h { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }
.table td input, .test-row input, .type-h input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
.tests-grid { display: grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 10px; overflow-x: auto; }
.tests-col { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.tests-col-h { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.test-row { display: flex; align-items: center; gap: 4px; }
.test-row > span { flex: 1; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.test-add { display: flex; gap: 4px; margin-top: auto; padding-top: 6px; }
.test-add input { flex: 1; min-width: 0; font: inherit; font-size: 12.5px; padding: 5px 7px; border: 1px dashed #c5ccd6; border-radius: 6px; }
.type-h { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.type-h label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.type-h input { width: 280px; }
.type-h .btn { margin-left: auto; }
.type-preview { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.row input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
/* Equipment import */
.min-info { border: 1px solid #f1c2bc; background: #fff8f7; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.min-info-h { font-weight: 700; color: var(--red); margin-bottom: 8px; }
.min-info-grid { display: grid; grid-template-columns: 1.3fr 1.3fr 1fr; gap: 12px; }
.min-info-grid > div { display: flex; flex-direction: column; gap: 5px; }
.req-chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.req-chip { background: var(--red); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; }
.opt-chip { background: var(--grey-bg); color: var(--slate); font-size: 12px; padding: 2px 8px; border-radius: 4px; }
@media (max-width: 720px) { .min-info-grid { grid-template-columns: 1fr; } }
.badge.blue { background: #e6f2fb; color: #1a5f99; }
.import-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.import-step { display: flex; gap: 12px; align-items: flex-start; }
.import-step > b { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.import-step > div { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.import-step label.inline { display: flex; gap: 6px; align-items: center; }
.dropzone { display: block; width: 100%; border: 2px dashed #c5ccd6; border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfc; }
.dropzone.over { border-color: var(--accent); background: var(--sel-bg); }
.dropzone input { display: block; margin: 0 auto 6px; }
.imp-summary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.imp-fatal, .imp-warn { background: var(--red-bg); color: var(--red); border-radius: 6px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.imp-warn { background: var(--amber-bg); color: var(--amber); }
.imp-table { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.imp-table th { position: sticky; top: 0; }
.imp-table tr.imp-error td { background: #fff5f4; }

/* T&C settings: system → type → tests */
.lv-details summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; list-style: none; }
.lv-details summary::before { content: '▸ '; position: absolute; }
.lv-details[open] summary::before { content: '▾ '; }
.lv-details summary { position: relative; padding-left: 28px; }
.lv-details summary::before { left: 12px; }
.lv-details summary small { font-weight: 400; }
.cfg-crumb { font-size: 13px; color: var(--slate); margin: 4px 0 10px; font-weight: 600; }
.cfg-crumb span { color: var(--muted); margin: 0 6px; }
.cfg-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.cfg-col-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.cfg-sys { padding: 12px; }
.cfg-sys-row { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border: 1px solid transparent; }
.cfg-sys-row:hover { background: #f1f5f8; }
.cfg-sys-row.active { background: var(--sel-bg); border-color: var(--sel-line); }
.cfg-sys-row.active b { color: var(--accent-2); }
.cfg-sys-row.orphan b { color: var(--amber); }
.cfg-add { margin: 10px 0 6px; }
.cfg-main { min-width: 0; }
.cfg-types-card { padding: 12px 14px; }
.cfg-types { display: flex; flex-wrap: wrap; gap: 8px; }
.cfg-type { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font: inherit; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.cfg-type small { color: var(--muted); font-size: 11px; }
.cfg-type:hover { border-color: var(--sel-line); }
.cfg-type.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cfg-type.active small { color: #d9f0f0; }
.cfg-type.add { border-style: dashed; color: var(--accent-2); justify-content: center; }
.cfg-type.add.active { background: var(--sel-bg); color: var(--accent-2); }
.cfg-addtype { margin-top: 12px; padding: 12px; background: #fafbfc; border: 1px dashed #c5ccd6; border-radius: 8px; display: flex; flex-direction: column; gap: 12px; }
.cfg-addtype .row { margin-top: 6px; }
.cfg-addtype select { width: auto; min-width: 220px; }
.req-levels { background: var(--hover); border: 1px solid var(--sel-line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.req-levels .row { margin: 4px 0; gap: 14px; }
.req-levels label.inline { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.tests-col.opt { opacity: .7; background: #f3f4f6; }
.tests-col-h > div { margin-top: 3px; font-weight: 400; }
.chip.optional { background: #f3f4f6; color: #9aa3ae; border: 1px dashed #d5dbe3; }
.shared-note { background: var(--amber-bg); color: var(--amber); border-radius: 6px; padding: 7px 10px; font-size: 12.5px; margin: 0 0 10px; }
.empty-cfg { text-align: center; padding: 28px; }
@media (max-width: 1000px) { .cfg-layout { grid-template-columns: 1fr; } }

/* Floors & rooms */
.rooms-card .rooms-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 12px; flex-wrap: wrap; }
.rooms-card .rooms-head label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.rooms-card .rooms-head select { width: auto; min-width: 240px; }
.rooms-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.rooms-grid .table { display: block; max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.rooms-grid .table tbody { display: table; width: 100%; }
.rooms-grid .table td { padding: 6px; }
.rooms-grid .table select { width: auto; font-size: 12px; padding: 4px; }
.rooms-tools { display: flex; flex-direction: column; gap: 14px; }
.rooms-tools > div { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.rooms-tools textarea { width: 100%; font: inherit; }
.rooms-tools .test-add { width: 100%; }
@media (max-width: 1000px) { .rooms-grid { grid-template-columns: 1fr; } }

/* Demo tools */
.demo-tools-btn { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 7px; padding: 7px 12px; cursor: pointer; font: inherit; width: 100%; text-align: left; }
.demo-tools-btn:hover { background: rgba(255,255,255,.15); }
.demo-tool { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.demo-tool > div { flex: 1; }
.demo-tool p { margin: 4px 0 0; }
.demo-tool .btn { flex-shrink: 0; }
.demo-tool.danger { background: #fff8f7; border-color: #f1c2bc; }

/* Trades */
.trade-filter { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.trade-filter label { font-size: 12px; color: var(--muted); font-weight: 600; }
.trade-filter select { width: auto; min-width: 200px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.trade-chip { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; letter-spacing: .02em; vertical-align: 1px;
  background: #e3e7ed; color: #3b4656; }
.trade-chip.t-HVAC { background: #dff1f8; color: #0f5f80; }
.trade-chip.t-ELV  { background: #ece4fb; color: #5b2ca0; }
.trade-chip.t-BMS  { background: #fdf1d8; color: #8a5600; }
.trade-chip.t-FS   { background: #fbe1de; color: #b0281b; }
.trade-chip.t-PD   { background: #e3f4ea; color: #1f7a45; }
.trade-table tr.clickable:hover td { background: var(--hover); }
.trade-table tr.trade-active td { background: var(--sel-bg); }
.cellbar.wide { width: 90px; }
.cfg-trade-h { font-size: 12px; font-weight: 700; color: var(--slate); margin: 10px 0 4px; display: flex; align-items: center; gap: 6px; }
.cfg-trade-h:first-of-type { margin-top: 2px; }
.cfg-add { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.cfg-trade-h.edit input { flex: 1; min-width: 0; font: inherit; font-size: 12px; font-weight: 700; padding: 3px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--slate); }
.cfg-trade-h.edit input:hover, .cfg-trade-h.edit input:focus { border-color: var(--line); background: #fff; }
.sys-card { padding: 12px 14px; }
.sys-edit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sys-edit label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.sys-edit input { width: 280px; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.sys-edit select { width: auto; }
.sys-edit .btn { margin-left: auto; }
.cfg-add select { width: 100%; }

/* Option lists */
.lists-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
.list-card .table { display: block; max-height: 420px; overflow-y: auto; }
.list-card .table tbody { display: table; width: 100%; }
.list-card .table td { padding: 6px 6px; }
.list-card .ord { width: 44px; white-space: nowrap; }
.list-card .ord .x, .list-card td > .x { font-size: 15px; padding: 0 3px; }
.x:disabled { opacity: .25; cursor: default; }
.list-card .test-add { margin-top: 10px; }
@media (max-width: 1100px) { .lists-grid { grid-template-columns: 1fr; } }
@media (max-width: 1000px) { .levels-legend { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .ref-row { grid-template-columns: 1fr; } .filters { flex-direction: column; } }

/* Denied page */
.denied-page { text-align: center; padding: 80px 20px; color: var(--muted); }
.denied-page svg { width: 48px; height: 48px; color: var(--red); }

/* Login */
.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, #0f2537, #164a5c); }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: 640px; max-width: 100%; }
.brand.big { color: var(--ink); padding: 0 0 8px; } .brand.big small { color: var(--muted); }
.user-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.user-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; font: inherit; }
.user-card:hover { border-color: var(--accent); background: var(--hover); }
.user-card b { display: block; margin-bottom: 3px; } .user-card .role-badge { margin-left: 0; }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1b2430; color: #fff; padding: 11px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: .25s; font-size: 13px; }
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--green); } .toast.error { background: var(--red); }
.toast svg { vertical-align: -2px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: 1fr 1fr; } .grid2, .folders { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr 1fr; } .meta .span2 { grid-column: span 2; }
}
@media (max-width: 720px) {
  #app { flex-direction: column; } .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; overflow-x: auto; } .sidebar nav a { white-space: nowrap; }
  .content { padding: 16px; } .user-grid, .form { grid-template-columns: 1fr; } .form .span2 { grid-column: span 1; }
  .stepper { flex-wrap: wrap; gap: 6px; } .step-line { display: none; }
}
.tc-level.opt { background: #fafbfc; opacity: .8; }
.tc-level-h .badge { font-size: 10.5px; }
.stage-docs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.stage-docs .btn { margin-left: auto; }

/* Document storage settings */
.stg-chip { font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 12px; text-decoration: none; background: var(--grey-bg); color: var(--slate); white-space: nowrap; }
.stg-chip.stg-local { background: #e3f4ea; color: #1f7a45; }
.stg-chip.stg-gdrive { background: #e6f2fb; color: #1a5f99; }
.stg-chip.stg-onedrive { background: #e8eefc; color: #2b4fb3; }
.stg-current { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stg-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); margin-left: 6px; }
.stg-status.ok { background: var(--green-bg); color: var(--green); }
.stg-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stg-opt { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 14px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.stg-opt:hover { border-color: var(--sel-line); }
.stg-opt.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel-line); }
.stg-opt .stg-status { margin-left: 0; }
.stg-settings h3 { margin-bottom: 12px; }
.stg-field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; margin-bottom: 10px; max-width: 560px; }
.stg-field input { font: inherit; font-weight: 400; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.stg-field small { font-weight: 400; }
.stg-notes { margin: 8px 0; padding-left: 18px; font-size: 13px; color: var(--slate); }
.stg-notes li { margin-bottom: 4px; }
.stg-guide { margin: 10px 0; font-size: 13px; }
.stg-guide summary { cursor: pointer; font-weight: 600; color: var(--accent-2); }
.stg-guide ol { padding-left: 18px; }
.stg-common { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.stg-tree { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.stg-tree code { display: block; padding: 5px 8px; word-break: break-all; }
.stg-actions { margin-top: 14px; }
.file-path { font-size: 11px; word-break: break-all; }
@media (max-width: 1100px) { .stg-options { grid-template-columns: 1fr 1fr; } }

/* Server mode */
.me-name { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.me-name small { color: var(--muted); font-size: 11px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.login-form input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; }
.login-form .btn { justify-content: center; }

/* Approval pause */
.approval-banner { background: #fbe1de; color: #8f2016; border-bottom: 1px solid #f1c2bc; padding: 8px 24px; font-size: 13px; }
.approval-banner a { color: inherit; font-weight: 700; margin-left: 6px; }
.approval-ctrl { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.approval-ctrl > div { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 260px; }
.approval-ctrl.paused { border-color: #f1c2bc; background: #fff8f7; }
.post-box { background: #fff8ef; border-color: #f3d3a8; }
.demo-tools-btn.locked { opacity: .55; cursor: not-allowed; display: flex; align-items: center; gap: 6px; }

/* ---------- T&C 進度報告 ---------- */
.rpt-filters { align-items: center; flex-wrap: wrap; }
.table.rpt td.c, .table.rpt th.c { text-align: center; }
.pcell { display: inline-flex; flex-direction: column; align-items: center; min-width: 58px; padding: 3px 6px; border-radius: 6px; line-height: 1.2; }
.pcell b { font-size: 13px; } .pcell small { font-size: 10.5px; color: var(--muted); }
.pcell.p-done { background: var(--green-bg); color: var(--green); } .pcell.p-part { background: var(--amber-bg); color: var(--amber); }
.pcell.p-none { background: var(--grey-bg); color: var(--muted); } .pcell.p-ret { background: var(--red-bg); color: var(--red); }
.pcell.opt { opacity: .6; font-style: italic; }
.table.rpt tr.rpt-grp td { background: var(--grey-bg); font-weight: 600; padding: 6px 12px; }

/* ---------- 提交：選擇設備（一份文件可涵蓋多部設備） ---------- */
.eqp { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: #fbfcfd; }
.eqp-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.form label.eqp-general { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.form label.eqp-general input { width: auto; }
.eqp-bar { display: flex; gap: 8px; }
.eqp-bar input { flex: 1; min-width: 0; } .eqp-bar select { width: auto; min-width: 120px; }
.eqp-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.eqp-hint { font-size: 12px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--hover); }
.form label.eqp-grp-h { flex-direction: row; align-items: center; gap: 8px; background: var(--grey-bg); padding: 5px 10px; position: sticky; top: 0; z-index: 1; font-weight: 400; cursor: pointer; }
.form label.eqp-item { flex-direction: row; align-items: center; gap: 8px; padding: 4px 10px 4px 28px; border-bottom: 1px solid var(--line); font-weight: 400; cursor: pointer; }
.form label.eqp-item b { min-width: 110px; }
.form label.eqp-item .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form label.eqp-grp-h input, .form label.eqp-item input { width: auto; margin: 0; }
.eqp-item.on { background: var(--sel-bg); }
.eqp-sel { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; font-size: 13px; }
.sub-eq-list > div { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.sub-eq-list > div > b { min-width: 44px; font-size: 12px; color: var(--muted); }
.eq-pill { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 1px 7px; font: inherit; font-size: 12px; cursor: pointer; }
.eq-pill:hover { border-color: var(--accent); color: var(--accent-2); }

/* ---------- 多部設備：個別設備不合格 ---------- */
.unit-results { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px; background: #fff; }
.unit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.unit-row > b { min-width: 44px; font-size: 12px; color: var(--muted); }
.unit-chk { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; font-size: 12px; cursor: pointer; }
.unit-chk input { margin: 0; }
.unit-chk:has(input:checked) { background: var(--red-bg); border-color: var(--red); color: var(--red); font-weight: 600; }
#fail-reason { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.eq-pill.pass { border-color: #b9e0c7; color: var(--green); }
.eq-pill.fail { border-color: var(--red); background: var(--red-bg); color: var(--red); font-weight: 600; }
.fail-note { color: var(--red); margin: 4px 0; }
.review-box.fail-box { border-color: var(--red); background: #fff7f6; }

/* ---------- 一份報告多項測試 ---------- */
.tests-pick { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: #fbfcfd; display: flex; flex-direction: column; gap: 6px; }
.tp-h { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.tp-h .link { margin-left: auto; font-size: 12px; }
.test-list { display: flex; flex-wrap: wrap; gap: 6px; }
.form label.test-chk { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; background: #fff; cursor: pointer; }
.form label.test-chk input { width: auto; margin: 0; }
.form label.test-chk:has(input:checked) { border-color: var(--accent); background: var(--sel-bg); }
.sub-test-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.test-pill { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 1px 8px; font-size: 12px; }
.test-pill.pass { border-color: #b9e0c7; color: var(--green); }
.test-pill.fail { border-color: var(--red); background: var(--red-bg); color: var(--red); font-weight: 600; }

/* ---------- 設備型號及規格 ---------- */
.spec-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fbfcfd; display: flex; flex-direction: column; gap: 8px; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; }
.spec-new { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; padding: 8px; border: 1px dashed var(--accent); border-radius: 6px; background: var(--hover); }
.spec-new .span3 { grid-column: span 3; }
.model-specs { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 10px; background: var(--hover); border-radius: 6px; }
.model-specs span { display: flex; flex-direction: column; } .model-specs small { color: var(--muted); font-size: 11px; } .model-specs b { font-size: 13px; }
.model-specs.eq-sum { margin: 0 0 12px; }
.spec-chip { display: inline-flex; margin: 2px 4px 2px 0; border: 1px solid var(--line); border-radius: 4px; font-size: 12px; white-space: nowrap; overflow: hidden; padding-right: 6px; }
.spec-chip i { font-style: normal; background: var(--grey-bg); color: var(--slate); padding: 1px 6px; margin-right: 6px; font-size: 11px; border-right: 1px solid var(--line); }
.col-picker { position: relative; }
.col-picker summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: #fff; white-space: nowrap; }
.col-picker summary::-webkit-details-marker { display: none; }
.col-picker-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 37, 55, .12); padding: 8px; max-height: 320px; overflow: auto; min-width: 260px; display: flex; flex-direction: column; gap: 2px; }
.col-picker-menu label { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.col-picker-menu label:hover { background: var(--grey-bg); }
.col-picker-menu small { margin-left: auto; }
@media (max-width: 700px) { .spec-new { grid-template-columns: 1fr; } .spec-new .span3 { grid-column: span 1; } }
.cfg-type.add { border-style: dashed; color: var(--accent-2); justify-content: center; }
.ta-sys { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.unit-chk.ok:has(input:checked) { background: var(--sel-bg); border-color: var(--accent); color: var(--accent-2); }

/* ---------- 介面語言 ---------- */
.lang-switch { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: auto; }
.login-lang { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* ---------- 側欄分組（日常工作 / 設備及進度 / 設定） ---------- */
.sidebar nav { overflow-y: auto; gap: 0; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.nav-group-h { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: rgba(185, 199, 214, .55); padding: 8px 12px 4px; }
button.nav-fold { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; font-family: inherit; text-align: left; cursor: pointer; border-radius: 7px; }
button.nav-fold:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, .06); }
button.nav-fold:disabled { cursor: default; }
button.nav-fold small { background: rgba(255, 255, 255, .1); border-radius: 8px; padding: 0 6px; font-size: 10px; }
.nav-group.fold .nav-group-items { display: none; }
.nav-group.fold.open .nav-group-items { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 720px) { /* 窄畫面：側欄是一行可捲動的按鈕，不分組 */
  .nav-group, .nav-group.fold .nav-group-items { display: contents; }
  .nav-group-h { display: none; }
}

/* T&C label preview */
.label-preview { display: block; width: 100%; max-width: 640px; margin: 8px auto; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }

/* Inspection form generation (new submission) */
.formgen { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; }
.formgen select { flex: 1; min-width: 0; }

/* Inspection form preview (layer above the new-submission pop-up) */
.preview-layer { z-index: 60; }
.modal.preview-modal { width: 960px; }
.docx-preview-box { max-height: 68vh; overflow: auto; background: #d9dee5; border-radius: 8px; padding: 12px; }
.docx-preview-box .docx-wrapper { background: transparent; padding: 0; }
.docx-preview-box .docx-wrapper > section.docx { box-shadow: 0 2px 10px rgba(0,0,0,.18); margin: 0 auto 12px; }
.docx-preview-box .xl-page { background: #fff; color: #111; box-shadow: 0 2px 10px rgba(0,0,0,.18); margin: 0 auto 12px; padding: 24px; width: max-content; max-width: 100%; overflow-x: auto; box-sizing: border-box; }
.docx-preview-box .xl-canvas { position: relative; background: #fff; }
.docx-preview-box .xl-layer { position: absolute; left: 0; top: 0; pointer-events: none; }
.docx-preview-box .xl-layer > div, .docx-preview-box .xl-layer > img { position: absolute; }
.docx-preview-box .xl-t { display: flex; overflow: hidden; box-sizing: border-box; padding: 0 2px; font: 11pt Calibri, Carlito, Arial, sans-serif; line-height: 1.15; color: #000; }
.docx-preview-box .xl-sheet-name { margin: 4px 0 8px; color: #334; }

/* ---------- 檢查日程（js/app/schedule.js） ---------- */
.badge.teal { background: #dff3f3; color: var(--accent-2); }
.num-red { color: var(--red); }
.kpi.clickable:hover { border-color: var(--accent); }
.form .grid-sub { display: contents; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; font: inherit; cursor: pointer; color: var(--slate); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.cal-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-bar select { width: auto; min-width: 140px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.cal-title { margin: 0 0 0 8px; }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd div { font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.cal-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-day { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.cal-day:hover { background: #f8fbfb; }
.cal-day.other { background: #fafbfc; } .cal-day.other .cal-dn { color: #b4bcc7; }
.cal-day.weekend { background: #fcfcfd; }
.cal-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-dn { font-size: 12px; font-weight: 600; color: var(--slate); }
.ins-chip { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid #1a5f99; background: #e6f2fb; border-radius: 4px; padding: 2px 5px;
  font: inherit; font-size: 11.5px; line-height: 1.35; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.ins-chip small { color: var(--muted); font-size: 10.5px; }
.ins-chip:hover { filter: brightness(.96); }
.ins-warn { color: var(--red); margin-right: 2px; }
/* request for inspection mark: ✓ submitted, ! due (not submitted, inspection close) */
.ins-rq { display: inline-block; min-width: 13px; height: 13px; line-height: 13px; border-radius: 50%; text-align: center; font-size: 9.5px; font-weight: 700;
  margin-right: 3px; vertical-align: 1px; text-decoration: none; }
.ins-rq.ok { background: var(--green); color: #fff; } .ins-rq.due { background: var(--red); color: #fff; }
.kpis.k5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .kpis.k5 { grid-template-columns: 1fr 1fr; } }
.st-today.ins-chip { border-color: var(--accent); background: #dff3f3; }
.st-overdue.ins-chip { border-color: var(--red); background: var(--red-bg); }
.st-review.ins-chip { border-color: var(--amber); background: var(--amber-bg); }
.st-returned.ins-chip { border-color: var(--orange); background: var(--orange-bg); }
.st-done.ins-chip { border-color: var(--green); background: var(--green-bg); }
.st-cancelled.ins-chip { border-color: #b4bcc7; background: var(--grey-bg); text-decoration: line-through; color: var(--muted); }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-col { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cal-col.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-col-h { padding: 2px 4px 4px; border-bottom: 1px solid var(--line); }
.ins-card { background: #fff; border: 1px solid var(--line); border-left: 4px solid #1a5f99; border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.ins-card:hover { box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.ins-card-h { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ins-card.st-today { border-left-color: var(--accent); } .ins-card.st-overdue { border-left-color: var(--red); }
.ins-card.st-review { border-left-color: var(--amber); } .ins-card.st-returned { border-left-color: var(--orange); }
.ins-card.st-done { border-left-color: var(--green); } .ins-card.st-cancelled { border-left-color: #b4bcc7; opacity: .7; }
.ins-clash { background: var(--red-bg); color: var(--red); border-radius: 6px; padding: 6px 8px; font-size: 12px; margin: 4px 0 8px; }
.ins-overdue { border-color: #f1c2bc; }
.kv { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.kv th { text-align: left; width: 130px; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 6px 8px 6px 0; vertical-align: top; }
.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ins-formgen { margin-bottom: 8px; }
@media (max-width: 900px) { .cal-week { grid-template-columns: 1fr; } .cal-day { min-height: 70px; } }

/* ---------- 檢查表登記冊（js/app/register.js）及交接文件包（js/app/handover.js） ---------- */
.reg-cfg { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.reg-cfg > div small { display: block; } .reg-cfg > div b { font-size: 18px; }
.reg-cfg input { padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.row-void td { color: var(--muted); } .row-void td b { text-decoration: line-through; }
.ho-systems { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 12px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.ho-sum { background: var(--grey-bg); border-radius: 8px; padding: 10px 12px; }
.ho-prog .bar { height: 8px; margin-bottom: 4px; }

/* Backup and restore page (js/app/backup.js) */
.bk-actions { margin-top: 0; }
.bk-actions label { display: inline-flex; align-items: center; gap: 6px; }
.bk-running { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.bk-running progress, #bk-prog { flex: 1 1 200px; width: 100%; height: 8px; accent-color: var(--ink); }
#bk-cfg .form input[type=time], #bk-cfg .form input[type=number] { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; }
.bk-red { color: var(--red); }

/* =====================================================================================================
   Material Design 3 layer (overrides the rules above; keep it last)
   ===================================================================================================== */

/* ---- Type scale (M3): headline / title / body / label ---- */
body { background: var(--md-surface-container-low); color: var(--md-on-surface); font-size: 14px; line-height: 20px; letter-spacing: .015em;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }
h1 { font-size: 28px; line-height: 36px; font-weight: 400; letter-spacing: 0; }             /* headline medium */
h2 { font-size: 22px; line-height: 28px; font-weight: 400; letter-spacing: 0; }             /* title large */
h3 { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .01em; }         /* title medium */
h4 { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .007em; text-transform: none; color: var(--md-on-surface-variant); }
.matrix tr.grp td, .cfg-col-h { text-transform: none; letter-spacing: .007em; }
small { font-size: 12px; line-height: 16px; letter-spacing: .03em; }
code, .uid, .act, .folder-path, .path { font-family: var(--mono); }
code { font-size: 12px; font-weight: 500; background: var(--md-surface-container-high); border-radius: var(--md-shape-xs); }
a { color: var(--md-primary); }
.link { color: var(--md-primary); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* Material Symbols Rounded (navigation drawer and a few controls) */
.msi { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 22px; line-height: 1; letter-spacing: normal;
  text-transform: none; white-space: nowrap; direction: ltr; display: inline-block; flex-shrink: 0; width: 1em; overflow: hidden;
  font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; }

/* ---- State layers: hover 8 %, press 12 % of the content colour, laid over the container colour ---- */
:where(.btn, .sidebar nav a, button.nav-fold, .tabs button, .seg button, .tgroup button, .user-card, .cfg-type, .stg-opt, .cfg-sys-row,
  .troot, .tnode, .x, .tcaret, .eq-pill, .demo-tools-btn, .proj-edit, .me .link, .col-picker summary, .ins-chip, .form label.test-chk, .unit-chk):hover {
  background-image: linear-gradient(color-mix(in srgb, currentColor 8%, transparent), color-mix(in srgb, currentColor 8%, transparent)); }
:where(.btn, .sidebar nav a, .tabs button, .seg button, .tgroup button, .user-card, .cfg-type, .stg-opt, .cfg-sys-row, .troot, .tnode, .x,
  .demo-tools-btn, .me .link):active {
  background-image: linear-gradient(color-mix(in srgb, currentColor 12%, transparent), color-mix(in srgb, currentColor 12%, transparent)); }
.btn, .sidebar nav a, .tabs button, .seg button, .user-card, .cfg-type, .stg-opt, .demo-tools-btn { transition: background-color .15s, box-shadow .15s, border-color .15s; }

/* ---- Focus indicator (M3): 3 px secondary ring, 2 px offset ---- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--md-secondary); outline-offset: 2px; box-shadow: none; }
:where(input, select, textarea):focus-visible { outline: none; }

/* ---- Frame: drawer + top app bar on the surface-container-low background; content on white cards ---- */
#app { background: var(--md-surface-container-low); }
.content { padding: 4px 24px 56px; max-width: 1440px; }
.page-head { margin: 8px 0 16px; padding: 0; border: 0; }
.page-head + p.muted { margin-top: -6px; max-width: 80ch; }
.sub-h { margin: 24px 0 12px; }

/* top app bar */
.topbar { background: transparent; border: 0; min-height: 64px; padding: 8px 24px; gap: 12px; }
.proj small { color: var(--md-on-surface-variant); font-size: 12px; font-weight: 500; letter-spacing: .04em; }
.proj b { font-size: 18px; line-height: 24px; font-weight: 400; }
.proj-edit { border: 0; border-radius: var(--md-shape-s); padding: 4px 8px; margin: -4px -8px; }
.proj-edit:hover { background-color: transparent; border-color: transparent; }
.trade-filter label, .switch-label { font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); letter-spacing: .04em; }
.me { gap: 8px; }
.me .link { display: inline-flex; align-items: center; height: 40px; padding: 0 12px; border-radius: var(--md-shape-full); }
.me .link:hover { text-decoration: none; }
.avatar { width: 36px; height: 36px; background: var(--md-primary-container); color: var(--md-on-primary-container); border: 0; font-weight: 500; font-size: 14px; }

/* navigation drawer */
.sidebar { width: 264px; background: var(--md-surface-container-low); color: var(--md-on-surface-variant); }
.brand { padding: 16px 20px 12px 24px; color: var(--md-on-surface); gap: 12px; }
.brand b { font-size: 16px; line-height: 24px; font-weight: 500; }
.brand small { color: var(--md-on-surface-variant); font-size: 12px; }
.logo { width: 40px; height: 40px; border-radius: var(--md-shape-m); background: var(--md-primary); color: var(--md-on-primary); clip-path: none; padding: 0;
  font-size: 13px; font-weight: 700; letter-spacing: 0; }
.sidebar nav { padding: 4px 12px 8px; gap: 0; }
.nav-group { gap: 0; margin: 0; padding: 4px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--md-outline-variant); margin: 4px 16px 0; padding-top: 8px; }
.nav-group + .nav-group a, .nav-group + .nav-group .nav-fold { margin: 0 -16px; width: calc(100% + 32px); }
.nav-group-h, .nav-group-h.nav-fold { font-size: 14px !important; line-height: 20px; font-weight: 500; letter-spacing: .007em !important;
  color: var(--md-on-surface-variant) !important; padding: 10px 16px 8px !important; }
button.nav-fold { height: 44px; border-radius: var(--md-shape-full); padding: 0 16px !important; }
button.nav-fold:hover:not(:disabled) { color: var(--md-on-surface) !important; background-color: transparent; }
button.nav-fold > span { display: inline-flex; align-items: center; gap: 6px; }
button.nav-fold .msi { font-size: 20px; }
button.nav-fold small { background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); border-radius: var(--md-shape-full);
  padding: 0 8px; font-size: 11px; line-height: 18px; font-weight: 500; }
.sidebar nav a { height: 48px; padding: 0 16px; gap: 12px; border: 0; border-radius: var(--md-shape-full); color: var(--md-on-surface-variant);
  font-weight: 500; letter-spacing: .007em; }
.sidebar nav a:hover { background-color: transparent; color: var(--md-on-surface); }
.sidebar nav a > span:not(.msi):not(.count) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav a.active { background-color: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 600; }
.sidebar nav a.active .msi { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }
.sidebar nav a.nav-locked { opacity: .38; }
.count { margin-left: auto; background: var(--md-error); color: var(--md-on-error); border-radius: var(--md-shape-full); min-width: 20px; height: 20px;
  padding: 0 6px; font-size: 11px; line-height: 20px; font-weight: 500; text-align: center; }
.sidebar-foot { padding: 12px 16px 16px; border-top: 0; }
.demo-tools-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: var(--md-shape-full);
  background: var(--md-secondary-container); color: var(--md-on-secondary-container); font-weight: 500; }
.demo-tools-btn:hover { background-color: var(--md-secondary-container); }
.demo-tools-btn .msi { font-size: 20px; }
.demo-tools-btn.locked { opacity: 1; background: color-mix(in srgb, var(--md-on-surface) 12%, transparent); color: color-mix(in srgb, var(--md-on-surface) 38%, transparent); }

/* ---- Cards (M3 outlined / filled) ---- */
.card { background: var(--md-surface-container-lowest); border: 1px solid var(--md-surface-container-highest); border-radius: var(--md-shape-l); padding: 16px 20px; }
.card.flush { padding: 0; }
.card h3:first-child { margin-bottom: 12px; }
.card-h { padding: 14px 16px; font-size: 16px; font-weight: 500; border-bottom: 1px solid var(--line); }
.kpis { gap: 12px; }
.kpi { background: var(--md-surface-container-lowest); border: 1px solid var(--md-surface-container-highest); border-radius: var(--md-shape-l); padding: 16px 20px; gap: 6px; }
.kpi small { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .007em; color: var(--md-on-surface-variant); }
.kpi b { font-size: 36px; line-height: 44px; font-weight: 400; letter-spacing: 0; }   /* display small */
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover, .ins-card:hover { box-shadow: var(--md-elev-1); border-color: transparent; }
.lvl-card, .tc-level, .rev, .meta, .refs-box, .tests-col, .demo-tool, .spec-box, .eqp, .tests-pick, .type-preview, .req-levels, .cfg-addtype,
  .formgen, .unit-results, .ho-systems, .imp-table { border-radius: var(--md-shape-m); }
.meta, .refs-box, .tests-col, .spec-box, .eqp, .tests-pick, .type-preview, .cfg-addtype, .ho-sum { background: var(--md-surface-container-low); border-color: transparent; }
.model-specs, .eq-card, .eqp-hint { background: var(--md-surface-container-low); }
.model-specs { border-radius: var(--md-shape-m); }
.tc-level.opt, .tests-col.opt { background: var(--md-surface-container); }
.review-box { background: var(--md-surface-container-low); border: 0; border-radius: var(--md-shape-m); padding: 16px; }
.review-box.fail-box { background: var(--md-error-container); color: var(--md-on-error-container); }
.review { border-left-width: 4px; border-radius: 0 var(--md-shape-s) var(--md-shape-s) 0; }
.review.returned { background: color-mix(in srgb, var(--md-error-container) 45%, transparent); }
.bar, .cellbar { height: 6px; border-radius: var(--md-shape-full); background: var(--md-secondary-container); }
.bar i, .cellbar i { background: var(--md-primary); border-radius: var(--md-shape-full); }
.empty { color: var(--md-on-surface-variant); }

/* ---- Lists / tables ---- */
.table th { background: var(--md-surface-container-low); color: var(--md-on-surface-variant); font-size: 12px; font-weight: 500; letter-spacing: .04em;
  padding: 12px 16px; border-bottom: 1px solid var(--md-outline-variant); }
.table td { padding: 12px 16px; border-bottom-color: var(--md-surface-container-high); }
.card.flush > .table:first-child thead th:first-child, .card.flush > table:first-child th:first-child { border-top-left-radius: var(--md-shape-l); }
.card.flush > .table:first-child thead th:last-child, .card.flush > table:first-child th:last-child { border-top-right-radius: var(--md-shape-l); }
.mini th { color: var(--md-on-surface-variant); font-weight: 500; border-bottom: 1px solid var(--md-outline-variant); }
.mini td { border-bottom-color: var(--md-surface-container-high); }
.clickable:hover td, .tasks li:hover, .trade-table tr.clickable:hover td { background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); }
.trade-table tr.trade-active td, .eqp-item.on { background: color-mix(in srgb, var(--md-secondary-container) 60%, transparent); }
.row-denied td, .imp-table tr.imp-error td { background: color-mix(in srgb, var(--md-error-container) 40%, transparent); }
.row-pending td { background: color-mix(in srgb, var(--amber-bg) 35%, transparent); }
.tasks li { padding: 10px 8px; border-radius: var(--md-shape-s); border-bottom-color: var(--md-surface-container-high); }
.kv th { color: var(--md-on-surface-variant); font-weight: 500; }
.kv td { border-bottom-color: var(--md-surface-container-high); }
.matrix tr.grp td { background: var(--md-surface-container); color: var(--md-on-surface-variant); font-weight: 500; }
.matrix .mine { background: color-mix(in srgb, var(--md-primary-container) 45%, transparent) !important; }
.folder-path { background: var(--md-surface-container-low); }

/* ---- Buttons: outlined (default), filled (primary), tonal (success), outlined error (danger); full-rounded ---- */
.btn { height: 40px; padding: 0 20px; border: 1px solid var(--md-outline); border-radius: var(--md-shape-full); background: transparent; color: var(--md-primary);
  font-size: 14px; font-weight: 500; letter-spacing: .007em; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--md-outline); }
.btn.primary { background-color: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }
.btn.primary:hover { background-color: var(--md-primary); box-shadow: var(--md-elev-1); }
.btn.success { background-color: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { background-color: var(--green); box-shadow: var(--md-elev-1); }
.btn.danger, .btn.danger-outline { background-color: transparent; color: var(--md-error); border-color: var(--md-outline); }
.btn.danger:hover { background-color: transparent; border-color: var(--md-error); }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; gap: 6px; }
.btn.locked, .btn:disabled { background: transparent; border: 1px solid color-mix(in srgb, var(--md-on-surface) 12%, transparent);
  color: color-mix(in srgb, var(--md-on-surface) 38%, transparent); cursor: not-allowed; box-shadow: none; background-image: none; }
.btn.primary:disabled, .btn.primary.locked { background: color-mix(in srgb, var(--md-on-surface) 12%, transparent); border-color: transparent; }
a.btn { text-decoration: none; color: var(--md-primary); }
a.btn.primary { color: var(--md-on-primary); }
.row { gap: 8px; }
.x { border-radius: var(--md-shape-full); color: var(--md-on-surface-variant); min-width: 32px; min-height: 32px; display: inline-grid; place-items: center; }
.modal-h .x { width: 40px; height: 40px; margin: -6px -10px 0 0; }

/* ---- Text fields (M3 outlined, dense 40 px) and selects ---- */
textarea, input[type=text], input:not([type]), input[type=search], input[type=date], input[type=time], input[type=number], input[type=password], input[type=email], select,
  .filters input, .folder-search input, .row input, .stg-field input, .login-form input, .sys-edit input, .reg-cfg input, #fail-reason,
  .table td input, .test-row input, .type-h input, .test-add input, .cal-bar select, .trade-filter select, .me select, .lang-switch {
  font-size: 14px; color: var(--md-on-surface); background-color: var(--md-surface-container-lowest); border: 1px solid var(--md-outline);
  border-radius: var(--md-shape-xs); padding: 8px 12px; min-height: 40px; transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 72px; line-height: 20px; }
.table td input, .matrix select, .rooms-grid .table select { min-height: 32px; padding: 4px 8px; }
.test-add input { border-style: dashed; }
:where(textarea, input, select):hover:not(:focus):not(:disabled) { border-color: var(--md-on-surface); }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); }
:where(textarea, input, select):disabled { color: color-mix(in srgb, var(--md-on-surface) 38%, transparent); border-color: color-mix(in srgb, var(--md-on-surface) 12%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2343474e'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 20px; }
select[multiple] { background-image: none; padding-right: 12px; }
.matrix select, .rooms-grid .table select { padding-right: 28px; background-position: right 4px center; }
.form { gap: 16px; }
.form label, .stg-field, .login-form label { font-size: 12px; font-weight: 500; letter-spacing: .03em; color: var(--md-on-surface-variant); gap: 6px; }
.form label > input, .form label > select, .form label > textarea, .stg-field input, .login-form input { letter-spacing: .015em; }
.form label.inline { color: var(--md-on-surface); font-size: 14px; }
.review-box label { font-size: 12px; font-weight: 500; color: var(--md-on-surface-variant); }
input[type=checkbox], input[type=radio] { accent-color: var(--md-primary); width: 18px; height: 18px; }
progress { accent-color: var(--md-primary); }
.dropzone { border: 2px dashed var(--md-outline-variant); border-radius: var(--md-shape-m); background: var(--md-surface-container-low); }
.dropzone.over { border-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary-container) 50%, transparent); }

/* ---- Tabs (M3 primary tabs) ---- */
.tabs { gap: 0; border-bottom: 1px solid var(--md-surface-container-highest); }
.tabs button { position: relative; height: 48px; padding: 0 16px; border: 0; margin: 0; color: var(--md-on-surface-variant); font-weight: 500; letter-spacing: .007em; }
.tabs button.active { color: var(--md-primary); font-weight: 500; border: 0; }
.tabs button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--md-primary); }

/* ---- Segmented buttons ---- */
.seg { border: 1px solid var(--md-outline); border-radius: var(--md-shape-full); }
.seg button { height: 38px; padding: 0 16px; background: transparent; color: var(--md-on-surface); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--md-outline); }
.seg button.on { background-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.seg button.on::before { content: "check"; font-family: "Material Symbols Rounded"; font-size: 18px; line-height: 1; font-feature-settings: "liga"; }
.tgroup button { border: 1px solid var(--md-outline-variant); border-radius: var(--md-shape-s); background: transparent; color: var(--md-on-surface-variant); height: 28px; padding: 0 10px; font-weight: 500; }
.tgroup button.active { background-color: var(--md-secondary-container); border-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* ---- Chips and status badges (M3 small chips, tonal containers, 8 px corners) ---- */
.badge, .chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--md-shape-s); clip-path: none;
  font-size: 12px; font-weight: 500; letter-spacing: .03em; line-height: 16px; vertical-align: middle; }
.badge::before, .chip::before { content: none; }
.badge.green, .chip.done { background: var(--green-bg); color: #0f3a13; }
.badge.amber, .chip.review { background: var(--amber-bg); color: #3d2e00; }
.badge.red, .chip.returned { background: var(--md-error-container); color: var(--md-on-error-container); }
.badge.orange { background: var(--orange-bg); color: #4a2800; }
.badge.blue, .chip.partial { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.badge.teal { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.badge.grey, .chip.todo { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }
.badge.solid-green { background: var(--green); color: #fff; } .badge.solid-slate { background: var(--md-secondary); color: #fff; }
.chip.optional { background: transparent; color: var(--md-on-surface-variant); border: 1px dashed var(--md-outline-variant); }
.tc-level-h .badge { height: 20px; font-size: 11px; }
.role-badge { border-radius: var(--md-shape-s); padding: 2px 8px; font-weight: 500; letter-spacing: .03em; }
.role-intern { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.role-ae { background: #c8eceb; color: #00201f; } .role-engineer { background: var(--green-bg); color: #0f3a13; }
.role-se { background: var(--amber-bg); color: #3d2e00; } .role-pm { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.role-admin { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); }
.lv { font-family: var(--mono); background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--md-shape-xs); font-weight: 500; }
.uid { background: transparent; border: 1px solid var(--md-outline-variant); color: var(--md-on-surface-variant); border-radius: var(--md-shape-xs); font-weight: 500; }
.ref-chip, .spec-chip { border-color: var(--md-outline-variant); border-radius: var(--md-shape-s); }
.ref-chip i, .spec-chip i { background: var(--md-surface-container-high); border-right-color: var(--md-outline-variant); }
.eq-pill, .test-pill, .unit-chk { border-color: var(--md-outline-variant); border-radius: var(--md-shape-s); background-color: transparent; padding: 2px 8px; }
.eq-pill.pass, .test-pill.pass { border-color: #9fd19b; color: var(--green); }
.eq-pill.fail, .test-pill.fail { border-color: var(--md-error); background: var(--md-error-container); color: var(--md-on-error-container); }
.form label.test-chk { border-color: var(--md-outline-variant); border-radius: var(--md-shape-s); background-color: transparent; color: var(--md-on-surface); font-size: 13px; letter-spacing: .015em; }
.form label.test-chk:has(input:checked) { background-color: var(--md-secondary-container); border-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.unit-chk:has(input:checked) { background: var(--md-error-container); border-color: var(--md-error); color: var(--md-on-error-container); }
.unit-chk.ok:has(input:checked) { background: var(--md-secondary-container); border-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.req-chip { background: var(--md-error); border-radius: var(--md-shape-s); font-weight: 500; }
.opt-chip { background: var(--md-surface-container-high); border-radius: var(--md-shape-s); }
.stg-chip, .stg-status { border-radius: var(--md-shape-s); font-weight: 500; }
.tpend, .tret { border-radius: var(--md-shape-full); font-weight: 500; }
.tpend { background: var(--amber-bg); color: #3d2e00; }
.pcell { border-radius: var(--md-shape-s); }
.pcell.p-done { color: #0f3a13; } .pcell.p-part { color: #3d2e00; } .pcell.p-ret { color: var(--md-on-error-container); }
.act { font-weight: 500; }
.act-submit, .act-revise { color: var(--md-primary); }

/* trade chips: BS 1710 service colours, M3 small shape */
.trade-chip { border-radius: var(--md-shape-xs); font-weight: 500; font-size: 11px; letter-spacing: .04em; padding: 1px 6px; color: #fff; background: var(--md-secondary); }
.trade-chip.t-MVAC, .trade-chip.t-HVAC { background: #3f7a32; }   /* water services: green */
.trade-chip.t-ELV, .trade-chip.t-EL { background: #c4621a; }      /* electrical: orange */
.trade-chip.t-BMS { background: #34799f; }                         /* air / controls: light blue */
.trade-chip.t-FS { background: #b8322a; }                          /* fire: red */
.trade-chip.t-PD { background: #5b4a3d; }                          /* drainage: brown */
.trade-chip[class*="t-"] { color: #fff; }

/* ---- Selection lists: folder tree, T&C settings, storage options ---- */
.troot, .tnode { border-radius: var(--md-shape-full); padding: 8px 12px; }
.tnode { padding-left: 28px; }
.troot:hover, .tnode:hover { background-color: transparent; }
.troot.active, .tnode.active { background-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.tsep { background: var(--md-outline-variant); }
.cfg-sys-row { border-radius: var(--md-shape-m); border: 0; padding: 10px 12px; }
.cfg-sys-row:hover { background-color: transparent; }
.cfg-sys-row.active { background-color: var(--md-secondary-container); }
.cfg-sys-row.active b { color: var(--md-on-secondary-container); }
.cfg-type { border: 1px solid var(--md-outline-variant); background-color: transparent; border-radius: var(--md-shape-s); padding: 8px 14px; color: var(--md-on-surface); }
.cfg-type:hover { border-color: var(--md-outline-variant); }
.cfg-type.active { background-color: var(--md-secondary-container); border-color: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.cfg-type.active small { color: var(--md-on-secondary-container); opacity: .8; }
.cfg-type.add { border-style: dashed; color: var(--md-primary); }
.cfg-type.add.active { background-color: var(--md-primary-container); color: var(--md-on-primary-container); }
.cfg-crumb { color: var(--md-on-surface-variant); font-weight: 500; }
.stg-opt { border: 1px solid var(--md-outline-variant); border-radius: var(--md-shape-m); background-color: var(--md-surface-container-lowest); }
.stg-opt:hover { border-color: var(--md-outline-variant); }
.stg-opt.active { border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); background-color: color-mix(in srgb, var(--md-primary-container) 35%, #fff); }
.col-picker summary { border-color: var(--md-outline); border-radius: var(--md-shape-full); height: 40px; display: flex; align-items: center; padding: 0 16px; color: var(--md-primary); font-weight: 500; }
.col-picker-menu { border: 0; border-radius: var(--md-shape-xs); box-shadow: var(--md-elev-2); background: var(--md-surface-container); padding: 8px 0; }
.col-picker-menu label { padding: 6px 12px; border-radius: 0; }
.col-picker-menu label:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }

/* ---- Stepper ---- */
.step i { width: 24px; height: 24px; background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); font-weight: 500; }
.step.current { color: var(--md-primary); font-weight: 500; } .step.current i { background: var(--md-primary); color: var(--md-on-primary); }
.step.done i { background: var(--green); } .step.bad { font-weight: 500; }
.step-line { background: var(--md-outline-variant); height: 1px; }
.import-step > b { width: 28px; height: 28px; background: var(--md-primary); font-weight: 500; }

/* ---- Dialogs, scrim, snackbars ---- */
.modal-backdrop { background: var(--md-scrim); }
.modal { background: var(--md-surface-container-lowest); border-radius: var(--md-shape-xl); padding: 24px; box-shadow: var(--md-elev-3); }
.modal-h { margin-bottom: 16px; }
.modal-h h2, .modal-h h3 { font-size: 24px; line-height: 32px; font-weight: 400; }   /* headline small */
.modal-f { border-top: 0; padding-top: 8px; margin-top: 24px; }
.docx-preview-box { background: var(--md-surface-container-highest); border-radius: var(--md-shape-m); }
#toasts { right: 24px; bottom: 24px; }
.toast { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); border-radius: var(--md-shape-xs); padding: 14px 16px; min-width: 288px;
  box-shadow: var(--md-elev-3); font-size: 14px; line-height: 20px; border-left: 4px solid var(--md-inverse-primary); }
.toast.success { background: var(--md-inverse-surface); border-left-color: #8fd88a; }
.toast.error { background: var(--md-inverse-surface); border-left-color: #ffb4ab; }

/* banners and notices */
.approval-banner { background: var(--md-error-container); color: var(--md-on-error-container); border: 0; margin: 0 24px 12px; border-radius: var(--md-shape-m); padding: 12px 16px; }
.approval-ctrl.paused, .demo-tool.danger, .min-info { background: color-mix(in srgb, var(--md-error-container) 40%, #fff); border-color: var(--md-error-container); }
.post-box { background: color-mix(in srgb, var(--amber-bg) 40%, #fff); border-color: var(--amber-bg); }
.shared-note, .imp-warn { background: var(--amber-bg); color: #3d2e00; border-radius: var(--md-shape-s); }
.imp-fatal, .ins-clash { background: var(--md-error-container); color: var(--md-on-error-container); border-radius: var(--md-shape-s); }
.demo-tool { border-color: var(--md-outline-variant); }

/* ---- Calendar (M3 date-picker cues: today's date in a filled primary circle) ---- */
.cal-wd div { color: var(--md-on-surface-variant); font-weight: 500; text-align: center; }
.cal-grid { border-color: var(--md-surface-container-highest); border-radius: var(--md-shape-m); overflow: hidden; }
.cal-day { border-color: var(--md-surface-container-highest); }
.cal-day:hover { background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); }
.cal-day.other { background: var(--md-surface-container-low); } .cal-day.other .cal-dn { color: color-mix(in srgb, var(--md-on-surface) 38%, transparent); }
.cal-day.weekend { background: color-mix(in srgb, var(--md-surface-container-low) 60%, #fff); }
.cal-day.is-today { box-shadow: none; }
.cal-dn { font-weight: 500; color: var(--md-on-surface); }
.cal-day.is-today .cal-dn { align-self: flex-start; min-width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: var(--md-shape-full);
  background: var(--md-primary); color: var(--md-on-primary); padding: 0 6px; }
.ins-chip, .ins-card { border-radius: var(--md-shape-xs); }
.ins-chip { border-left-color: var(--md-primary); background: var(--md-primary-container); color: var(--md-on-primary-container); }
.ins-chip:hover { filter: none; }
.st-today.ins-chip { border-color: var(--md-tertiary); background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.ins-card { border-radius: var(--md-shape-s); border-color: var(--md-outline-variant); border-left-color: var(--md-primary); }
.ins-card.st-today { border-left-color: var(--md-tertiary); }
.cal-col { background: var(--md-surface-container-low); border-color: transparent; border-radius: var(--md-shape-m); }
.cal-col.is-today { border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary); }
.cal-col-h { border-bottom-color: var(--md-outline-variant); }

/* ---- Login ---- */
.login { background: radial-gradient(900px 600px at 0% 0%, var(--md-primary-container), transparent 70%),
  radial-gradient(800px 600px at 100% 100%, var(--md-tertiary-container), transparent 70%), var(--md-surface); }
.login-card { background: var(--md-surface-container-lowest); border: 0; border-radius: var(--md-shape-xl); padding: 32px; box-shadow: var(--md-elev-1); }
.brand.big b { font-size: 22px; line-height: 28px; font-weight: 400; }
.user-grid { gap: 12px; }
.user-card { border: 1px solid var(--md-outline-variant); border-radius: var(--md-shape-m); background-color: var(--md-surface-container-lowest); padding: 12px 16px; }
.user-card:hover { border-color: var(--md-outline-variant); background-color: var(--md-surface-container-lowest); }

/* ---- Small screens: drawer becomes a scrolling row of pill items ---- */
@media (max-width: 720px) {
  .sidebar { background: var(--md-surface-container-low); }
  .sidebar nav { padding: 0 12px 8px; gap: 4px; }
  .nav-group + .nav-group { border: 0; margin: 0; padding: 0; }
  .nav-group + .nav-group a { margin: 0; width: auto; }
  .sidebar nav a { height: 40px; padding: 0 14px; gap: 8px; }
  .sidebar nav a .msi { font-size: 20px; }
  .topbar { padding: 8px 16px; }
  .trade-filter { flex: 1 1 100%; margin-left: 0; }
  .trade-filter select { min-width: 0; width: 100%; }
  .content { padding: 4px 16px 40px; }
  .approval-banner { margin: 0 16px 12px; }
  h1 { font-size: 24px; line-height: 32px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* top app bar must fit on one row at 1280 px: cap the trade filter (long trade names are shown in the open list) */
.trade-filter select { width: 220px; min-width: 0; text-overflow: ellipsis; }
.lang-switch { width: auto; min-width: 0; }
/* short column headings stay on one line (CJK would otherwise break per character) */
.mini th { white-space: nowrap; letter-spacing: .02em; }
.topbar { flex-wrap: nowrap; gap: 8px 12px; }
.proj { flex: 0 1 auto; min-width: 0; }
.proj b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar > :not(.proj) { flex-shrink: 0; }
@media (max-width: 1100px) { .topbar { flex-wrap: wrap; } }
/* dense data tables (M3 allows a denser density for data-heavy screens) */
.table th { padding: 10px 12px; }
.table td { padding: 10px 12px; }
.tgroup { flex-wrap: wrap; gap: 6px; }
.tgroup button { height: auto; min-height: 28px; padding: 3px 10px; white-space: nowrap; }
