/* ==========================================================================
   TSM Lab Activity & Monitoring. Approved design: lab-activity-mockup.html (project root).
   ========================================================================== */
:root {
  --bg: #F3F5F9; --panel: #FFFFFF; --line: #E1E6EF; --line2: #EEF1F6; --text: #1B2433; --muted: #7C8AA3; --ink2: #3A4557;
  --green: #1FAE68; --green-bg: #E6F7EE; --amber: #C98A1D; --amber-bg: #FBF1DE; --red: #E14D63; --red-bg: #FCE9EC;
  --blue: #3B6FE0; --blue-bg: #EAF0FE; --navy: #0F1D3E; --teal: #0E9F9A; --teal-bg: #E2F5F4; --gold: #B8913A; --violet: #7B61D9;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: #1F4FB0; }
.num, .mono { font-family: "SF Mono", Consolas, monospace; font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.app { display: flex; min-height: 100vh; }
.side { width: 64px; flex: none; background: linear-gradient(180deg, #112043, #0A1430); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 8px; position: sticky; top: 0; height: 100vh; }
.side .brand img { width: 34px; height: 34px; display: block; margin-bottom: 12px; filter: drop-shadow(0 2px 8px rgba(214,178,94,.35)); }
.side .nav { width: 52px; min-height: 48px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #9FB0D6; text-decoration: none; font-size: 9px; font-weight: 600; }
.side .nav svg { width: 20px; height: 20px; }
.side .nav:hover { background: rgba(255,255,255,.07); color: #fff; }
.side .nav.on { background: linear-gradient(135deg, #0E9F9A, #31C2BC); color: #fff; box-shadow: 0 6px 16px -6px rgba(14,159,154,.8); }
.side .nav.bottom { margin-top: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.top h1 { margin: 0; font-size: 18px; } .top p { margin: 0; font-size: 12px; color: var(--muted); }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.top-right form { margin: 0; }
.chip { font-size: 12px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; white-space: nowrap; }
.chip.log { border-color: #BDE8D2; background: var(--green-bg); color: #0B7A45; font-weight: 600; }
.chip.log::before { content: "\25CF"; margin-right: 6px; animation: blink 1.4s infinite; }
.chip.stale { border-color: #F4C6CE; background: var(--red-bg); color: #B4364A; font-weight: 600; }
@keyframes blink { 50% { opacity: .25; } }
.wrap { padding: 16px 22px 28px; display: flex; flex-direction: column; gap: 16px; max-width: 1560px; width: 100%; margin: 0 auto; }

/* Cards, pills, buttons */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: 0 10px 26px -20px rgba(20,30,50,.25); min-width: 0; }
.card h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill.g { background: var(--green-bg); color: #0B7A45; } .pill.a { background: var(--amber-bg); color: #8A5A00; } .pill.r { background: var(--red-bg); color: #B4364A; }
.pill.b { background: var(--blue-bg); color: var(--blue); } .pill.n { background: #EDF1F7; color: var(--muted); } .pill.t { background: var(--teal-bg); color: #08746F; }
.btn { font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 8px; border: 1px solid #DCE3EF; background: #fff; cursor: pointer; color: var(--ink2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: #B9C4D8; } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.p { background: var(--navy); color: #fff; border-color: var(--navy); } .btn.t { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.lg { font-size: 15px; padding: 12px 22px; border-radius: 10px; } .btn.sm { font-size: 12px; padding: 5px 10px; } .btn.d { color: #B4364A; border-color: #F0C3CB; }
.link { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: #1F4FB0; cursor: pointer; }
.notice { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; padding: 10px 14px; border-radius: 10px; border: 1px solid; }
.notice.ok { background: var(--green-bg); border-color: #BDE8D2; color: #0B6B3E; } .notice.err { background: var(--red-bg); border-color: #F4C6CE; color: #A01D2E; }
.notice button { border: 0; background: none; font-size: 18px; color: inherit; cursor: pointer; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed #D6DEEC; border-radius: 10px; background: #FAFBFE; }

/* Session bar + horizontal timeline */
.session { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.sid { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.sid .code { font-size: 20px; font-weight: 800; }
.meta { display: flex; flex-direction: column; } .meta span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; } .meta b { font-size: 13.5px; }
.timer { text-align: right; } .timer .t { font-size: 34px; font-weight: 800; line-height: 1; color: var(--navy); } .timer span { font-size: 11px; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 18px; }
.step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 6px; cursor: pointer; background: none; border: 0; font: inherit; color: inherit; }
.step::before { content: ""; position: absolute; top: 19px; left: -50%; right: 50%; height: 4px; background: var(--line); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before, .step.cur::before { background: linear-gradient(90deg, var(--teal), #31C2BC); }
.dot { position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; background: #fff; border: 3px solid var(--line); color: var(--muted); }
.step.done .dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.step.skip .dot { background: #EDF1F7; border-color: #C9D2E3; color: var(--muted); }
.step.cur .dot { border-color: var(--teal); color: var(--teal); box-shadow: 0 0 0 6px rgba(14,159,154,.15); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(14,159,154,.06); } }
.step.view .dot { outline: 3px solid var(--navy); outline-offset: 3px; }
.step b { margin-top: 8px; font-size: 13px; } .step small { font-size: 11px; color: var(--muted); display: block; }
.step .dur { margin-top: 4px; font-size: 12px; font-weight: 700; } .step.cur .dur { color: var(--teal); }
.gantt { display: flex; height: 8px; border-radius: 6px; overflow: hidden; margin-top: 16px; background: var(--line2); }
.gantt i { display: block; height: 100%; }
.glegend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 11px; color: var(--muted); }
.glegend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 5px; }

/* Workspace */
.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.f.s2 { grid-column: span 2; } .f.s3 { grid-column: 1 / -1; }
.in { font: inherit; font-size: 13.5px; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 500; padding: 8px 10px; border: 1px solid #DCE3EF; border-radius: 8px; background: #F7F9FC; width: 100%; min-width: 0; }
.in:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,159,154,.15); background: #fff; }
.in:disabled { opacity: .75; }
textarea.in { resize: vertical; }
.sec { font-size: 11px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line2); }
.sec small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.actions .left { margin-right: auto; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.kv div span { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; } .kv div b { font-size: 13.5px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; } tbody tr:last-child td { border-bottom: 0; }
tr.clk { cursor: pointer; } tr.clk:hover td { background: #F8FAFE; }
.scroll { overflow-x: auto; }
.lod { color: #A3AEC4; }
svg.chart { width: 100%; display: block; }
.ctitle { font-size: 11.5px; font-weight: 700; color: var(--ink2); margin: 10px 0 2px; display: flex; justify-content: space-between; gap: 8px; }
.ctitle span { font-weight: 500; color: var(--muted); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; } .legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }

/* Balance */
.bal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.readout { background: #0F1D3E; color: #fff; border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.readout .w { font-size: 46px; font-weight: 800; line-height: 1; } .readout .w small { font-size: 18px; color: #9FB0D6; margin-left: 6px; }
.readout .st { font-size: 12px; font-weight: 700; letter-spacing: .08em; } .readout .st.ok { color: #5FD99A; } .readout .st.wait { color: #F5C36B; } .readout .st.bad { color: #FF9AA8; }
.readout .row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: #9FB0D6; }

/* Instruments */
.drop { border: 2px dashed #B9D9D7; border-radius: 12px; padding: 22px; text-align: center; background: #F6FBFB; color: var(--muted); display: block; }
.drop b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.drop input[type=file] { display: block; margin: 10px auto 0; font-size: 12.5px; }
.status { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; background: var(--teal-bg); margin-bottom: 12px; flex-wrap: wrap; }
.status .big { font-size: 22px; font-weight: 800; color: #08746F; }
.qcs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qc { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 9px; font-size: 13px; }
.qc .ok { color: var(--green); font-weight: 800; } .qc .no { color: var(--red); font-weight: 800; }
.qc input { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }
label.qc { cursor: pointer; }

/* Environment panel */
.envhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.int { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.int select { font: inherit; font-size: 12.5px; padding: 5px 8px; border-radius: 7px; border: 1px solid #DCE3EF; background: #F7F9FC; }
.vals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.v { border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; background: #FAFBFD; min-width: 0; }
.v span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; display: block; }
.v b { font-size: 17px; } .v small { font-size: 11px; color: var(--muted); margin-left: 2px; }
.v.warn { border-color: #F1D59C; background: #FFFAF0; } .v.bad { border-color: #F4C6CE; background: #FFF6F7; }
.envstats td { padding: 6px 8px; }

/* Sessions list */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid #DCE3EF; border-radius: 8px; background: #F7F9FC; min-width: 240px; }

/* Modal (Components/Widgets/Modal.razor) */
.modal-backdrop { position: fixed; inset: 0; z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; overflow-y: auto; background: rgba(15, 29, 62, .55); animation: modalFade .14s ease-out; }
.modal { width: 100%; max-width: var(--modal-w, 640px); max-height: calc(100vh - 6vh - 24px); display: flex; flex-direction: column; background: #FFFFFF; color: #141B26; border-radius: 12px; border-top: 4px solid var(--teal); box-shadow: 0 24px 60px -12px rgba(15, 29, 62, .45); animation: modalRise .16s ease-out; }
.modal:focus { outline: none; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid #E6EAF0; }
.modal-title { flex: 1; min-width: 0; } .modal-title h2 { margin: 2px 0 0; font-size: 18px; }
.modal-kicker { font-family: "SF Mono", Consolas, monospace; font-size: 12px; color: #5B6779; }
.modal-close { flex: none; width: 36px; height: 36px; margin: -4px -8px 0 0; border: 0; border-radius: 8px; background: transparent; font-size: 24px; line-height: 1; color: #5B6779; cursor: pointer; }
.modal-close:hover:not(:disabled) { background: #F1F4F9; color: #141B26; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-error { font-size: 13.5px; padding: 10px 14px; border-radius: 8px; border: 1px solid #F4C6CE; background: #FCE9EC; color: #A01D2E; }
.modal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid #E6EAF0; }
@keyframes modalFade { from { opacity: 0; } }
@keyframes modalRise { from { opacity: 0; transform: translateY(8px); } }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: 10px 18px; background: #FFF4D6; border-top: 1px solid #F1D59C; font-size: 13px; }

@media (max-width: 1150px) { .grid, .bal { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 18px; }
  .form, .qcs, .kv { grid-template-columns: minmax(0, 1fr); } .f.s2 { grid-column: auto; }
  .vals { grid-template-columns: repeat(3, minmax(0, 1fr)); } .session { grid-template-columns: minmax(0, 1fr); } .timer { text-align: left; }
  .modal-backdrop { padding: 0; } .modal { max-width: none; min-height: 100vh; max-height: none; border-radius: 0; }
}
