:root {
  color-scheme: light;
  --bg: #f6f8ff;
  --surface: #ffffff;
  --surface-muted: #f8faff;
  --ink: #17202a;
  --ink-muted: #5d6978;
  --line: #d9e2ff;
  --accent: #406aff;
  --accent-strong: #284cf2;
  --accent-soft: #eef3ff;
  --gain: #16b96f;
  --gain-bright: #26e88b;
  --warning: #fca028;
  --danger: #a93535;
  --shadow: 0 14px 30px rgba(64, 106, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.widget-page {
  background: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  background: #17202a;
  color: #f8fafc;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #406aff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.sidebar-note span {
  color: #a9b7c8;
}

.brand-lockup h1,
.topbar h2,
.panel h3 {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 1.05rem;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #d9e3ed;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.note-label {
  margin: 0 0 8px;
  color: #a9b7c8;
  font-size: 0.82rem;
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  margin-top: 8px;
  font-size: 0.82rem;
}

.workspace {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.widget-workspace {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

.widget-topbar {
  background: linear-gradient(135deg, #ffffff 0%, #f3f6ff 100%);
}

.widget-hidden-status {
  display: none;
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1.15fr);
  gap: 20px;
  padding: 22px;
  border: 1px solid #c8d5ff;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3ff 0%, #f3fff8 100%);
  box-shadow: var(--shadow);
}

.access-panel h3,
.access-panel p {
  margin: 0;
}

.access-panel h3 {
  font-size: 1.35rem;
}

.access-panel p {
  margin-top: 10px;
  color: var(--ink-muted);
  line-height: 1.55;
}

.access-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.access-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.access-form span {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.access-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
}

.form-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.form-status.success {
  color: var(--gain);
}

.form-status.error {
  color: var(--danger);
}

.assessment-body {
  display: grid;
  gap: 22px;
}

.assessment-locked {
  pointer-events: none;
  opacity: 0.42;
  filter: grayscale(0.25);
  user-select: none;
}

.assessment-unlocked {
  opacity: 1;
  filter: none;
}

.topbar,
.panel,
.metric-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

.topbar h2 {
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1;
}

.lede {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 1rem;
}

.topbar-actions,
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button,
.icon-button,
.tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.button {
  padding: 0 16px;
  font-weight: 800;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button.secondary,
.icon-button,
.tab {
  background: #ffffff;
  color: var(--ink);
}

.button:hover,
.icon-button:hover,
.tab:hover {
  transform: translateY(-1px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.scenario-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid #c8d5ff;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef3ff 0%, #f3fff8 100%);
  box-shadow: var(--shadow);
}

.scenario-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.scenario-card p:last-child {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--ink-muted);
}

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.metric-panel {
  display: grid;
  gap: 8px;
  min-height: 142px;
  padding: 18px;
}

.metric-label,
.metric-detail,
.summary-grid span,
.number-field span,
.field span,
.range-field span,
.license-row label span {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.metric-panel strong {
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1;
}

.savings-panel {
  background: linear-gradient(135deg, #eef3ff 0%, #eafff4 100%);
  border-color: #c8d5ff;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h3 {
  font-size: 1.28rem;
}

.panel-score {
  color: var(--gain);
  font-size: 1.45rem;
}

.gauge-ring {
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, #e5eaee 0deg);
}

.gauge-ring::before {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface);
}

.gauge-ring span {
  position: relative;
  font-size: 1rem;
  font-weight: 900;
}

.control-stack,
.split-controls {
  display: grid;
  gap: 14px;
}

.field,
.range-field,
.number-field {
  display: grid;
  gap: 7px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

select,
input {
  min-height: 42px;
  padding: 0 11px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.license-table {
  display: grid;
  gap: 10px;
}

.license-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, 0.6fr) minmax(86px, 0.6fr) 36px;
  grid-template-areas:
    "name name savings remove"
    "active inactive cost cost";
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.license-row label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.tool-name {
  grid-area: name;
  min-width: 0;
}

.license-row label:nth-of-type(1) {
  grid-area: active;
}

.license-row label:nth-of-type(2) {
  grid-area: inactive;
}

.license-row label:nth-of-type(3) {
  grid-area: cost;
}

.row-savings {
  grid-area: savings;
  min-height: 42px;
  display: grid;
  place-items: center end;
  color: var(--gain);
}

.remove-row {
  grid-area: remove;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  font-size: 1.2rem;
}

.split-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bar-list,
.insight-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecff;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gain-bright));
}

.tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.tab {
  min-width: 140px;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.insight {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.insight-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 900;
}

.insight p {
  margin: 3px 0 0;
  color: var(--ink-muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid div {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.summary-grid strong {
  font-size: 2rem;
}

textarea {
  min-height: 260px;
  padding: 16px;
  resize: vertical;
  line-height: 1.55;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-stack {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .access-panel,
  .access-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-heading,
  .scenario-card,
  .access-panel {
    display: grid;
  }

  .metric-grid,
  .dashboard-grid,
  .summary-grid,
  .split-controls,
  .nav-stack {
    grid-template-columns: 1fr;
  }

  .license-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name name"
      "active inactive"
      "cost savings"
      "remove remove";
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .report-actions,
  .control-stack,
  .license-table,
  .tabs {
    display: none;
  }

  .app-shell,
  .workspace,
  .dashboard-grid,
  .metric-grid {
    display: block;
  }

  body {
    background: #ffffff;
  }

  .panel,
  .metric-panel,
  .topbar {
    margin-bottom: 14px;
    box-shadow: none;
  }
}
