:root {
  --brand-900: #0f2c31; --brand-800: #173C42; --brand-700: #1d4f56; --brand-600: #167568; --brand-500: #1f8d7d;
  --brand-100: #e3f1ee; --brand-50: #f1f8f6;
  --ink: #15262a; --ink-2: #3c5054; --muted: #66797d; --line: #dbe4e3; --line-2: #e9efee;
  --bg: #f4f7f7; --card: #ffffff;
  --red: #b23a2b; --red-bg: #fbeae6; --amber: #a86512; --amber-bg: #fdf1dc; --green: #1b7a4b; --green-bg: #e2f4ea;
  --blue: #2a5d99; --blue-bg: #e5eefa;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 44, 49, .06);
  --shadow: 0 1px 2px rgba(15, 44, 49, .05), 0 4px 16px rgba(15, 44, 49, .06);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.01em; color: var(--brand-900); font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--brand-900); font-weight: 650; }
h3 { font-size: 11.5px; margin: 18px 0 8px; color: var(--brand-600); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--brand-800), var(--brand-900)); color: #cfe4e0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand img { border-radius: 8px; }
.brand-name { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand-sub { color: #9cc4bd; font-size: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #7fa9a2; padding: 14px 10px 6px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: #d4e7e3; font-weight: 500; }
.side-nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.side-nav a.active { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 3px 0 0 #6fd1bf; }
.side-nav a .badge { margin-left: auto; background: #6fd1bf; color: var(--brand-900); border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px; border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #6fd1bf; color: var(--brand-900); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.side-user-text { min-width: 0; flex: 1; }
.who-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { color: #9cc4bd; font-size: 11.5px; }
.side-user-actions { display: flex; gap: 2px; }
.icon-btn { background: none; border: 0; color: inherit; padding: 7px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.mobilebar { display: none; }
.content { padding: 28px 32px 64px; max-width: 1360px; width: 100%; outline: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 44, 49, .45); }
  .mobilebar { display: flex; align-items: center; gap: 8px; background: var(--brand-800); color: #fff; padding: 8px 12px; position: sticky; top: 0; z-index: 20; }
  .content { padding: 20px 16px 48px; }
}

/* ---------- page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 760px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-600); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- layout */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1150px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g-2-1 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .g2, .g3, .g4, .g-2-1 { grid-template-columns: 1fr; } }
.mb { margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- KPIs */
.kpi { position: relative; overflow: hidden; }
.kpi .k-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-600); }
.kpi .value { font-size: 30px; font-weight: 700; color: var(--brand-900); margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .value.bad { color: var(--red); } .kpi .value.good { color: var(--green); }
.kpi .note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- status */
.status-strip { display: flex; gap: 22px; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.status-strip .item { min-width: 120px; }
.status-strip .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.status-strip .v { font-weight: 650; color: var(--brand-900); margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f2; color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.s-done { background: var(--green-bg); color: var(--green); }
.pill.s-progress { background: var(--blue-bg); color: var(--blue); }
.pill.s-blocked { background: var(--red-bg); color: var(--red); }
.pill.s-open { background: var(--amber-bg); color: var(--amber); }
.pill.gate { background: var(--brand-800); color: #fff; }
.pill.gate::before { display: none; }

/* ---------- tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 11.5px; color: var(--muted); font-weight: 650; background: #f6f9f9; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover td { background: #fafcfc; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: var(--brand-50); }
tr.section td { background: #fff; padding-top: 4px; }
tr.section td h3 { margin: 10px 0 2px; }
.card table td:first-child, .card table th:first-child { padding-left: 4px; }
.card .tablewrap table td:first-child, .card .tablewrap table th:first-child { padding-left: 12px; }
td .sub { font-size: 12px; color: var(--muted); }

/* ---------- buttons and forms */
button, .btn { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--brand-600); background: var(--brand-600); color: #fff;
  padding: 8px 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; line-height: 1.3; }
button:hover, .btn:hover { background: var(--brand-700); border-color: var(--brand-700); text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand-700); border-color: #c4d6d3; }
button.secondary:hover, .btn.secondary:hover { background: var(--brand-50); }
button.danger { background: #fff; color: var(--red); border-color: #ebc1b8; }
button.danger:hover { background: var(--red-bg); }
button:disabled { opacity: .5; cursor: default; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }
button.icon-btn { border: 0; background: none; font-weight: normal; padding: 7px; }
.content button.icon-btn { color: var(--muted); }
.content button.icon-btn:hover { background: var(--brand-50); color: var(--brand-700); }
input, select, textarea { font: inherit; border: 1px solid #cbd8d6; border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); width: 100%; }
input:hover, select:hover, textarea:hover { border-color: #aac1bd; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(22, 117, 104, .18); border-color: var(--brand-600); }
input:disabled { background: #f6f9f9; color: var(--ink-2); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.changed { background: #fff8e6; border-color: #e6c77f; }
input.dirty { background: var(--brand-100); border-color: var(--brand-600); }
label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.fields { display: grid; gap: 12px 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fields .wide { grid-column: 1 / -1; } .fields .half { grid-column: span 2; }
.search { position: relative; max-width: 320px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; }

/* ---------- progress / plan */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-600), var(--brand-500)); width: 0; border-radius: 999px; }
.phase { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.phase:last-child { border-bottom: 0; padding-bottom: 0; }
.phase .t { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.phase.current .t span:first-child { color: var(--brand-600); }
.board { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .board { grid-template-columns: 1fr; } }
.column { background: #eaf0ef; border-radius: var(--radius); padding: 14px; }
.column.current { background: var(--brand-100); box-shadow: inset 0 0 0 2px rgba(22, 117, 104, .35); }
.column-head { display: flex; justify-content: space-between; align-items: baseline; margin: 2px 4px 12px; }
.column-head .d { font-size: 12px; color: var(--muted); }
.task { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.task.gate { border-color: var(--brand-700); box-shadow: inset 4px 0 0 var(--brand-700), var(--shadow-sm); }
.task .tt { font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: flex-start; }
.task .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.task .meta .full { grid-column: 1 / -1; }
.task .meta label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.task .meta input, .task .meta select { padding: 5px 8px; font-size: 13px; }
.stamp { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* ---------- charts */
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); border: 1px dashed #c9d7d5; border-radius: var(--radius-sm); background: #fbfdfd; }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* ---------- facility cards */
.fac-card .name { font-weight: 700; color: var(--brand-900); font-size: 15px; }
.fac-card .role { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.fac-card dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
.fac-card dt { color: var(--ink-2); } .fac-card dd { margin: 0; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- inputs page */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid #c9d8d5; background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.chip:hover { border-color: var(--brand-600); color: var(--brand-700); text-decoration: none; }
.inputs-table td:first-child { width: 44%; }
.inputs-table td.f { width: 15%; }
.note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.savebar { position: sticky; bottom: 16px; display: flex; justify-content: flex-end; margin-top: 14px; pointer-events: none; }
.savebar .inner { pointer-events: auto; display: flex; gap: 10px; align-items: center; background: var(--brand-900); color: #fff; padding: 10px 12px 10px 18px;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 44, 49, .3); }
.savebar .inner button.secondary { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }

/* ---------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-art { background: radial-gradient(1200px 600px at 10% 10%, #1f6d66 0%, var(--brand-800) 45%, var(--brand-900) 100%); color: #d7ebe7;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { color: #fff; font-size: 34px; max-width: 520px; margin-top: 70px; line-height: 1.2; }
.login-art p { max-width: 480px; font-size: 15.5px; color: #b7d6d0; }
.login-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; max-width: 460px; }
.login-art li { display: flex; gap: 12px; align-items: flex-start; }
.login-art li svg { color: #6fd1bf; margin-top: 2px; }
.login-form { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-form form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 22px; margin-bottom: 4px; }
.login-form .field { margin-bottom: 14px; }
.login-form button { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 10px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { padding: 28px; } .login-art h1 { margin-top: 18px; font-size: 26px; } .login-art ul { display: none; } }

/* ---------- dialog, toast */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(780px, 94vw); max-height: 90vh; box-shadow: 0 24px 70px rgba(0, 0, 0, .28); color: var(--ink); }
dialog::backdrop { background: rgba(15, 44, 49, .5); }
dialog form { padding: 24px 26px; }
dialog h2 { font-size: 18px; margin-bottom: 4px; }
dialog .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-2); }
dialog .foot .right { display: flex; gap: 8px; margin-left: auto; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--brand-900); color: #fff; padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow); z-index: 50; font-size: 13.5px; font-weight: 500; }
.toast.error { background: var(--red); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #eef3f2, #f7fafa, #eef3f2); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

@media print {
  .sidebar, .mobilebar, .actions, .savebar { display: none !important; }
  .shell { display: block; } .content { padding: 0; } .card { break-inside: avoid; box-shadow: none; }
}
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
.inputs-table { min-width: 760px; }
.inputs-table td.f { min-width: 120px; }
.inputs-table input.num { min-width: 100px; }
@media (max-width: 1250px) { .g-2-1 { grid-template-columns: 1fr; } }
.model-table { min-width: 620px; }
.model-table td:first-child { min-width: 240px; }

/* ---------- weekly log entry */
dialog.wide { width: min(1180px, 96vw); }
.entry-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .entry-grid { grid-template-columns: 1fr; } }
.entry-main h3:first-child { margin-top: 4px; }
.entry-live { position: sticky; top: 0; }
.live-card { background: var(--brand-900); color: #d7ebe7; border-radius: 12px; padding: 16px 18px; }
.live-title { color: #fff; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; margin: 4px 0 10px; }
.live-card dl { margin: 0 0 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13px; }
.live-card dt { color: #a9cbc4; } .live-card dd { margin: 0; text-align: right; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-total { display: flex; justify-content: space-between; border-top: 1px solid rgba(255, 255, 255, .18); padding: 10px 0 14px; margin-bottom: 4px; color: #fff; }
.live-total b { font-size: 18px; }
.live-card .neg { color: #ffb4a6; } .live-card .pos { color: #9fe0d4; }
.cost-table td { vertical-align: middle; }
.cost-table td.cost-in { width: 150px; }
.cost-table td.cost-mode { width: 90px; text-align: right; }
input.auto { background: var(--brand-50); color: var(--brand-700); font-weight: 600; border-style: dashed; }
.switch { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.switch input { width: auto; accent-color: var(--brand-600); }
.calc { padding: 7px 10px; border: 1px dashed #cbd8d6; border-radius: 8px; background: var(--brand-50); text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- import */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed #bfd2cf; border-radius: 12px;
  padding: 26px; background: var(--brand-50); cursor: pointer; text-align: center; margin-bottom: 12px; font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--brand-600); background: var(--brand-100); }
.dropzone span:first-of-type { display: inline-flex; gap: 8px; align-items: center; color: var(--brand-700); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.map-table td { vertical-align: middle; }
.map-table td:first-child { width: 30%; }
.map-table select { min-width: 180px; }
.import-actions { margin-top: 14px; justify-content: flex-end; }
.import-actions .grow { flex: 1; min-width: 220px; max-width: 360px; }
#recognised { margin-top: 8px; color: var(--green); display: flex; gap: 6px; align-items: center; }

/* ---------- completeness */
.completeness .cell { display: inline-block; min-width: 46px; text-align: center; padding: 2px 8px; border-radius: 6px; font-weight: 650; font-size: 12.5px; cursor: default; }
.c-full { background: var(--green-bg); color: var(--green); }
.c-part { background: var(--amber-bg); color: var(--amber); }
.c-none { background: var(--red-bg); color: var(--red); }
.completeness tr.current td { background: var(--brand-50); }
.completeness .fillcell { min-width: 150px; display: flex; align-items: center; gap: 8px; }
.completeness .fillcell .bar { flex: 1; }
.legend i.lg { width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; }
.neg-text { color: var(--red); }
