/* Power & Sun — pricing tool
   Brand: orange #E9532B, amber #F9A93C, blue #14509B */

:root {
  --ps-orange: #E9532B;
  --ps-orange-dark: #C63F1B;
  --ps-amber: #F9A93C;
  --ps-amber-soft: #FDF0DC;
  --ps-blue: #14509B;
  --ps-blue-dark: #0E3A72;
  --ps-blue-soft: #EAF0F9;

  --ink: #16202E;
  --ink-2: #47566B;
  --ink-3: #7C8899;
  --line: #DFE4EC;
  --line-2: #EDF0F5;
  --bg: #F6F8FB;
  --panel: #FFFFFF;

  --ok: #1F8A54;
  --ok-soft: #E6F5EC;
  --warn: #B4700B;
  --warn-soft: #FDF3E0;
  --danger: #C22F31;
  --danger-soft: #FCEBEB;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .06), 0 6px 20px rgba(22, 32, 46, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--ps-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--line-2); }
.sidebar__brand img { width: 100%; max-width: 168px; display: block; }
.sidebar__brand small {
  display: block; margin-top: 8px; color: var(--ink-3);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600;
}

.nav { padding: 10px 10px 24px; }
.nav__group { margin-top: 14px; }
.nav__group:first-child { margin-top: 4px; }
.nav__label {
  padding: 6px 8px; color: var(--ink-3); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
}
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px;
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav a.is-active { background: var(--ps-blue-soft); color: var(--ps-blue); font-weight: 600; }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 26px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { flex: 1; min-width: 0; }
.topbar__title .crumb { color: var(--ink-3); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.topbar__user { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(140deg, var(--ps-amber), var(--ps-orange));
  color: #fff; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}

.content { padding: 22px 26px 60px; }
.content--wide { padding-left: 16px; padding-right: 16px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel__head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
}
.panel__head h2 { flex: 1; min-width: 160px; }
.panel__head .sub { color: var(--ink-3); font-size: 12px; font-weight: 500; }
.panel__body { padding: 16px; }
.panel__body--flush { padding: 0; }
.panel__foot { padding: 12px 16px; border-top: 1px solid var(--line-2); background: #FCFDFE; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px)  { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat__label { color: var(--ink-3); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__note { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.stat--orange { border-top: 3px solid var(--ps-orange); }
.stat--amber  { border-top: 3px solid var(--ps-amber); }
.stat--blue   { border-top: 3px solid var(--ps-blue); }
.stat--ok     { border-top: 3px solid var(--ok); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data th {
  background: #FAFBFD; color: var(--ink-2); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--line);
}
table.data tbody tr:hover { background: #FBFCFE; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
table.data td.wrap { white-space: normal; min-width: 240px; }
table.data tfoot td { font-weight: 700; background: #FAFBFD; border-top: 1px solid var(--line); }
table.data .group-head th {
  background: var(--ps-blue-soft); color: var(--ps-blue); text-align: center;
  border-bottom: 1px solid var(--line); top: 0;
}
/* Sortable column headings */
table.data th.sortable { padding: 0; }
table.data th.sortable a {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 10px; color: inherit; text-decoration: none;
  font: inherit; letter-spacing: inherit; text-transform: inherit; white-space: nowrap;
}
table.data th.sortable.num a { justify-content: flex-end; }
table.data th.sortable a:hover { background: var(--ps-blue-soft); color: var(--ps-blue); text-decoration: none; }
table.data th.sortable a:focus-visible { outline: 2px solid var(--ps-blue); outline-offset: -2px; }
table.data th.sortable i { font-style: normal; font-size: 11px; opacity: .3; line-height: 1; }
table.data th.sortable a:hover i { opacity: .65; }
table.data th.sortable.is-sorted { background: var(--ps-blue-soft); color: var(--ps-blue); }
table.data th.sortable.is-sorted i { opacity: 1; color: var(--ps-blue); }

table.data.glossary td { white-space: normal; vertical-align: top; }
table.data.glossary tr:last-child td { border-bottom: 0; }

.sortbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.sortbar .field { margin-bottom: 0; }
.dir-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.dir-toggle a {
  padding: 7px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: #fff; text-decoration: none; border-right: 1px solid var(--line);
}
.dir-toggle a:last-child { border-right: 0; }
.dir-toggle a:hover { background: #F7F9FC; text-decoration: none; }
.dir-toggle a.is-active { background: var(--ps-blue); color: #fff; }

.row-flag td { background: var(--danger-soft); }
.row-flag:hover td { background: #FBE0E0; }

/* ---------- Cost waterfall ---------- */
.waterfall { width: 100%; border-collapse: collapse; font-size: 13px; }
.waterfall td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); }
.waterfall td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.waterfall .step td { color: var(--ink-2); }
.waterfall .step td:first-child { padding-left: 22px; }
.waterfall .subtotal td { font-weight: 700; background: var(--ps-blue-soft); color: var(--ps-blue-dark); }
.waterfall .total td { font-weight: 800; background: var(--ps-amber-soft); color: #7A4A06; font-size: 14px; }
.waterfall .head td { font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .07em; color: var(--ink-3); padding-top: 14px; }
.waterfall .muted td { color: var(--ink-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700;
  letter-spacing: .02em; white-space: nowrap;
}
.badge--grey   { background: var(--line-2); color: var(--ink-2); }
.badge--blue   { background: var(--ps-blue-soft); color: var(--ps-blue); }
.badge--amber  { background: var(--warn-soft); color: var(--warn); }
.badge--green  { background: var(--ok-soft); color: var(--ok); }
.badge--red    { background: var(--danger-soft); color: var(--danger); }
.badge--orange { background: #FDECE6; color: var(--ps-orange-dark); }

.tier-pill { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.tier-1 { background: var(--ps-blue-soft); color: var(--ps-blue); }
.tier-2 { background: var(--warn-soft); color: var(--warn); }
.tier-3 { background: #FDECE6; color: var(--ps-orange-dark); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: #F7F9FC; text-decoration: none; }
.btn--primary { background: var(--ps-blue); border-color: var(--ps-blue); color: #fff; }
.btn--primary:hover { background: var(--ps-blue-dark); }
.btn--accent { background: var(--ps-orange); border-color: var(--ps-orange); color: #fff; }
.btn--accent:hover { background: var(--ps-orange-dark); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn--danger { color: var(--danger); border-color: #EFC9C9; }
.btn--danger:hover { background: var(--danger-soft); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 13px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(20, 80, 155, .18); outline-offset: 0; border-color: var(--ps-blue);
}
input[readonly], input:disabled, select:disabled { background: #F4F6F9; color: var(--ink-2); }
textarea { min-height: 70px; resize: vertical; }

/* Input provenance, mirroring the workbook's colour key. */
.is-input    { background: #F3F8FF; border-color: #C6DCF7; }
.is-auto     { background: var(--ps-amber-soft); border-color: #F1D7AA; }
.is-computed { background: #F1F8F3; border-color: #CDE6D6; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 4px; margin: 0 0 16px; }
legend {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ps-blue); padding: 0 7px;
}

/* ---------- Notices ---------- */
.notice { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.notice--ok    { background: var(--ok-soft); border-color: #BFE3CE; color: #14603A; }
.notice--warn  { background: var(--warn-soft); border-color: #F0DBB0; color: #7A4A06; }
.notice--error { background: var(--danger-soft); border-color: #EFC9C9; color: #8E2022; }
.notice--info  { background: var(--ps-blue-soft); border-color: #C9DBF2; color: var(--ps-blue-dark); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Workflow rail ---------- */
.flow { display: flex; gap: 0; flex-wrap: wrap; }
.flow__step {
  flex: 1; min-width: 108px; padding: 9px 12px; border: 1px solid var(--line);
  border-right: 0; background: #fff; font-size: 12px;
}
.flow__step:last-child { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.flow__step:first-child { border-radius: 8px 0 0 8px; }
.flow__step .day { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
.flow__step .what { font-weight: 600; color: var(--ink-2); }
.flow__step.is-done { background: var(--ok-soft); border-color: #BFE3CE; }
.flow__step.is-done .what { color: #14603A; }
.flow__step.is-current { background: var(--ps-blue-soft); border-color: #C9DBF2; }
.flow__step.is-current .what { color: var(--ps-blue); }

.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.meta-list dt { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.meta-list dd { margin: 0; }

.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); }
.pager { display: flex; gap: 6px; padding: 12px 16px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.pager a, .pager span { padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.pager .is-current { background: var(--ps-blue); border-color: var(--ps-blue); color: #fff; font-weight: 700; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #FFF7EC 0%, var(--bg) 45%, #EEF3FA 100%); }
.login__card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(22,32,46,.10); padding: 28px; }
.login__card img { width: 190px; display: block; margin: 0 auto 6px; }
.login__card .lead { text-align: center; color: var(--ink-3); font-size: 12.5px; margin: 0 0 20px; }
.login__accounts { margin-top: 18px; border-top: 1px solid var(--line-2); padding-top: 14px; font-size: 12px; color: var(--ink-3); }
.login__accounts code { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }

@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; break-inside: avoid; }
}
