:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --line: #d8e1ea;
  --text: #17212b;
  --muted: #5f6f80;
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --green: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --purple: #6d28d9;
  --shadow: 0 10px 28px rgba(27, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 100;
  padding: 9px 14px;
  border-radius: 8px;
  background: #0f2a4a;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Malgun Gothic", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.36);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.header-actions,
.preset-grid,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: calc(100vh - 75px);
}

.controls-panel {
  position: sticky;
  top: 75px;
  align-self: start;
  height: calc(100vh - 75px);
  overflow: auto;
  padding: 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.content {
  min-width: 0;
  padding: 22px;
}

.panel-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.panel-section:first-child {
  padding-top: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.button,
.preset,
.tab {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.button.secondary {
  background: #f8fafc;
}

.button.full {
  width: 100%;
  margin-top: 10px;
}

.button:hover,
.preset:hover,
.tab:hover {
  border-color: #94a3b8;
}

.preset.active,
.tab.active {
  border-color: var(--blue);
  background: #e9f0ff;
  color: var(--blue-2);
  font-weight: 700;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.slider-list {
  display: grid;
  gap: 14px;
}

.slider-row {
  display: grid;
  gap: 6px;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slider-head label {
  font-weight: 700;
}

.slider-value {
  min-width: 42px;
  text-align: right;
  color: var(--blue-2);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.text-input,
.select-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.savings-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.savings-box strong {
  color: var(--blue-2);
  font-size: 22px;
}

.fine-print {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.notice-band {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-left: 5px solid #f2c94c;
  background: #fff8df;
  color: #573a00;
}

.notice-band strong {
  display: inline-block;
  margin-right: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-cell {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-cell .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-cell .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
}

.workbench {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tabs {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.tab-view {
  display: none;
  padding: 16px;
}

.tab-view.active {
  display: block;
}

.table-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.table-toolbar h2 {
  margin-bottom: 0;
}

.subtle {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 275px);
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf2fb;
  font-size: 12px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbff;
}

.check-cell {
  text-align: center;
}

.delete-check {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.money {
  color: #334155;
  font-weight: 700;
  white-space: nowrap;
}

.score {
  font-weight: 800;
  color: var(--blue-2);
}

.pill-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef4f8;
  color: #334155;
  font-size: 12px;
}

.decision {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.decision.reduce {
  background: var(--red);
}

.decision.standardize {
  background: var(--purple);
}

.decision.monitor {
  background: var(--amber);
}

.decision.keep {
  background: var(--green);
}

.decision.check {
  background: #64748b;
}

.decision.expand {
  background: var(--blue);
}

.detail-panel {
  position: fixed;
  top: 75px;
  right: 0;
  z-index: 30;
  width: min(560px, 100vw);
  height: calc(100vh - 75px);
  transform: translateX(100%);
  transition: transform 180ms ease;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.14);
  overflow: auto;
}

.detail-panel.open {
  transform: translateX(0);
}

.icon-button {
  position: sticky;
  top: 0;
  float: right;
  width: 40px;
  height: 40px;
  border: 0;
  background: #0f172a;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.detail-content {
  padding: 24px;
}

.detail-content h2 {
  margin-right: 44px;
  font-size: 20px;
}

.detail-block {
  margin: 18px 0;
}

.detail-block h3 {
  color: var(--muted);
  font-size: 13px;
}

.detail-block p {
  line-height: 1.6;
  white-space: pre-wrap;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.method-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 700px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 14px;
  }

  .summary-grid,
  .method-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }
}
