:root {
  --ink: #212529;
  --muted: #61666d;
  --surface: #fff;
  --bg: #f8f9fa;
  --border: #d3d7dc;
  --brand: #f29559;
  --blue: #2563eb;
  --green: #16875d;
  --red: #b42318;
  --soft-blue: #edf4ff;
  --soft-green: #eaf7f1;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.portal-body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  margin: 0;
  overflow: hidden;
}
.portal-navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  left: 0;
  min-height: 60px;
  padding: 10px 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1030;
}
.portal-brand { color: var(--ink); font-size: 1.2rem; font-weight: 700; }
.portal-brand span, .login-brand span { color: var(--brand); }
.portal-brand em, .login-brand em { color: #4b4b4b; font-style: normal; font-weight: 600; }
.portal-navbar .nav-link { color: #4b4b4b; padding-bottom: 4px; padding-top: 4px; }
.portal-navbar .nav-link:hover { color: var(--blue); }
.portal-userbox { align-items: center; display: flex; gap: 12px; }
.portal-userbox form { margin: 0; }
.portal-main {
  bottom: 36px;
  left: 0;
  overflow: auto;
  padding: 20px;
  position: absolute;
  right: 0;
  top: 60px;
}
.portal-main.is-login { bottom: 0; display: grid; place-items: center; top: 0; }
.portal-footer {
  background: #f0f0f0;
  border-top: 1px solid var(--border);
  bottom: 0;
  color: var(--muted);
  font-size: .72rem;
  height: 36px;
  left: 0;
  padding: 9px 20px;
  position: fixed;
  right: 0;
}
h1 { font-size: clamp(1.55rem, 3vw, 2.15rem); font-weight: 700; margin: 2px 0 4px; }
h2 { font-size: 1rem; font-weight: 700; margin: 0; }
p { color: var(--muted); }
.eyebrow { color: var(--brand); font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.page-heading { align-items: end; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 16px; }
.page-heading p { margin: 0; }
.page-heading.compact { align-items: center; }
.generate-bar { align-items: end; display: grid; gap: 8px; grid-template-columns: 155px minmax(190px, 1fr) auto; }
.generate-period { background: #fff; border: 1px solid var(--border); border-radius: 4px; min-height: 38px; padding: 7px 9px; }
.generate-period label { color: var(--muted); display: block; font-size: .62rem; line-height: 1; margin: 0; }
.generate-period strong { font-size: .8rem; }
.generate-bar label, .portal-form label { display: block; font-size: .73rem; font-weight: 700; margin-bottom: 4px; }
input, select, textarea {
  background: #fff;
  border: 1px solid #bfc5cc;
  border-radius: 4px;
  min-height: 38px;
  padding: 7px 9px;
  width: 100%;
}
input[type="checkbox"] { min-height: auto; width: auto; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 7px rgb(15 23 42 / 5%);
  margin-bottom: 16px;
  padding: 16px;
}
.panel-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 10px; }
.metric-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.metric-card { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 5px; display: grid; padding: 12px 14px; }
.metric-card span { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.metric-card strong { font-size: 1.35rem; }
.metric-card small { color: var(--muted); }
.dashboard-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); }
.portal-table { font-size: .79rem; margin: 0; }
.portal-table thead th { background: #f4f6f8; border-bottom-color: var(--border); color: #50555b; font-size: .67rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.portal-table td { vertical-align: middle; }
.portal-table td small { color: var(--muted); display: block; font-size: .68rem; }
.portal-table code { color: #465569; font-size: .72rem; }
.type-badge, .status { border-radius: 999px; display: inline-block; font-size: .67rem; font-weight: 700; padding: 3px 7px; white-space: nowrap; }
.type-badge.is-hydro { background: #e8f2ff; color: #175ca8; }
.type-badge.is-wind { background: #e9f7ef; color: #24734d; }
.status.success { background: var(--soft-green); color: var(--green); }
.status.danger { background: #fff0ef; color: var(--red); }
.status.muted { background: #eef0f2; color: #687078; }
.status.warning { background: #fff4ce; color: #815b00; }
.run-list > a { align-items: center; border-bottom: 1px solid var(--border); color: var(--ink); display: flex; justify-content: space-between; padding: 11px 4px; text-decoration: none; }
.run-list > a:hover { background: #fafbfc; }
.run-list small { color: var(--muted); display: block; font-size: .7rem; }
.split-grid { display: grid; gap: 16px; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.4fr); }
.portal-form > div { margin-bottom: 12px; }
.portal-form .errorlist { color: var(--red); font-size: .75rem; margin: 4px 0; }
.portal-form .helptext { color: var(--muted); display: block; font-size: .7rem; margin-top: 3px; }
.wide-form { max-width: 1100px; }
.form-section + .form-section { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 18px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.check-field { align-items: center; display: flex; gap: 8px; }
.check-field label { margin: 0; }
.form-actions { margin-top: 18px; }
.section-note { color: var(--muted); font-size: .78rem; margin: 6px 0; }
.item-list > div { align-items: center; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; padding: 12px 0; }
.item-list > div:last-child { border-bottom: 0; }
.item-list span, .item-list small { color: var(--muted); display: block; font-size: .75rem; }
.empty-state { color: var(--muted); font-size: .82rem; padding: 20px 4px !important; }
.integration-note code { background: #f3f5f7; border-radius: 4px; display: block; margin: 6px 0; overflow-wrap: anywhere; padding: 8px; }
.integration-note p { font-size: .78rem; margin: 8px 0 0; }
.integration-note p code { display: inline; padding: 2px 4px; }
.action-bar { display: flex; gap: 8px; }
.plan-preview { max-height: 520px; overflow: auto; }
.plan-preview thead { position: sticky; top: 0; z-index: 1; }
.login-shell { width: min(420px, 94vw); }
.login-brand { font-size: 1.6rem; font-weight: 700; margin-bottom: 12px; text-align: center; }
.login-panel { padding: 28px; }
.login-panel h1 { font-size: 1.5rem; }

@media (max-width: 980px) {
  body.portal-body { overflow: auto; }
  .portal-main { bottom: auto; min-height: calc(100vh - 60px); position: relative; top: 60px; }
  .portal-footer { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .generate-bar, .dashboard-grid, .split-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .portal-main { padding: 12px; }
  .metric-grid, .form-grid { grid-template-columns: 1fr; }
  .action-bar { flex-direction: column; width: 100%; }
}
