/* TR & PJP System - styles. Colours follow the Management Dashboard portal (teal header, amber active tab);
   chart colours and status colours follow the validated reference palette of the dataviz skill. */
:root {
  --teal: #1b6577; --teal-d: #175564; --teal-l: #e6f0f2; --accent: #f4a62a;
  --bg: #f3f6f7; --card: #ffffff; --line: #e1e6e8; --line2: #eef2f3;
  --ink: #0f1f26; --ink2: #4a5a61; --muted: #7a888e;
  --good: #0ca30c; --good-t: #006300; --good-bg: #e7f6e7;
  --warn: #fab219; --warn-t: #7a4b00; --warn-bg: #fff4d9;
  --bad: #d03b3b; --bad-t: #a32525; --bad-bg: #fbe9e9;
  --info: #2a78d6; --info-t: #1c5cab; --info-bg: #e8f1fc;
  --r: 10px; --sh: 0 1px 2px rgba(15, 31, 38, .06), 0 2px 8px rgba(15, 31, 38, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.45; }
[hidden] { display: none !important; }
small { color: var(--muted); font-size: 12px; }
a { color: var(--teal); }
h2, h3 { margin: 0; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px; background: #fff; border-bottom: 1px solid var(--line); }
.brand b { display: block; font-size: 17px; color: var(--teal); letter-spacing: .2px; line-height: 1.1; }
.brand span { font-size: 11px; color: var(--muted); }
#tabs { display: flex; align-self: stretch; gap: 2px; }
#tabs [role=tab] { border: 0; background: none; padding: 0 18px; font-weight: 600; color: var(--ink2); border-bottom: 3px solid transparent; cursor: pointer; }
#tabs [role=tab]:hover { background: var(--teal-l); }
#tabs [role=tab].on { color: var(--teal); border-bottom-color: var(--accent); }
.right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
#who { color: var(--ink2); font-weight: 600; }

.notice { background: var(--warn-bg); color: var(--warn-t); border-bottom: 1px solid #f3dfa6; padding: 8px 20px; font-size: 13px; font-weight: 600; }
.notice::before { content: "! "; }

/* ---------- buttons ---------- */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn.pri { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.pri:hover { background: var(--teal-d); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--bad-t); }
.btn:disabled { opacity: .6; cursor: wait; }
.lnk { border: 0; background: none; color: var(--teal); font-weight: 600; cursor: pointer; padding: 2px 4px; }
.lnk:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ---------- login ---------- */
#view-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0b1f2e, var(--teal)); }
.login { width: min(380px, 92vw); background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; }
.login h1 { margin: 0; color: var(--teal); font-size: 22px; }
.login p { margin: 6px 0 14px; color: var(--ink2); font-size: 13px; }
.login label { font-size: 12px; font-weight: 600; margin: 10px 0 4px; color: var(--ink2); }
.login input { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafb; }
.login .btn { margin-top: 18px; padding: 11px; }
#lerr { color: var(--bad-t); font-size: 13px; margin-top: 10px; min-height: 18px; }
.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- performance ---------- */
#view-perf, #view-input { padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--sh); position: sticky; top: 62px; z-index: 10; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg label { display: inline-flex; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 6px 11px; font-size: 13px; font-weight: 600; color: var(--ink2); border-right: 1px solid var(--line); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--teal); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--info); outline-offset: -2px; }
.seg label:hover span { background: var(--teal-l); }
.seg input:checked + span:hover { background: var(--teal-d); }
.cust input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.lvl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lvl select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 600; max-width: 240px; }
.crumb { border: 0; background: none; font-weight: 700; color: var(--teal); cursor: pointer; padding: 4px 2px; }
span.crumb { cursor: default; }
.crumb.on { color: var(--ink); }
.sep { color: var(--muted); }
.cmp { font-size: 12px; color: var(--muted); }
.who { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 18px 2px 10px; }
.who h2 { font-size: 20px; }
.who > span:not(.badge) { color: var(--ink2); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 14px 12px; box-shadow: var(--sh); display: flex; flex-direction: column; min-height: 132px; }
.tl { font-size: 12px; font-weight: 600; color: var(--ink2); }
.tv { font-size: 28px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -.3px; }
.tv small { font-size: 16px; color: var(--muted); font-weight: 600; }
.ts { font-size: 12px; color: var(--muted); flex: 1; }
.tf { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; font-weight: 600; }
.dl.up { color: var(--good-t); } .dl.down { color: var(--bad-t); } .dl.flat { color: var(--muted); font-weight: 500; }
.st-ic { border-radius: 10px; padding: 0 7px; }
.st-ic.good { background: var(--good-bg); color: var(--good-t); }
.st-ic.warn { background: var(--warn-bg); color: var(--warn-t); }
.st-ic.bad { background: var(--bad-bg); color: var(--bad-t); }

.g2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); min-width: 0; }
.card.wide { margin-top: 12px; }
.ch { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ch h3 { font-size: 15px; }
.ch p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.cv { position: relative; }
.foot { font-size: 12px; color: var(--muted); margin: 16px 2px 0; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; color: var(--ink2); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); background: #f8fafb; white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tfoot th { border-top: 1px solid var(--line); border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .c { text-align: center; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td, .tbl tr.click:focus td { background: var(--teal-l); }
.tbl td:first-child, .tbl th:first-child { position: sticky; left: 0; background: inherit; }
.tbl tbody tr { background: #fff; }
.empty { color: var(--muted); font-size: 13px; padding: 12px 2px; margin: 0; }
.empty.center { text-align: center; padding: 60px 10px; }
.muted { color: var(--muted); }
.pc { font-weight: 650; }
.pc.good { color: var(--good-t); } .pc.warn { color: var(--warn-t); } .pc.bad { color: var(--bad-t); }
.ar { font-size: 10px; margin-left: 4px; } .ar.up { color: var(--good-t); } .ar.down { color: var(--bad-t); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #eef1f2; color: var(--ink2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good-t); }
.badge.warn { background: var(--warn-bg); color: var(--warn-t); }
.badge.bad { background: var(--bad-bg); color: var(--bad-t); }
.badge.info { background: var(--info-bg); color: var(--info-t); }
.badge.muted { background: #f1f3f4; color: var(--muted); }
.mk { display: inline-block; width: 18px; text-align: center; font-weight: 700; }
.mk.good { color: var(--good-t); } .mk.bad { color: var(--bad-t); } .mk.muted { color: var(--muted); }
.dsc { white-space: nowrap; }
.legend-inline { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

/* ---------- input ---------- */
.in-wrap { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
.in-menu { position: sticky; top: 70px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; box-shadow: var(--sh); max-height: calc(100vh - 86px); overflow: auto; }
.mg { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 10px 8px 4px; }
.mi { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; }
.mi b { display: block; font-size: 13px; color: var(--ink); }
.mi small { font-size: 11px; }
.mi:hover { background: var(--teal-l); }
.mi.on { background: var(--teal-l); border-left-color: var(--accent); }
.mi.on b { color: var(--teal); }
.mi.today b::after { content: "today"; font-size: 10px; font-weight: 700; color: var(--warn-t); background: var(--warn-bg); border-radius: 8px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.in-main { min-width: 0; }
.guide { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; background: linear-gradient(135deg, var(--teal), #237f93); color: #fff; border-radius: var(--r); padding: 14px 16px; }
.guide b { font-size: 15px; }
.guide p { margin: 4px 0 0; font-size: 13px; opacity: .92; max-width: 720px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; max-width: 520px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 12px; background: #fff; color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
.guide .chip { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .25); }
.chip.ok { background: var(--good-bg); color: var(--good-t); border-color: #c9ebc9; }
.guide .chip.ok { background: #fff; color: var(--good-t); border-color: #fff; }
.fh { margin: 18px 0 10px; }
.fh h2 { font-size: 19px; }
.doc { margin: 4px 0 0; color: var(--ink2); font-size: 13px; border-left: 3px solid var(--accent); padding-left: 10px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 10px 0; }
.bar label { font-size: 12px; font-weight: 600; color: var(--ink2); display: inline-flex; align-items: center; gap: 6px; }
.bar select, .bar input[type=date], .bar input[type=search] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 500; color: var(--ink); }
.bar input[type=search] { min-width: 220px; margin-left: auto; }
.daychips { display: flex; gap: 4px; flex-wrap: wrap; }
.st { font-size: 15px; margin: 20px 0 8px; }
.st small { font-weight: 500; margin-left: 6px; }
.note { font-size: 12px; color: var(--muted); }
.form-card { margin-top: 10px; }
.ft { font-size: 15px; margin: 0 0 10px; }
.ft small { font-weight: 500; }
form.rec .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 14px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.w2 { grid-column: span 2; }
.sec { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--teal); border-bottom: 1px solid var(--line); padding: 8px 0 4px; margin-top: 4px; }
.lb { font-size: 12px; font-weight: 600; color: var(--ink2); }
.lb label { cursor: pointer; }
.rq { color: var(--bad-t); font-style: normal; margin-left: 2px; }
.fld input:not([type=radio]), .fld select, .fld textarea, .entry input, .entry select { width: 100%; padding: 8px 9px; border: 1px solid #cfd8db; border-radius: 7px; background: #fff; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .entry input:focus, .entry select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px rgba(27, 101, 119, .15); }
.fld textarea { resize: vertical; }
.fld .seg { width: fit-content; }
.fld .seg span { padding: 7px 14px; }
.entry td { padding: 4px; min-width: 120px; }
.entry td:last-child { min-width: 0; }
.entry td.nm { min-width: 170px; }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.errbox { background: var(--bad-bg); color: var(--bad-t); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.errbox ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- dialog & toasts ---------- */
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(920px, 96vw); max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(11, 31, 46, .45); }
dialog .x { position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; gap: 10px; align-items: center; background: #0f1f26; color: #fff; border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 420px; transition: opacity .5s, transform .5s; font-size: 13px; }
.toast .ti { width: 20px; height: 20px; border-radius: 50%; background: var(--good); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.toast.err .ti { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

@media (max-width: 900px) {
  .in-wrap { grid-template-columns: 1fr; }
  .in-menu { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 4px; }
  .mg { width: 100%; }
  .mi { width: auto; }
  .mi small { display: none; }
  #top { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .right { margin-left: 0; }
  .filters { position: static; }
  .fld.w2 { grid-column: auto; }
}
@media print { #top, .filters, .in-menu, .acts { display: none !important; } .card, .tile { box-shadow: none; break-inside: avoid; } }
