:root {
  --primary-emerald: #059669;
  --primary-emerald-dark: #047857;
  --primary-emerald-light: #d1fae5;
  --primary-emerald-surface: #ecfdf5;
  
  --sonnette-blue: #0284c7;
  --sonnette-blue-dark: #0369a1;
  --sonnette-blue-light: #e0f2fe;

  --accent-amber: #d97706;
  --accent-amber-light: #fef3c7;
  --accent-rose: #e11d48;
  --accent-rose-light: #ffe4e6;

  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --font-sans: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Montserrat', 'Noto Sans JP', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--slate-100);
  color: var(--slate-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 60px 32px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  margin-bottom: 24px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-logo-badge {
  background: var(--primary-emerald);
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
}

.brand-titles h1 span {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary-emerald-dark);
  margin-left: 10px;
}

.brand-titles p {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-top: 4px;
}

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

.mode-toggle-group {
  display: flex;
  background: var(--slate-100);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--slate-200);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.mode-btn.active {
  background: var(--white);
  color: var(--primary-emerald-dark);
  box-shadow: var(--shadow-sm);
}

.btn-print {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-emerald);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.btn-print:hover {
  background: var(--primary-emerald-dark);
  transform: translateY(-1px);
}

/* Banner Alert */
.policy-banner {
  background: var(--primary-emerald-surface);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.88rem;
  color: var(--primary-emerald-dark);
}

.policy-badge {
  background: var(--primary-emerald);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 8px;
}

/* 3-Column Layout */
.main-grid {
  display: grid;
  grid-template-columns: 340px 1fr 380px;
  gap: 24px;
  align-items: start;
}

/* Common Card Styles */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--slate-900);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--slate-100);
}

.card-title i {
  color: var(--primary-emerald);
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate-700);
  margin-bottom: 8px;
}

.badge-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--slate-100);
  color: var(--slate-600);
}

.badge-tag.highlight {
  background: var(--primary-emerald-light);
  color: var(--primary-emerald-dark);
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--slate-300);
  background: var(--white);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--slate-800);
  outline: none;
  transition: all 0.2s;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--primary-emerald);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* Radio Cards (Co-pay Ratio) */
.ratio-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ratio-chip {
  text-align: center;
  padding: 10px 8px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-700);
  background: var(--slate-50);
}

.ratio-chip.active {
  border-color: var(--primary-emerald);
  background: var(--primary-emerald-surface);
  color: var(--primary-emerald-dark);
}

.ratio-chip span {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Issues Checklist */
.issues-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.issue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--slate-50);
}

.issue-item:hover {
  background: var(--white);
  border-color: var(--slate-300);
}

.issue-item.active {
  border-color: var(--primary-emerald);
  background: var(--primary-emerald-surface);
}

.issue-item input {
  display: none;
}

.issue-checkbox-custom {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--slate-300);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  transition: all 0.2s;
  flex-shrink: 0;
}

.issue-item.active .issue-checkbox-custom {
  background: var(--primary-emerald);
  border-color: var(--primary-emerald);
  color: var(--white);
}

.issue-label-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-800);
  flex-grow: 1;
}

.issue-cat-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--slate-200);
  color: var(--slate-600);
  font-weight: 600;
}

/* Center: Simulation & Limit Gauge */
.center-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Limit Units Gauge Card */
.gauge-card {
  background: linear-gradient(180deg, var(--white), var(--slate-50));
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.gauge-title-group h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--slate-900);
}

.gauge-title-group p {
  font-size: 0.8rem;
  color: var(--slate-500);
}

.gauge-total-badge {
  text-align: right;
}

.gauge-total-val {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--slate-900);
}

.gauge-total-sub {
  font-size: 0.75rem;
  color: var(--slate-500);
}

/* Progress Multi-Bar */
.progress-container {
  height: 28px;
  background: var(--slate-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
  position: relative;
  margin-bottom: 14px;
}

.progress-bar-equip {
  background: var(--primary-emerald);
  height: 100%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
}

.progress-bar-remain {
  background: var(--slate-400);
  height: 100%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
}

.gauge-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--slate-600);
  padding: 0 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.equip { background: var(--primary-emerald); }
.legend-dot.remain { background: var(--slate-400); }

/* Other Service Conversion Box */
.service-capacity-box {
  background: var(--sonnette-blue-light);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.capacity-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sonnette-blue-dark);
}

.capacity-badges {
  display: flex;
  gap: 12px;
}

.capacity-pill {
  background: var(--white);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--slate-800);
  box-shadow: var(--shadow-sm);
}

.capacity-pill span {
  color: var(--sonnette-blue);
  font-size: 0.95rem;
}

/* Equipment Catalog Grid */
.equipment-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.equip-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.equip-card {
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  transition: all 0.2s;
  cursor: pointer;
}

.equip-card:hover {
  border-color: var(--slate-300);
  box-shadow: var(--shadow-sm);
}

.equip-card.selected {
  border-color: var(--primary-emerald);
  background: var(--primary-emerald-surface);
}

.equip-info {
  flex-grow: 1;
}

.equip-category {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-emerald-dark);
  text-transform: uppercase;
}

.equip-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--slate-800);
  margin: 2px 0;
}

.equip-benefit {
  font-size: 0.78rem;
  color: var(--slate-500);
}

.equip-meta {
  text-align: right;
  min-width: 110px;
}

.equip-units {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--slate-900);
}

.equip-units span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--slate-500);
}

.equip-copay {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-emerald-dark);
}

/* Fitness Prescription Card */
.fitness-card {
  border-left: 4px solid var(--sonnette-blue);
  background: var(--white);
}

.fitness-plan-selector {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 14px 0;
}

.fit-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
}

.fit-option.active {
  border-color: var(--sonnette-blue);
  background: #f0f9ff;
}

.fit-option-info h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate-900);
}

.fit-option-info p {
  font-size: 0.78rem;
  color: var(--slate-600);
  margin-top: 2px;
}

.fit-option-price {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--sonnette-blue-dark);
}

.fit-evidence-box {
  background: var(--white);
  border: 1px dashed var(--sonnette-blue);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--slate-700);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.fit-evidence-box i {
  color: var(--sonnette-blue);
  flex-shrink: 0;
  margin-top: 2px;
}

/* Right Column: A4 Carte / Prescription Summary */
.carte-card {
  background: var(--white);
  border: 2px solid var(--slate-300);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 24px;
}

.carte-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 18px;
}

.carte-header-tag {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--primary-emerald-dark);
  background: var(--primary-emerald-surface);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: 6px;
}

.carte-header h2 {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--slate-900);
}

.carte-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--slate-50);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.carte-meta-item strong {
  color: var(--slate-900);
}

/* Financial Breakdown (Separated for Legal Compliance) */
.cost-separation-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.cost-block {
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.cost-block.insurance-block {
  background: var(--primary-emerald-surface);
  border: 1.5px solid #a7f3d0;
}

.cost-block.selfpay-block {
  background: var(--sonnette-blue-light);
  border: 1.5px solid #bae6fd;
}

.cost-block.total-summary-block {
  background: var(--slate-50);
  border: 2px solid var(--slate-300);
  padding: 12px 16px;
}

.cost-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.cost-type-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cost-type-badge.insurance {
  background: var(--primary-emerald);
  color: var(--white);
}

.cost-type-badge.selfpay {
  background: var(--sonnette-blue);
  color: var(--white);
}

.cost-subnote {
  font-size: 0.7rem;
  color: var(--slate-500);
  font-weight: 600;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--slate-600);
  margin-bottom: 4px;
}

.cost-row:last-child {
  margin-bottom: 0;
}

.cost-row.highlight strong {
  font-size: 0.95rem;
  font-weight: 800;
}

.insurance-block .cost-row.highlight strong {
  color: var(--primary-emerald-dark);
}

.selfpay-block .cost-row.highlight strong {
  color: var(--sonnette-blue-dark);
}

.cost-row.total {
  margin-bottom: 0;
}

.cost-block-footer-note {
  font-size: 0.68rem;
  color: var(--slate-500);
  margin-top: 6px;
  line-height: 1.3;
}

.cost-math-operator {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 16px;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--slate-400);
}

.total-label-group {
  display: flex;
  flex-direction: column;
}

.total-label-group span:first-child {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--slate-900);
}

.total-breakdown-sub {
  font-size: 0.68rem;
  color: var(--slate-500);
  margin-top: 1px;
}

.cost-row.total .cost-total-val {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--slate-900);
}

.carte-section-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--slate-700);
  text-transform: uppercase;
  margin: 14px 0 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.carte-item-list {
  font-size: 0.8rem;
  color: var(--slate-700);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.carte-item-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--slate-50);
  border-radius: 6px;
}

.prevention-saving-box {
  background: var(--accent-amber-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.78rem;
  color: #92400e;
  line-height: 1.5;
  margin-top: 14px;
}

.carte-footer-note {
  font-size: 0.7rem;
  color: var(--slate-400);
  margin-top: 16px;
  text-align: center;
  line-height: 1.4;
}

/* Modal Settings */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 90%;
  padding: 28px;
  box-shadow: var(--shadow-xl);
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--slate-400);
}

/* Print Styles (@media print) */
@media print {
  body {
    background: var(--white);
    color: #000;
  }
  .app-container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }
  .app-header,
  .policy-banner,
  .card-input-section,
  .equipment-section,
  .fitness-plan-selector,
  .header-actions,
  .mode-toggle-group,
  .btn-print {
    display: none !important;
  }
  .main-grid {
    display: block !important;
  }
  .carte-card {
    border: none;
    box-shadow: none;
    position: static;
    width: 100%;
    padding: 0;
  }
  .cost-breakdown {
    background: #f8fafc !important;
    color: #000 !important;
    border: 1px solid #cbd5e1;
  }
  .cost-row {
    color: #334155 !important;
  }
  .cost-row.total .cost-total-val {
    color: #059669 !important;
  }
}

/* Responsive */
@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .carte-card {
    position: static;
  }
}
