/* ══════════════════════════════════════════
   長照補助試算器 · subsidy-calculator.css
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  background: #F1F5F9; color: #1E293B; min-height: 100vh;
}

/* ── Top Bar ── */
.sc-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid #E2E8F0;
  padding: .75rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sc-back { color: #4F7EFF; text-decoration: none; font-size: .875rem; font-weight: 500; white-space: nowrap; }
.sc-back:hover { text-decoration: underline; }
.sc-topbar-brand { flex: 1; text-align: center; font-weight: 700; color: #1E293B; }
.sc-topbar-brand small { font-weight: 400; color: #64748B; margin-left: .35rem; }

/* ── Hero ── */
.sc-hero {
  background: linear-gradient(135deg, #1E3A8A 0%, #4F7EFF 60%, #7C3AED 100%);
  color: #fff; padding: 2rem 1.5rem 1.75rem; text-align: center;
}
.sc-hero h1 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 900; margin-bottom: .4rem; }
.sc-hero p  { font-size: .9rem; opacity: .85; max-width: 520px; margin: 0 auto; }

/* ── Layout ── */
.sc-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  max-width: 1140px;
  margin: 1.25rem auto 3rem;
  padding: 0 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .sc-layout { grid-template-columns: 1fr; }
  .sc-sidebar { order: -1; }
}

/* ── Basic Info Card ── */
.sc-basic-card {
  background: #fff; border: 1px solid #E2E8F0; border-radius: 1rem;
  margin-bottom: 1.25rem; overflow: hidden;
}
.sc-basic-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .875rem 1.25rem .75rem;
  background: #F8FAFC; border-bottom: 1px solid #E2E8F0;
}
.sc-basic-head h2 { font-size: .9375rem; font-weight: 700; }
.sc-basic-body { padding: 1.1rem 1.25rem; }

.sc-basic-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 620px) { .sc-basic-grid { grid-template-columns: 1fr; } }

.sc-field { display: flex; flex-direction: column; gap: .4rem; }
.sc-field > label { font-size: .75rem; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: .04em; }

/* Level buttons */
.sc-level-grid { display: flex; gap: .4rem; flex-wrap: wrap; }
.sc-level-btn {
  padding: .4rem .75rem; border: 2px solid #CBD5E1; border-radius: .5rem;
  background: #fff; font-family: inherit; font-size: .875rem; font-weight: 700;
  color: #475569; cursor: pointer; transition: all .15s; min-width: 56px; text-align: center;
}
.sc-level-btn:hover { border-color: #4F7EFF; color: #4F7EFF; }
.sc-level-btn.active { background: #4F7EFF; border-color: #4F7EFF; color: #fff; box-shadow: 0 2px 8px rgba(79,126,255,.3); }

/* Household radio */
.sc-household-grid { display: flex; flex-direction: column; gap: .4rem; }
.sc-household-opt { position: relative; display: block; cursor: pointer; }
.sc-household-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.sc-household-label {
  display: flex; justify-content: space-between; align-items: center;
  padding: .45rem .7rem; border: 2px solid #E2E8F0; border-radius: .5rem; transition: all .15s;
}
.sc-household-opt input:checked + .sc-household-label { border-color: #4F7EFF; background: #EEF2FF; }
.sc-hh-name { font-size: .8125rem; font-weight: 700; }
.sc-hh-rate { font-size: .75rem; color: #64748B; }
.sc-household-opt input:checked + .sc-household-label .sc-hh-rate { color: #4F7EFF; }

/* Toggle (外籍看護) */
.sc-toggle-wrap { display: flex; flex-direction: column; gap: .5rem; }
.sc-toggle-item { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.sc-toggle-item input[type="checkbox"] { display: none; }
.sc-toggle-track {
  width: 40px; height: 22px; border-radius: 99px;
  background: #CBD5E1; position: relative; flex-shrink: 0;
  transition: background .2s;
}
.sc-toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.sc-toggle-item input:checked + .sc-toggle-track { background: #4F7EFF; }
.sc-toggle-item input:checked + .sc-toggle-track::after { transform: translateX(18px); }
.sc-toggle-label { font-size: .875rem; font-weight: 500; color: #1E293B; line-height: 1.3; }
.sc-toggle-sub { font-size: .75rem; color: #94A3B8; display: block; }

/* ── Category Tabs ── */
.sc-cat-tabs { display: flex; gap: 0; margin-bottom: 0; overflow-x: auto; background: #fff; border: 1px solid #E2E8F0; border-radius: 1rem 1rem 0 0; border-bottom: none; }
.sc-cat-tab {
  flex: 1; min-width: 110px;
  padding: .75rem .5rem;
  border: none; background: none; font-family: inherit;
  font-size: .8125rem; font-weight: 600; color: #64748B;
  cursor: pointer; border-bottom: 3px solid transparent;
  transition: all .15s; display: flex; flex-direction: column; align-items: center; gap: .15rem;
  text-align: center;
}
.sc-cat-tab:hover { color: #4F7EFF; background: #F8FAFF; }
.sc-cat-tab.active { color: #4F7EFF; border-bottom-color: #4F7EFF; background: #EEF2FF; }
.sc-cat-tab-icon { font-size: 1.25rem; }
.sc-cat-tab-limit { font-size: .7rem; color: #94A3B8; font-weight: 400; }
.sc-cat-tab.active .sc-cat-tab-limit { color: #4F7EFF; }

/* ── Service Panel ── */
.sc-service-panel {
  background: #fff; border: 1px solid #E2E8F0;
  border-radius: 0 0 1rem 1rem; margin-bottom: 1.25rem;
}
.sc-panel-content { display: none; }
.sc-panel-content.active { display: block; }

/* Mini budget bar inside panel */
.sc-panel-budget {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem; background: #FAFBFF; border-bottom: 1px solid #E2E8F0;
  flex-wrap: wrap;
}
.sc-pbudget-label { font-size: .8rem; font-weight: 600; color: #64748B; white-space: nowrap; }
.sc-pbudget-track { flex: 1; min-width: 100px; height: 8px; background: #E2E8F0; border-radius: 99px; overflow: hidden; }
.sc-pbudget-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg,#4F7EFF,#7C3AED); transition: width .3s; max-width: 100%; }
.sc-pbudget-fill.over { background: linear-gradient(90deg,#F59E0B,#DC2626); }
.sc-pbudget-nums { font-size: .8rem; color: #475569; white-space: nowrap; }
.sc-pbudget-nums strong { color: #1E293B; }

/* Section header inside panel */
.sc-section-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1.25rem; background: #F8FAFC;
  border-top: 1px solid #E2E8F0; border-bottom: 1px solid #E2E8F0;
  font-size: .8125rem; font-weight: 700; color: #475569;
}
.sc-section-head:first-of-type { border-top: none; }

/* Service table */
.sc-svc-table { width: 100%; border-collapse: collapse; }
.sc-svc-table thead th {
  padding: .55rem .875rem; background: #FAFBFF;
  font-size: .7rem; font-weight: 700; color: #94A3B8;
  text-transform: uppercase; letter-spacing: .04em;
  text-align: left; border-bottom: 1px solid #E2E8F0;
}
.sc-svc-table thead th:nth-child(3),
.sc-svc-table thead th:nth-child(4),
.sc-svc-table thead th:nth-child(5) { text-align: right; }

.sc-svc-row td { padding: .55rem .875rem; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
.sc-svc-row:last-child td { border-bottom: none; }
.sc-svc-row:hover { background: #FAFBFF; }
.sc-svc-row.disabled { opacity: .35; pointer-events: none; }
.sc-svc-row.disabled .sc-qty-input { background: #F1F5F9; }

.sc-code { font-size: .7rem; font-family: monospace; background: #F1F5F9; color: #64748B; padding: .1rem .35rem; border-radius: .25rem; white-space: nowrap; }
.sc-svc-name { font-size: .875rem; color: #1E293B; }
.sc-svc-note { font-size: .7rem; color: #F59E0B; display: block; }
.sc-unit-price { font-size: .8125rem; color: #94A3B8; text-align: right; white-space: nowrap; }
.sc-subtotal { font-size: .875rem; font-weight: 700; color: #4F7EFF; text-align: right; white-space: nowrap; min-width: 80px; }
.sc-subtotal.zero { color: #CBD5E1; font-weight: 400; }

/* Qty stepper */
.sc-qty-cell { text-align: right; }
.sc-qty-wrap { display: inline-flex; align-items: center; border: 1.5px solid #CBD5E1; border-radius: .5rem; overflow: hidden; }
.sc-qty-btn {
  width: 1.875rem; height: 1.875rem; border: none; background: #F8FAFC;
  font-size: 1rem; font-weight: 700; color: #475569;
  cursor: pointer; transition: background .1s; flex-shrink: 0;
}
.sc-qty-btn:hover { background: #E2E8F0; }
.sc-qty-input {
  width: 2.25rem; height: 1.875rem;
  border: none; border-left: 1.5px solid #CBD5E1; border-right: 1.5px solid #CBD5E1;
  text-align: center; font-family: inherit; font-size: .875rem; font-weight: 600;
  -moz-appearance: textfield; background: #fff;
}
.sc-qty-input::-webkit-outer-spin-button,
.sc-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Result Sidebar ── */
.sc-result-card {
  position: sticky; top: 64px;
  background: #fff; border: 1px solid #E2E8F0; border-radius: 1rem; overflow: hidden;
}
.sc-result-top {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #1E3A8A 0%, #4F7EFF 100%);
  color: #fff;
}
.sc-result-top h3 { font-size: .875rem; font-weight: 600; opacity: .8; margin-bottom: .2rem; }
.sc-result-level-row { display: flex; align-items: baseline; gap: .5rem; }
.sc-result-level { font-size: 1.375rem; font-weight: 900; }
.sc-result-hhtype { font-size: .8rem; opacity: .75; }

/* 4 budget mini cards in sidebar */
.sc-budget-list { padding: .85rem 1rem; display: flex; flex-direction: column; gap: .65rem; }
.sc-bcard {
  border: 1.5px solid #E2E8F0; border-radius: .625rem; padding: .65rem .875rem;
  transition: border-color .2s;
}
.sc-bcard.over { border-color: #FECACA; background: #FEF9F9; }
.sc-bcard.ok   { border-color: #BBF7D0; background: #F0FDF4; }
.sc-bcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.sc-bcard-name { font-size: .8rem; font-weight: 700; color: #1E293B; }
.sc-bcard-period { font-size: .7rem; color: #94A3B8; }
.sc-bcard-track { height: 6px; background: #E2E8F0; border-radius: 99px; overflow: hidden; margin-bottom: .4rem; }
.sc-bcard-fill  { height: 100%; border-radius: 99px; background: linear-gradient(90deg,#4F7EFF,#7C3AED); transition: width .3s; max-width: 100%; }
.sc-bcard-fill.over { background: linear-gradient(90deg,#F59E0B,#DC2626); }
.sc-bcard-nums { display: flex; justify-content: space-between; font-size: .75rem; }
.sc-bcard-used     { color: #1E293B; font-weight: 700; }
.sc-bcard-limit    { color: #94A3B8; }
.sc-bcard-remain   { font-size: .7rem; }
.sc-bcard-remain.ok   { color: #16A34A; }
.sc-bcard-remain.over { color: #DC2626; }

/* Totals section */
.sc-totals { padding: .75rem 1.25rem; border-top: 2px solid #F1F5F9; }
.sc-total-row { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; }
.sc-total-row + .sc-total-row { border-top: 1px solid #F1F5F9; }
.sc-total-label { font-size: .875rem; color: #64748B; }
.sc-total-value { font-size: .9375rem; font-weight: 700; }
.sc-total-value.primary { color: #4F7EFF; }
.sc-total-value.success { color: #16A34A; }
.sc-total-value.danger  { color: #DC2626; }
.sc-grand-row { display: flex; justify-content: space-between; align-items: center; padding: .7rem 0 .35rem; border-top: 2px solid #E2E8F0; margin-top: .25rem; }
.sc-grand-label  { font-size: 1rem; font-weight: 700; }
.sc-grand-amount { font-size: 1.4rem; font-weight: 900; color: #1E293B; }

/* Status */
.sc-status { padding: .6rem 1.25rem; font-size: .8125rem; font-weight: 600; border-top: 1px solid #E2E8F0; }
.sc-status.ok   { color: #16A34A; background: #F0FDF4; }
.sc-status.over { color: #DC2626; background: #FEF2F2; }

/* CTA */
.sc-cta-wrap { padding: .85rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.sc-cta {
  display: block; padding: .75rem 1rem; border-radius: .625rem;
  background: #4F7EFF; color: #fff; border: none;
  font-family: inherit; font-size: .9375rem; font-weight: 700;
  text-align: center; text-decoration: none; cursor: pointer;
  transition: background .15s;
}
.sc-cta:hover { background: #3B6FEE; }
.sc-cta.outline { background: #fff; color: #4F7EFF; border: 2px solid #4F7EFF; }
.sc-cta.outline:hover { background: #EEF2FF; }
.sc-reset { background: none; border: none; font-family: inherit; font-size: .8rem; color: #94A3B8; cursor: pointer; text-align: center; text-decoration: underline; }
.sc-reset:hover { color: #64748B; }

/* Notice box */
.sc-notice {
  max-width: 1140px; margin: 0 auto 2rem; padding: 0 1.25rem;
  font-size: .8rem; color: #94A3B8; line-height: 1.7; text-align: center;
}

@media (max-width: 540px) {
  .sc-svc-table thead th:nth-child(2) { display: none; }
  .sc-svc-row td:nth-child(2) { display: none; }
}
