/* Aligned with Raqmin apps/web/tailwind.config.js + styles.scss tokens */

:root {
  color-scheme: light;

  /* Gray scale */
  --gray-25: #fcfcfc;
  --gray-50: #f7f7f7;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d6d6d6;
  --gray-400: #a3a3a3;
  --gray-500: #737373;
  --gray-600: #525252;
  --gray-800: #1a1a1a;

  /* Brand */
  --brand-500: #9cc498;
  --brand-600: #2f8d68;
  --brand-700: #006840;
  --brand-800: #005430;
  --brand-900: #122d13;

  /* Semantic */
  --bg: var(--gray-50);
  --surface: #ffffff;
  --surface-muted: var(--gray-100);
  --text: var(--gray-800);
  --muted: var(--gray-600);
  --line: var(--gray-200);
  --accent: var(--brand-700);
  --accent-strong: var(--brand-800);
  --accent-soft: var(--brand-500);

  /* System (Raqmin tailwind blue / orange / red) */
  --blue: #2a549f;
  --amber: #f79009;
  --danger: #d92d20;

  /* Raqmin shadow-card */
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-dropdown: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-md: 0.5rem;
  --radius-lg: 0.625rem;
  --transition-normal: 200ms ease;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Figtree, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

::selection {
  background: #e1ede0;
  color: var(--brand-900);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.planner-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 18px 0 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand-600);
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.875rem, 4vw, 2.25rem);
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
}

h2 {
  margin-bottom: 8px;
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
}

.subtitle {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 400;
}

.status-strip {
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-normal);
}

.status-strip:hover {
  box-shadow: var(--shadow-card-hover);
}

.status-strip span,
.metric-label,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.result-primary .metric-label {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

dt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: var(--text);
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.result-panel,
.info-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.control-panel,
.result-panel {
  padding: 18px;
  transition: box-shadow var(--transition-normal);
}

.control-panel:hover,
.result-panel:hover {
  box-shadow: var(--shadow-card-hover);
}

.field-group {
  margin-bottom: 18px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label,
.field-label-row label {
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

output {
  min-width: 42px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

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

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.125rem;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 10px;
  align-items: center;
  margin-top: 7px;
}

.inline-control input[type="range"] {
  margin: 0;
}

.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

select,
input[type="number"] {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color var(--transition-normal),
    box-shadow var(--transition-normal);
}

select:focus-visible,
input[type="number"]:focus-visible {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgb(156 196 152 / 0.2);
}

.toggle-grid {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.toggle-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 500;
}

.toggle-row.is-hidden {
  display: none;
}

input[type="checkbox"] {
  width: 21px;
  height: 21px;
  accent-color: var(--accent);
}

.advanced-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.advanced-panel summary:focus-visible {
  outline: none;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-soft);
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.result-panel {
  position: sticky;
  top: 18px;
  /* visible so metric tooltips are not clipped; top rounding on .result-primary */
  overflow: visible;
  padding: 0;
}

.result-panel > *:not(.result-primary) {
  padding-left: 18px;
  padding-right: 18px;
}

.result-panel > .capacity-bars {
  padding-top: 18px;
}

.result-panel > .metric-grid {
  padding: 0 18px 18px;
}

.result-primary {
  padding: 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--brand-900);
  color: #fff;
}

.result-primary strong {
  display: block;
  margin: 4px 0 2px;
  font-size: clamp(3rem, 8vw, 4.75rem);
  line-height: 0.95;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.result-primary span {
  color: rgba(255, 255, 255, 0.72);
}

/* Dynamic note: keep sentence case for longer marketing copy */
.result-primary #capacity-note {
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.35;
}

.capacity-bars {
  display: grid;
  gap: 13px;
  margin: 18px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.bar-fill {
  width: 0%;
  height: 100%;
  background: var(--brand-600);
  transition: width 160ms ease;
}

.bar-fill.secondary {
  background: var(--blue);
}

.bar-fill.warning {
  background: var(--amber);
}

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

.metric-grid div {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

/* Lift cell above grid neighbors so tooltips paint on top */
.metric-grid > div:has(.info-button:hover),
.metric-grid > div:has(.info-button:focus-visible) {
  z-index: 30;
}

.advanced-grid label:has(.info-button:hover),
.advanced-grid label:has(.info-button:focus-visible) {
  position: relative;
  z-index: 30;
}

.info-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--gray-300);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent-strong);
  cursor: help;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.info-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent-soft);
}

.tooltip {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: calc(100% + 9px);
  width: 230px;
  max-width: min(230px, calc(100vw - 48px));
  padding: 9px 10px;
  border: 1px solid var(--gray-800);
  border-radius: var(--radius-md);
  background: var(--gray-800);
  box-shadow: var(--shadow-dropdown);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 500;
  text-align: left;
  text-transform: none;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.tooltip::after {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 10px;
  height: 10px;
  border-right: 1px solid var(--gray-800);
  border-bottom: 1px solid var(--gray-800);
  background: var(--gray-800);
  content: "";
  transform: translate(-50%, -5px) rotate(45deg);
}

.info-button:hover .tooltip,
.info-button:focus .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

dd {
  margin: 4px 0 0;
  font-size: 1.375rem;
  line-height: 1.75rem;
  font-weight: 600;
  color: var(--text);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.info-panel {
  padding: 16px;
}

.info-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5rem;
}

.is-danger {
  color: var(--danger);
}

@media (max-width: 860px) {
  .planner-header,
  .planner-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .planner-header {
    display: grid;
    align-items: start;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .advanced-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .result-primary strong {
    font-size: clamp(2.75rem, 12vw, 3.5rem);
  }
}
