/* ═══════════════════════════════════════════════════════════════
   WWTP DSS — Application Stylesheet
   Aesthetic: Industrial precision. Monospace data, blueprint grid.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

:root {
  --wwtp-bg:          #0d1117;
  --wwtp-bg-2:        #161b22;
  --wwtp-bg-3:        #1c2128;
  --wwtp-border:      #30363d;
  --wwtp-border-2:    #3d444d;
  --wwtp-text:        #e6edf3;
  --wwtp-text-muted:  #7d8590;
  --wwtp-text-dim:    #4d5566;
  --wwtp-accent:      #1f6feb;
  --wwtp-accent-2:    #388bfd;
  --wwtp-success:     #3fb950;
  --wwtp-warning:     #d29922;
  --wwtp-danger:      #f85149;
  --wwtp-info:        #58a6ff;
  --wwtp-purple:      #bc8cff;
  --wwtp-teal:        #39d353;
  --wwtp-orange:      #db6d28;
  --wwtp-font:        'IBM Plex Sans', system-ui, sans-serif;
  --wwtp-mono:        'IBM Plex Mono', 'Courier New', monospace;
  --wwtp-radius:      6px;
  --wwtp-shadow:      0 1px 3px rgba(0,0,0,.4);
}

#wwtp-dss-root * { box-sizing: border-box; }

#wwtp-dss-root {
  font-family: var(--wwtp-font);
  background:  var(--wwtp-bg);
  color:       var(--wwtp-text);
  min-height:  100vh;
  font-size:   14px;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────── */
.wwtp-app { display: flex; height: 100vh; overflow: hidden; }

.wwtp-sidebar {
  width: 240px; min-width: 240px;
  background: var(--wwtp-bg-2);
  border-right: 1px solid var(--wwtp-border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.wwtp-main {
  flex: 1; overflow-y: auto;
  background: var(--wwtp-bg);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.wwtp-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--wwtp-border);
}
.wwtp-logo {
  font-family: var(--wwtp-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--wwtp-info);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.wwtp-logo-sub {
  font-size: 10px;
  color: var(--wwtp-text-muted);
  margin-top: 2px;
}

.wwtp-nav { padding: 8px 0; }
.wwtp-nav-section {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--wwtp-text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.wwtp-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  cursor: pointer;
  color: var(--wwtp-text-muted);
  font-size: 13px;
  border: none; background: none; width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
}
.wwtp-nav-item:hover { background: var(--wwtp-bg-3); color: var(--wwtp-text); }
.wwtp-nav-item.active { background: rgba(31,111,235,.15); color: var(--wwtp-accent-2); }
.wwtp-nav-item .nav-icon { width: 16px; text-align: center; font-size: 14px; }
.wwtp-nav-item .nav-badge {
  margin-left: auto;
  background: var(--wwtp-accent);
  color: #fff;
  font-size: 10px;
  font-family: var(--wwtp-mono);
  padding: 1px 5px;
  border-radius: 10px;
}

/* ── Project list ─────────────────────────────────────────────── */
.wwtp-project-list { padding: 8px; flex: 1; }
.wwtp-project-card {
  padding: 10px;
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.wwtp-project-card:hover { border-color: var(--wwtp-border-2); background: var(--wwtp-bg-3); }
.wwtp-project-card.active { border-color: var(--wwtp-accent); background: rgba(31,111,235,.08); }
.wwtp-project-card-name { font-size: 12px; font-weight: 500; color: var(--wwtp-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wwtp-project-card-ref { font-family: var(--wwtp-mono); font-size: 10px; color: var(--wwtp-text-muted); margin-top: 2px; }
.wwtp-project-card-status {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 4px;
  font-family: var(--wwtp-mono);
  text-transform: uppercase;
}
.status-draft    { background: rgba(125,133,144,.2); color: var(--wwtp-text-muted); }
.status-in_progress { background: rgba(31,111,235,.2); color: var(--wwtp-info); }
.status-completed { background: rgba(63,185,80,.2); color: var(--wwtp-success); }

/* ── Main content area ────────────────────────────────────────── */
.wwtp-page { padding: 24px; max-width: 1200px; }
.wwtp-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--wwtp-border);
}
.wwtp-page-title { font-size: 20px; font-weight: 500; }
.wwtp-page-subtitle { font-size: 13px; color: var(--wwtp-text-muted); margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────── */
.wwtp-card {
  background: var(--wwtp-bg-2);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  margin-bottom: 16px;
}
.wwtp-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--wwtp-border);
}
.wwtp-card-title {
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.wwtp-card-body { padding: 16px; }

/* ── Grid ────────────────────────────────────────────────────── */
.wwtp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wwtp-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.wwtp-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── Form elements ───────────────────────────────────────────── */
.wwtp-field { margin-bottom: 14px; }
.wwtp-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--wwtp-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 5px;
}
.wwtp-label .wwtp-unit {
  font-weight: 400;
  color: var(--wwtp-text-dim);
  font-family: var(--wwtp-mono);
  margin-left: 4px;
}
.wwtp-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--wwtp-bg-3);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  color: var(--wwtp-text);
  font-family: var(--wwtp-mono);
  font-size: 13px;
  transition: border-color .12s;
}
.wwtp-input:focus {
  outline: none;
  border-color: var(--wwtp-accent);
  box-shadow: 0 0 0 3px rgba(31,111,235,.15);
}
.wwtp-input.assumed { border-color: var(--wwtp-warning); background: rgba(210,153,34,.06); }
.wwtp-input.error   { border-color: var(--wwtp-danger); }

.wwtp-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--wwtp-bg-3);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  color: var(--wwtp-text);
  font-size: 13px;
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.wwtp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--wwtp-radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .12s;
  font-family: var(--wwtp-font);
}
.wwtp-btn-primary   { background: var(--wwtp-accent); color: #fff; border-color: var(--wwtp-accent); }
.wwtp-btn-primary:hover { background: var(--wwtp-accent-2); }
.wwtp-btn-secondary { background: var(--wwtp-bg-3); color: var(--wwtp-text); border-color: var(--wwtp-border-2); }
.wwtp-btn-secondary:hover { border-color: var(--wwtp-text-muted); }
.wwtp-btn-danger    { background: rgba(248,81,73,.1); color: var(--wwtp-danger); border-color: var(--wwtp-danger); }
.wwtp-btn-success   { background: rgba(63,185,80,.1); color: var(--wwtp-success); border-color: var(--wwtp-success); }
.wwtp-btn-sm        { padding: 4px 10px; font-size: 12px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.wwtp-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--wwtp-radius);
  font-size: 12px;
  margin-bottom: 10px;
  line-height: 1.6;
}
.wwtp-alert-error   { background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.3); color: #ff7b72; }
.wwtp-alert-warning { background: rgba(210,153,34,.1); border: 1px solid rgba(210,153,34,.3); color: #e3b341; }
.wwtp-alert-info    { background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.3); color: var(--wwtp-info); }
.wwtp-alert-success { background: rgba(63,185,80,.1); border: 1px solid rgba(63,185,80,.3); color: var(--wwtp-success); }
.wwtp-alert-icon    { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* ── Treatment train ─────────────────────────────────────────── */
.wwtp-train-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 16px 0;
}
.wwtp-train-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 160px;
}
.wwtp-train-node {
  width: 140px;
  background: var(--wwtp-bg-3);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, transform .1s;
  position: relative;
}
.wwtp-train-node:hover { border-color: var(--wwtp-accent); transform: translateY(-2px); }
.wwtp-train-node.selected { border-color: var(--wwtp-accent); background: rgba(31,111,235,.12); }
.wwtp-train-node.has-warning { border-color: var(--wwtp-warning); }
.wwtp-train-node.has-error   { border-color: var(--wwtp-danger); }

.wwtp-train-node-icon { font-size: 22px; margin-bottom: 6px; }
.wwtp-train-node-type {
  font-size: 9px;
  font-family: var(--wwtp-mono);
  color: var(--wwtp-text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}
.wwtp-train-node-name { font-size: 11px; font-weight: 500; color: var(--wwtp-text); }
.wwtp-train-node-tech { font-size: 10px; color: var(--wwtp-accent-2); margin-top: 3px; }
.wwtp-train-connector {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 4px;
  position: relative;
}
.wwtp-train-connector::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--wwtp-border) 0%, var(--wwtp-border-2) 100%);
  position: relative;
}
.wwtp-train-connector-arrow {
  position: absolute;
  right: -1px;
  color: var(--wwtp-border-2);
  font-size: 14px;
}
.wwtp-compat-badge {
  position: absolute;
  top: -8px; left: 50%; transform: translateX(-50%);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 10px;
  font-family: var(--wwtp-mono);
  white-space: nowrap;
}
.compat-ok      { background: rgba(63,185,80,.2);  color: var(--wwtp-success); }
.compat-warn    { background: rgba(210,153,34,.2); color: var(--wwtp-warning); }
.compat-error   { background: rgba(248,81,73,.2);  color: var(--wwtp-danger); }

/* ── Sizing results table ─────────────────────────────────────── */
.wwtp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wwtp-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--wwtp-bg-3);
  border-bottom: 1px solid var(--wwtp-border);
  font-size: 10px;
  font-weight: 600;
  color: var(--wwtp-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: var(--wwtp-mono);
}
.wwtp-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--wwtp-border);
  vertical-align: top;
}
.wwtp-table tr:hover td { background: var(--wwtp-bg-3); }
.wwtp-table .val-col {
  font-family: var(--wwtp-mono);
  font-weight: 500;
  color: var(--wwtp-info);
  white-space: nowrap;
}
.wwtp-table .unit-col {
  font-family: var(--wwtp-mono);
  color: var(--wwtp-text-dim);
  font-size: 11px;
}
.wwtp-table .ref-col { color: var(--wwtp-text-muted); font-size: 11px; }

/* ── KPI cards ───────────────────────────────────────────────── */
.wwtp-kpi {
  background: var(--wwtp-bg-2);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  padding: 16px;
  text-align: center;
}
.wwtp-kpi-value {
  font-family: var(--wwtp-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--wwtp-info);
  line-height: 1.2;
}
.wwtp-kpi-label { font-size: 11px; color: var(--wwtp-text-muted); margin-top: 4px; }
.wwtp-kpi-unit  { font-family: var(--wwtp-mono); font-size: 11px; color: var(--wwtp-text-dim); }

/* ── Mass loading bars ───────────────────────────────────────── */
.wwtp-mass-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wwtp-mass-bar-label { width: 80px; font-family: var(--wwtp-mono); font-size: 11px; color: var(--wwtp-text-muted); text-align: right; }
.wwtp-mass-bar-track { flex: 1; height: 8px; background: var(--wwtp-bg-3); border-radius: 4px; overflow: hidden; }
.wwtp-mass-bar-fill  { height: 100%; border-radius: 4px; background: var(--wwtp-accent); transition: width .4s ease; }
.wwtp-mass-bar-val   { width: 90px; font-family: var(--wwtp-mono); font-size: 11px; color: var(--wwtp-info); }

/* ── Compliance table ─────────────────────────────────────────── */
.wwtp-compliance-row td:first-child { font-family: var(--wwtp-mono); font-weight: 500; }
.wwtp-pass   { color: var(--wwtp-success); }
.wwtp-fail   { color: var(--wwtp-danger); }
.wwtp-unknown{ color: var(--wwtp-text-muted); }

/* ── Tabs ────────────────────────────────────────────────────── */
.wwtp-tabs { display: flex; border-bottom: 1px solid var(--wwtp-border); margin-bottom: 16px; }
.wwtp-tab {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--wwtp-text-muted);
  border-bottom: 2px solid transparent;
  border: none; background: none;
  font-family: var(--wwtp-font);
  transition: all .12s;
  margin-bottom: -1px;
}
.wwtp-tab:hover { color: var(--wwtp-text); }
.wwtp-tab.active { color: var(--wwtp-accent-2); border-bottom-color: var(--wwtp-accent-2); }

/* ── Blueprint grid background ───────────────────────────────── */
.wwtp-main {
  background-image:
    linear-gradient(rgba(31,111,235,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,111,235,.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── Loading spinner ─────────────────────────────────────────── */
.wwtp-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--wwtp-border-2);
  border-top-color: var(--wwtp-accent);
  border-radius: 50%;
  animation: wwtp-spin .6s linear infinite;
}
@keyframes wwtp-spin { to { transform: rotate(360deg); } }

/* ── Misc utilities ──────────────────────────────────────────── */
.wwtp-mono   { font-family: var(--wwtp-mono); }
.wwtp-muted  { color: var(--wwtp-text-muted); }
.wwtp-flex   { display: flex; align-items: center; }
.wwtp-gap-8  { gap: 8px; }
.wwtp-gap-16 { gap: 16px; }
.wwtp-mb-16  { margin-bottom: 16px; }
.wwtp-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--wwtp-text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 12px;
  font-family: var(--wwtp-mono);
}

.wwtp-score-bar {
  display: flex; gap: 2px; align-items: center;
}
.wwtp-score-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--wwtp-border-2);
}
.wwtp-score-dot.filled { background: var(--wwtp-accent); }

/* Login notice */
.wwtp-login-notice {
  padding: 24px;
  background: var(--wwtp-bg-2);
  border: 1px solid var(--wwtp-border);
  border-radius: var(--wwtp-radius);
  color: var(--wwtp-text-muted);
}
.wwtp-login-notice a { color: var(--wwtp-accent-2); }
