
:root{
  --bg:#ffffff;
  --card:rgba(255,255,255,0.72);
  --stroke:rgba(0,0,0,0.06);
  --text:#0b0b0c;
  --muted:#6b7280;
  --brand:#3b82f6;
  --accent:#0ea5e9;
  --shadow: 0 10px 30px rgba(0,0,0,.08);
  --radius:18px;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color:var(--text);
  background: var(--bg);
}

.container{
  max-width: 980px;
  margin: 48px auto 96px;
  padding: 0 20px;
}

.header{
  text-align:center;
  margin-bottom:24px;
}

.title{
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.subtitle{
  color:var(--muted);
  font-size: 15px;
  margin-top:6px;
}

.glass{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(180%) blur(22px);
}

.section{
  padding: 20px;
  margin-top: 18px;
}

.section h3{
  margin: 0 0 12px;
  font-size: 17px;
}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px){
  .grid-3{
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-2{
    grid-template-columns: repeat(2, 1fr);
  }
}

.label{
  font-size:13px;
  color:var(--muted);
  margin-bottom:6px;
}

.input, select{
  width:100%;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.9);
  border-radius: 12px;
  padding:12px 14px;
  font-size:15px;
  outline:none;
  transition:border .2s ease, box-shadow .2s ease;
}

.input:focus, select:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 4px rgba(59,130,246,.14);
}

.btn{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:12px 18px;
  border-radius:14px;
  border:1px solid rgba(59,130,246,.2);
  background: linear-gradient(180deg, #4f8df9 0%, #3b82f6 100%);
  color:white;
  font-weight:600;
  cursor:pointer;
  box-shadow: var(--shadow);
}

.card-row{
  display:grid;
  grid-template-columns: 1fr;
  gap:12px;
}

@media (min-width: 900px){
  .card-row{ grid-template-columns: 0.95fr 1.05fr; }
}

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

.kpi .kpi-card{
  padding:16px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:linear-gradient(180deg, rgba(248,250,252,0.85) 0%, rgba(255,255,255,0.85) 100%);
}

.kpi .value{
  font-size:22px;
  font-weight:700;
  margin-top:2px;
}

.small{
  font-size:12px;
  color:var(--muted);
}

.table{
  width:100%;
  border-collapse: collapse;
}

.table th, .table td{
  text-align:left;
  padding:10px 8px;
  border-bottom:1px solid var(--stroke);
  font-size:14px;
}

.help{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}

.hidden{ display:none; }

/* v3 layout tweaks */
.section.balanced{
  display:flex;
  flex-direction:column;
  justify-content:flex-start; /* top-align so heading lines up with Extra Information */
}
.section.balanced .kpi{ margin-top:10px; }

/* Center content and give comfortable height only on wider screens */
@media (min-width: 900px){
  .section.balanced{ min-height: 240px; justify-content:flex-start; }
  /* Keep KPIs in a 2x2 grid on wide screens */
  .kpi{ grid-template-columns: repeat(2, 1fr); }
}

/* Improve KPI card spacing */
.kpi .kpi-card{ display:flex; flex-direction:column; justify-content:center; min-height:120px; }


/* v3.3 additions */
.card-row{ width:100%; }

/* === KPI color bands (accessible, subtle) === */
:root{
  --kpi-verygood-bg: rgba(16, 185, 129, 0.14);  /* emerald 500 @ 14% */
  --kpi-verygood-bd: rgba(16, 185, 129, 0.35);

  --kpi-good-bg: rgba(59, 130, 246, 0.12);      /* blue 500 @ 12% */
  --kpi-good-bd: rgba(59, 130, 246, 0.35);

  --kpi-fair-bg: rgba(245, 158, 11, 0.14);      /* amber 500 @ 14% */
  --kpi-fair-bd: rgba(245, 158, 11, 0.38);

  --kpi-bad-bg: rgba(239, 68, 68, 0.15);        /* red 500 @ 15% */
  --kpi-bad-bd: rgba(239, 68, 68, 0.40);
}

.kpi-card.band-verygood{
  background: linear-gradient(180deg, var(--kpi-verygood-bg) 0%, rgba(255,255,255,0.85) 100%);
  border-color: var(--kpi-verygood-bd);
}
.kpi-card.band-good{
  background: linear-gradient(180deg, var(--kpi-good-bg) 0%, rgba(255,255,255,0.85) 100%);
  border-color: var(--kpi-good-bd);
}
.kpi-card.band-fair{
  background: linear-gradient(180deg, var(--kpi-fair-bg) 0%, rgba(255,255,255,0.85) 100%);
  border-color: var(--kpi-fair-bd);
}
.kpi-card.band-bad{
  background: linear-gradient(180deg, var(--kpi-bad-bg) 0%, rgba(255,255,255,0.85) 100%);
  border-color: var(--kpi-bad-bd);
}
/* Keep label readable on tinted backgrounds */
.kpi-card.band-verygood .small,
.kpi-card.band-good .small,
.kpi-card.band-fair .small,
.kpi-card.band-bad .small{ color: #374151; }


/* === Inline tooltips === */
.tt {
  display:inline-flex; align-items:center; justify-content:center;
  width:14px; height:14px; margin-left:4px;
  border-radius:50%;
  border:1px solid rgba(0,0,0,0.08);
  background: transparent;
  color:#6b7280; /* gray-500 */
  font-size:10px; font-weight:700; line-height:1;
  opacity:.65;
  cursor:help; user-select:none; position:relative; vertical-align:middle;
  transition:opacity .12s ease, border-color .12s ease;
}
.tt::before{ content:'i'; }
.tt:hover, .tt:focus{ opacity:.95; border-color: rgba(0,0,0,0.15); }
.tt:focus{ outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,.25); }

/* Tooltip bubble */
.tt::after{
  content: attr(data-tip);
  position:absolute; z-index:50; left:50%; transform:translate(-50%, -8px);
  bottom: 125%;
  white-space:normal; text-align:left;
  min-width: 220px; max-width: 360px; /* wider for readability */
  background: rgba(17,24,39,0.96); /* slate-900 */
  color:#fff; font-size:13px; font-weight:500; line-height:1.4;
  padding:10px 12px; border-radius:10px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  opacity:0; pointer-events:none; transition:opacity .12s ease;
}
.tt:hover::after, .tt:focus::after, .tt.open::after { opacity:1; }
.tt[data-tip='']::after{ display:none; }

/* Place below when there's not enough space (optional hook via class .tt-btm) */
.tt-btm::after{ bottom:auto; top: 125%; transform: translate(-50%, 8px); }

/* On tinted KPI cards, make the icon more subtle and avoid clashing */
.kpi-card .tt{
  color:#4b5563; /* gray-600 */
  opacity:.55; border-color: rgba(0,0,0,0.06); background: transparent;
}
.kpi-card.band-verygood .tt,
.kpi-card.band-good .tt,
.kpi-card.band-fair .tt,
.kpi-card.band-bad .tt { background: transparent; }

@media (prefers-reduced-motion: reduce){
  .tt, .tt::after{ transition:none; }
}
@media (hover:none){
  .tt{ width:16px; height:16px; }
}
/* small caret */
.tt.open::before-bubble {}
.tt-btm::after{ bottom:auto; top: 125%; transform: translate(-50%, 6px); }
/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce){
  .tt::after{ transition:none; }
}
@media (hover:none){
  /* Boost size slightly for touch */
  .tt{ width:18px; height:18px; }
}



/* =========================
   HIG Refresh — 2025-09-26
   Subtle Apple‑inspired UI polish without changing markup
   ========================= */

/* 1) Global type & rhythm */
:root{
  --radius:16px; /* unify across inputs/cards/buttons */
  --hairline: rgba(0,0,0,0.08);
  --hairline-strong: rgba(0,0,0,0.12);
  --card-glass: rgba(255,255,255,0.65);
  --shadow-1: 0 1px 0 rgba(0,0,0,0.04);
  --shadow-2: 0 12px 30px rgba(0,0,0,0.08);
  --label:#6B7280;
  --headline:#0b0b0c;
  --section:#334155;
  --system-blue:#0A84FF; /* iOS system blue approximation */
  --focus-ambient: rgba(59,130,246,0.35);
  --kpi-bad:#DC2626;
  --kpi-good:#059669;
  --kpi-fair:#C2410C;
  --kpi-vgood:#059669;
}

html, body{
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  color: var(--headline);
}

/* Headline / title */
.header .title{
  font-weight: 600;
  font-size: clamp(28px, 3.2vw, 32px);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 8px; /* title → 8px → subtitle */
}
.header .subtitle{
  color: var(--label);
  font-size: 14.5px;
  line-height: 1.45;
}

/* Section headings */
.card h3, .glass h3, .section h3{
  font-weight: 500;
  font-size: 15.5px;
  color: var(--section);
  margin-bottom: 16px; /* section header → 16px → content */
}

/* Layout rhythm within cards */
.card .row, .glass .row{
  margin-top: 10px;
  margin-bottom: 10px;
}

/* 2) Cards — frosted glass + hairline + soft depth */
.card, .glass, .panel, .kpi-card{
  background: var(--card-glass);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-1), var(--shadow-2);
  padding: 20px;
}
/* equal heights for KPI grid */
.kpi{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.kpi-card{ display:flex; flex-direction:column; justify-content:space-between; min-height:110px; position:relative; overflow:hidden; }
/* inset highlight */
.kpi-card::before{
  content:"";
  position:absolute; inset:0 0 auto 0; height:8px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.75), rgba(255,255,255,0));
  pointer-events:none;
}

/* 3) Typography for values & labels */
.small, .label{
  font-size:13px;
  font-weight:500;
  color: var(--label);
}
.value, .kpi .value{
  font-size: clamp(18px, 2.2vw, 20px);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
  line-height: 1.25;
}

/* 4) KPI color bands — tint bg, colorize value text */
.kpi-card.band-verygood .value{ color: var(--kpi-vgood); }
.kpi-card.band-good .value{ color: #16A34A; }
.kpi-card.band-fair .value{ color: var(--kpi-fair); }
.kpi-card.band-bad .value{ color: var(--kpi-bad); }

/* low‑alpha gradients */
.kpi-card.band-verygood{ background: linear-gradient(180deg, rgba(16,185,129,0.10) 0%, rgba(255,255,255,0.85) 100%); border-color: rgba(16,185,129,0.18); }
.kpi-card.band-good{     background: linear-gradient(180deg, rgba(34,197,94,0.10) 0%, rgba(255,255,255,0.85) 100%);  border-color: rgba(34,197,94,0.18); }
.kpi-card.band-fair{     background: linear-gradient(180deg, rgba(251,146,60,0.10) 0%, rgba(255,255,255,0.85) 100%);  border-color: rgba(251,146,60,0.18); }
.kpi-card.band-bad{      background: linear-gradient(180deg, rgba(239,68,68,0.10) 0%, rgba(255,255,255,0.85) 100%);  border-color: rgba(239,68,68,0.18); }
.kpi-card.band-verygood .small,
.kpi-card.band-good .small,
.kpi-card.band-fair .small,
.kpi-card.band-bad .small{ color:#374151; }

/* 5) Inputs & buttons — iOS feel */
input[type="text"], input[type="number"], select, textarea{
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  padding: 12px 14px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02) inset;
  outline: none;
  transition: box-shadow .2s, border-color .2s, background .2s;
}
input:focus, select:focus, textarea:focus{
  border-color: var(--system-blue);
  box-shadow: 0 0 0 2px var(--focus-ambient);
  background: #fff;
}
.btn, button, .button{
  appearance: none;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #0A84FF 0%, #0876E6 100%);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 8px 18px rgba(10,132,255,0.22);
  transition: transform .06s ease, box-shadow .2s ease, filter .2s ease, background-color .2s ease;
}
.btn:hover{
  filter: saturate(110%) brightness(1.02);
}
.btn:active{
  transform: translateY(0.5px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 14px rgba(10,132,255,0.20);
  background: linear-gradient(180deg, #0A7CF0 0%, #086DDA 100%); /* 2% darker */
}
.btn:focus{
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ambient), 0 2px 4px rgba(0,0,0,0.05);
}

/* tighten general spacing */
.container{ padding-top: 18px; }
.section.balanced .kpi { margin-top: 12px; }

/* 6) Tooltips — calm, clear */
.info-icon, .tooltip-icon{
  width: 14px; height: 14px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:50%;
  color:#6b7280;
  opacity:.55;
  margin-left: 6px;
  cursor: help;
  position: relative;
}
/* simple dot with 'i' using CSS, in case SVG not present */
.info-icon::before{
  content: "i";
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.tooltip-bubble{
  position:absolute;
  left: 0; top: 125%;
  min-width: 240px; max-width: 360px;
  background: rgba(255,255,255,0.98);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  color:#111827;
  border:1px solid var(--hairline-strong);
  border-radius:10px;
  padding:10px 12px;
  font-size: 12.5px;
  line-height: 1.4;
  box-shadow: var(--shadow-1), 0 10px 24px rgba(0,0,0,0.08);
  z-index: 10;
  display:none;
}
.info-icon:hover .tooltip-bubble{ display:block; }
.kpi-card [class*="icon"]{ color:#9CA3AF; } /* monochrome on tinted KPI cards */

/* 7) Misc: drop heavy borders globally */
.card, .glass, .panel { border-color: var(--hairline); }
hr{ border: none; height:1px; background: var(--hairline); }

/* Make results area breathe a bit more */
#results .section{ margin-top: 16px; }



/* === Project-specific HIG tasks (2025-09-26) === */
/* Force KPI grid to 2x2 on wide screens */
@media (min-width: 900px){
  .section.balanced .kpi { grid-template-columns: repeat(2, 1fr) !important; }
  .section.balanced { min-height: auto !important; }
}
/* Right-align the Calculate button container */
.actions-right{ display:flex; justify-content:flex-end; }


/* === Tooltip clipping fix (2025-09-26) === */
.kpi-card{ overflow: visible !important; }
.kpi{ overflow: visible !important; }
.tooltip-bubble{ z-index: 999 !important; }


/* === Tooltip consistency & stacking (2025-09-26) === */
/* Make KPI tooltips use a solid background like the rest, and float above neighbors */
.tt::after{
  background: #374151 !important; /* solid slate */
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  z-index: 2000 !important;
}
.kpi-card{ position: relative; z-index: 0; }
.kpi-card:hover{ z-index: 5; } /* raise hovered card so its tooltip sits above siblings */
.section{ overflow: visible; } /* allow cross-panel overflow */


/* === Cross-panel tooltip stacking fix (2025-09-26) === */
.glass.section{ position: relative; z-index: 0; }
.glass.section:hover, .glass.section:focus-within{ z-index: 100; } /* bring hovered panel above neighbor */


/* === KPI tooltip color consistency (2025-09-26) === */
.kpi .tt::after{
  background: #111827 !important; /* solid slate-900 */
  color: #ffffff !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}


/* === KPI tooltip visual consistency: remove parent opacity on hover === */
.kpi .tt:hover, .kpi .tt:focus{ opacity: 1 !important; }


/* === Flags pill toggles (Apparel / Hazmat) === */
.flags-row{ display:flex; gap:12px; align-items:center; margin-top:8px; flex-wrap:wrap; }
.pill-toggle{ display:inline-flex; align-items:center; gap:8px; font-size:14px; color:#374151; }
.pill-toggle input{ position:absolute; opacity:0; pointer-events:none; }
.pill-toggle .pill-ui{
  display:inline-flex; align-items:center; justify-content:center;
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--stroke); background:#fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04) inset;
  transition: all .15s ease;
}
.pill-toggle input:checked + .pill-ui{
  background:#eff6ff; border-color:#93c5fd; color:#1d4ed8;
  box-shadow: 0 0 0 2px rgba(147,197,253,.35);
}


/* === Actions bar with standard checkboxes on the left === */
.actions-bar{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.actions-left{ display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
.check-inline{ display:inline-flex; align-items:center; gap:6px; font-size:14px; color:#374151; }
.check-inline input{ width:16px; height:16px; }
