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

:root {
  --green-dark: #1a2e23;
  --green-mid: #2d4a3e;
  --green-accent: #3a6b55;
  --cream: #f5f0e1;
  --cream-light: #faf7ee;
  --white: #ffffff;
  --text-dark: #1a2e23;
  --text-muted: #5a7a6a;
  --border: #d4cdb8;
  --orange: #e8834a;
  --shadow: 0 2px 12px rgba(26,46,35,0.08);
  --shadow-lg: 0 8px 32px rgba(26,46,35,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
}

.calculator-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

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

.calc-header {
  background: var(--green-dark);
  border-radius: var(--radius);
  padding: 32px 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.calc-header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(58,107,85,0.3) 0%, transparent 70%);
  border-radius: 50%;
}

.calc-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--cream);
  margin-bottom: 8px;
  position: relative;
}

.calc-header p {
  font-size: 14px;
  color: rgba(245,240,225,0.7);
  position: relative;
  max-width: 600px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(212,205,184,0.5);
}

.step-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green-accent);
  margin-bottom: 12px;
}

.step-label .num {
  background: var(--green-dark);
  color: var(--cream);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}

.card h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card .hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Search input for categories */
.search-input-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.search-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px 11px 38px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--cream-light);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px rgba(58,107,85,0.1);
}

.search-input::placeholder { color: #a0b0a5; }

/* Category groups */
.cat-groups-container {
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.cat-groups-container::-webkit-scrollbar { width: 4px; }
.cat-groups-container::-webkit-scrollbar-track { background: transparent; }
.cat-groups-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-group {
  border-bottom: 1px solid var(--border);
}

.cat-group:last-child { border-bottom: none; }

.cat-group-header {
  background: var(--cream-light);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.cat-group-header:hover { background: var(--cream); }

.cat-group-header .group-title {
  font-size: 13px;
  font-weight: 700;
}

.cat-group-header .group-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-group-header .group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--white);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.chevron {
  width: 16px; height: 16px;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.cat-group.collapsed .chevron { transform: rotate(-90deg); }
.cat-group.collapsed .cat-group-items { display: none; }

.cat-group-items {
  padding: 4px 10px;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(212,205,184,0.2);
  font-size: 13px;
  transition: var(--transition);
}

.cat-item:last-child { border-bottom: none; }
.cat-item:hover { background: var(--cream-light); border-radius: 4px; }
.cat-item.hidden-by-filter { display: none; }

.cat-item input[type="checkbox"] {
  accent-color: var(--green-accent);
  width: 16px; height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.cat-item label {
  cursor: pointer;
  flex: 1;
  line-height: 1.4;
}

.cat-group.hidden-by-filter { display: none; }

/* Selected categories counter badge */
.selected-cats-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.selected-cats-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.selected-cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-dark);
  color: var(--cream);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
}

.selected-cat-tag .remove-cat {
  cursor: pointer;
  opacity: 0.7;
  font-size: 14px;
  line-height: 1;
  transition: var(--transition);
}

.selected-cat-tag .remove-cat:hover { opacity: 1; }

/* Button */
.btn-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green-dark);
  color: var(--cream);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 28px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  justify-content: center;
}

.btn-search:hover { background: var(--green-accent); }
.btn-search:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-search svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* Results */
.results-col { min-width: 0; }

.class-group {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--white);
}

.class-group-header {
  background: var(--cream-light);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.class-group-header:hover { background: var(--cream); }

.class-group-header .class-title {
  font-size: 13px;
  font-weight: 700;
}

.class-group-header .class-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.class-group-header .class-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--white);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.class-group.collapsed .chevron { transform: rotate(-90deg); }
.class-group.collapsed .class-group-items { display: none; }

.class-group.dismissed {
  opacity: 0.45;
  order: 999;
}

.class-group.dismissed .class-group-items { display: none; }

.class-group.dismissed .class-group-header {
  background: #eee;
}

.class-group.dismissed .class-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.btn-dismiss-class {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-dismiss-class:hover {
  border-color: #c0392b;
  color: #c0392b;
  background: #fdeaea;
}

.class-group.dismissed .btn-dismiss-class {
  border-color: var(--green-accent);
  color: var(--green-accent);
}

.class-group.dismissed .btn-dismiss-class:hover {
  background: #e0f0e5;
}

.class-group-items {
  padding: 6px 10px;
  max-height: 260px;
  overflow-y: auto;
}

.class-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 4px;
  border-bottom: 1px solid rgba(212,205,184,0.2);
  font-size: 13px;
  transition: var(--transition);
}

.class-item:last-child { border-bottom: none; }
.class-item:hover { background: var(--cream-light); border-radius: 4px; }

.class-item input[type="checkbox"] {
  accent-color: var(--green-accent);
  width: 16px; height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}

.class-item label {
  cursor: pointer;
  flex: 1;
  line-height: 1.4;
}

.no-results {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 16px;
}

.sidebar .card { margin-bottom: 12px; }

.fee-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(212,205,184,0.25);
  gap: 8px;
}

.fee-row:last-child { border-bottom: none; }

.fee-row .fee-label {
  font-size: 12px;
  color: var(--text-dark);
  flex: 1;
  line-height: 1.4;
}

.fee-row .fee-label small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.fee-row .fee-amount {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.fee-total {
  background: var(--green-dark);
  color: var(--cream);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.fee-total .label { font-size: 14px; font-weight: 700; }
.fee-total .amount { font-size: 20px; font-weight: 800; }

.fee-stages {
  padding: 12px;
  background: var(--cream-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.fee-stages h4 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.stage-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.stage-row .stage-label { color: var(--text-muted); }
.stage-row .stage-amount { font-weight: 600; }

.fee-summary-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.fee-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 16px;
  line-height: 1.4;
}

.fee-disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 4px;
  line-height: 1.4;
  font-style: italic;
}

.btn-consult {
  display: block;
  width: 100%;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 8px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-consult:hover { background: #d6743d; }

.btn-reset {
  width: 100%;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset:hover { border-color: #c0392b; color: #c0392b; }

.sidebar-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.sidebar-empty svg {
  width: 40px; height: 40px;
  stroke: var(--border);
  fill: none; stroke-width: 1.5;
  margin-bottom: 10px;
}

.hidden { display: none !important; }

/* Popup */
.popup-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,46,35,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.popup-overlay.visible { display: flex; }

.popup {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: popupIn 0.25s ease;
}

@keyframes popupIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px;
  transition: var(--transition);
}

.popup-close:hover { color: var(--text-dark); }

.popup h3 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }

.popup .popup-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.popup .form-field { margin-bottom: 14px; }

.popup .form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}

.popup .form-field input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--cream-light);
  transition: var(--transition);
}

.popup .form-field input:focus {
  outline: none;
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px rgba(58,107,85,0.1);
}

.popup .form-consent {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.popup .btn-submit {
  width: 100%;
  background: var(--green-dark);
  color: var(--cream);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.popup .btn-submit:hover { background: var(--green-accent); }

.popup .success-msg {
  text-align: center;
  padding: 20px 0;
  display: none;
}

.popup .success-msg .check {
  width: 48px; height: 48px;
  background: #e0f0e5;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  color: var(--green-accent);
  font-size: 24px;
}

.popup .success-msg p { font-size: 15px; font-weight: 600; }
.popup .success-msg small { font-size: 13px; color: var(--text-muted); }

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-group label {
  display: inline-flex !important;
  align-items: center;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: var(--transition);
}

.radio-group label.selected {
  background: var(--green-dark);
  color: var(--cream);
  border-color: var(--green-dark);
}

.class-group-items::-webkit-scrollbar { width: 4px; }
.class-group-items::-webkit-scrollbar-track { background: transparent; }
.class-group-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* No filter results message */
.no-filter-results {
  text-align: center;
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: 13px;
  display: none;
}

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

  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    z-index: 100;
    padding: 0;
  }

  .sidebar .card {
    border-radius: 16px 16px 0 0;
    margin-bottom: 0;
    box-shadow: 0 -4px 24px rgba(26,46,35,0.15);
    max-height: 50vh;
    overflow-y: auto;
  }

  .sidebar .sidebar-empty { display: none; }

  .results-col { padding-bottom: 200px; }

  .calculator-wrapper { padding: 12px 10px 40px; }
  .calc-header { padding: 24px 20px; }
  .calc-header h1 { font-size: 20px; }
}

@media (max-width: 480px) {
  .card { padding: 18px 14px; }
}
