*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #0f172a;
  background: #f8fafc;
  line-height: 1.5;
  font-weight: 400;
}

body {
  margin: 0;
}

.site-header {
  background: #2f3e51;
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-logo img {
  height: 60px;
  width: auto;
  display: block;
}

.site-nav a {
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: #ffffff;
}

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

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #475569;
  cursor: pointer;
}

.mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-pill {
  width: 42px;
  height: 22px;
  background: #e2e8f0;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-pill::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}

.mode-toggle input:checked + .toggle-pill {
  background: #2563eb;
}

.mode-toggle input:checked + .toggle-pill::after {
  transform: translateX(20px);
}

.page-header h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 500;
}

.page-header p {
  margin: 0;
  color: #475569;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 0.95fr;
  gap: 20px;
  align-items: start;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#inputs.stack {
  max-width: 520px;
}

.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.card h3 {
  margin: 0 0 8px 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.field.multi {
  grid-template-columns: 1fr;
}

.field.multi .input-row {
  margin-left: auto;
}

.field.multi .input-row label {
  margin-right: auto;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-weight: 400;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.input-row {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.field .input-row {
  width: 100%;
}

.inline-label {
  color: #475569;
  font-size: 0.85rem;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  max-width: 110px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  text-align: right;
}

.input-row input[type="number"],
.input-row input[type="text"],
.input-row select {
  flex: 0 0 110px;
}

.suffix {
  color: #64748b;
  font-size: 0.9rem;
}

.error {
  color: #b91c1c;
  font-size: 0.85rem;
}

.warning {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.cp-button {
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

.cp-button-secondary {
  background: #ffffff;
  color: #2563eb;
}

.cp-about-btn {
  padding: 8px 14px;
  font-size: 0.9rem;
}

.share-status {
  font-size: 0.85rem;
  color: #475569;
  min-height: 20px;
}

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

.kpi {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
  text-align: center;
}

.kpi .label {
  color: #64748b;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
}

.kpi .value {
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
}

.table th {
  color: #64748b;
  font-weight: 500;
}

.chart {
  display: grid;
  gap: 12px;
}

.chart-bar {
  width: 100%;
  height: 18px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.chart-bar > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: 0.75rem;
  color: #ffffff;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: #475569;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.mini-chart {
  display: grid;
  gap: 12px;
}

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

.mini-title {
  font-size: 0.85rem;
  color: #475569;
}

.mini-bar {
  height: 16px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.mini-seg {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.7rem;
  color: #ffffff;
  font-weight: 600;
  min-width: 0;
}

.mini-legend {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: #475569;
}

.legend-dot.a { background: #15803d; }
.legend-dot.c { background: #b45309; }
.legend-dot.pick { background: #1d4ed8; }
.legend-dot.reserve { background: #64748b; }

.mini-seg.a { background: #15803d; }
.mini-seg.c { background: #b45309; }
.mini-seg.pick { background: #1d4ed8; }
.mini-seg.reserve { background: #64748b; }

.assumptions ul {
  margin: 0;
  padding-left: 18px;
  color: #475569;
}

.muted {
  color: #64748b;
  font-size: 0.85rem;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #93c5fd;
  font-size: 11px;
  color: #2563eb;
  cursor: pointer;
  background: #dbeafe;
  padding: 0;
  position: relative;
}

.info::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 280px;
  background: #0f172a;
  color: #ffffff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.info::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #0f172a;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 11;
}

.info:hover::after,
.info:hover::before,
.info:focus::after,
.info:focus::before {
  opacity: 1;
  visibility: visible;
}

body.quick .detail-only {
  display: none;
}

body.quick .detail-card {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 620px;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.modal-close {
  border: none;
  background: #e2e8f0;
  color: #334155;
  font-size: 1.2rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
}

.modal-body h4 {
  margin: 10px 0 6px;
  font-weight: 500;
}

.modal-body p {
  margin: 0 0 8px;
  color: #475569;
}

.modal-body ul {
  margin: 0;
  padding-left: 18px;
  color: #475569;
}
