@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --emerald: #0d7a4e;
  --emerald-dark: #0a5e3c;
  --emerald-light: #e8f5ee;
  --emerald-50: #f0faf5;
  --gold: #c9a84c;
  --gold-light: #f5ecd4;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --red-500: #ef4444;
  --amber-500: #f59e0b;
  --amber-50: #fffbeb;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.7;
}

/* HEADER */
.header {
  background: linear-gradient(135deg, var(--emerald-dark) 0%, var(--emerald) 100%);
  color: white;
  padding: 48px 20px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(201,168,76,0.1) 0%, transparent 50%);
}
.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  position: relative;
  margin-bottom: 6px;
}
.header .subtitle {
  font-size: 1rem;
  opacity: 0.85;
  font-weight: 300;
  position: relative;
}
.header .version {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  margin-top: 10px;
  position: relative;
  backdrop-filter: blur(4px);
}
.header .clinic-info {
  font-size: 0.82rem;
  opacity: 0.75;
  margin-top: 12px;
  position: relative;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px 100px; }

/* TABS */
.tab-nav {
  display: flex;
  gap: 0;
  margin: 32px 0 24px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
}
.tab-btn {
  flex: 1;
  padding: 14px 24px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: white;
  color: var(--gray-500);
  transition: all 0.2s;
}
.tab-btn.active {
  background: var(--emerald);
  color: white;
}
.tab-btn:not(.active):hover { background: var(--gray-50); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* OVERVIEW */
.overview-box {
  background: white;
  border-radius: 16px;
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 5px solid var(--emerald);
}
.overview-catmi { border-left-color: #f59e0b; }
.overview-box h2 {
  font-family: 'Playfair Display', serif;
  color: var(--emerald-dark);
  margin-bottom: 8px;
  font-size: 1.4rem;
}
.overview-box p { font-size: 0.92rem; color: var(--gray-700); }
.overview-goal {
  margin-top: 12px;
  background: var(--emerald-50);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--emerald-dark);
}

/* TEST LINK */
.test-link-box {
  margin-top: 16px;
  text-align: center;
}
.btn-test {
  display: inline-block;
  background: linear-gradient(135deg, var(--emerald), var(--emerald-dark));
  color: white;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(13,122,78,0.3);
}
.btn-test:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13,122,78,0.4);
}

/* FLOWCHART */
.flowchart-section {
  background: white;
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-align: center;
}
.flowchart-section h2 {
  font-family: 'Playfair Display', serif;
  color: var(--emerald-dark);
  margin-bottom: 20px;
  font-size: 1.3rem;
}
.flowchart-section img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.flow-note {
  margin-top: 16px;
  font-size: 0.88rem;
  color: var(--gray-500);
}
.flow-note strong { color: var(--emerald-dark); }
.flow-diagram { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.flow-row { display: flex; justify-content: center; }
.flow-arrow { font-size: 1.2rem; color: var(--gray-300); }
.flow-node {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.flow-start { background: var(--emerald-light); color: var(--emerald-dark); }
.flow-check { background: #fef3c7; color: #92400e; }
.flow-photo { background: #fff7ed; color: #ea580c; }
.flow-router { background: #ede9fe; color: #6d28d9; }
.flow-leaf { background: var(--gray-100); color: var(--gray-700); font-size: 0.78rem; padding: 8px 12px; }
.flow-split {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 4px;
}
.flow-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.flow-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--emerald);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.flow-5col { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* BRANCH CARDS */
.branch-card {
  background: white;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.2s;
}
.branch-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.branch-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  cursor: pointer;
  user-select: none;
}
.branch-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.branch-header h3 {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
}
.branch-badge {
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-main { background: var(--emerald-light); color: var(--emerald-dark); }
.badge-disc { background: #ede9fe; color: #6d28d9; }
.badge-count { background: #fef3c7; color: #92400e; }
.branch-toggle {
  font-size: 1.2rem;
  color: var(--gray-500);
  transition: transform 0.2s;
}
.branch-card.open .branch-toggle { transform: rotate(180deg); }

.branch-body { padding: 0 24px 24px; display: none; }
.branch-card.open .branch-body { display: block; }

/* TABLES */
.info-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.info-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.info-table td:first-child {
  width: 110px;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--emerald-dark);
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.section-label .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.sample-msg {
  background: var(--emerald-50);
  border-left: 3px solid var(--emerald);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--gray-700);
  margin: 8px 0;
}

/* STEPS */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.step-card {
  background: var(--gray-50);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--gray-200);
}
.step-goal { background: var(--emerald-50); border-color: var(--emerald); }
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--emerald);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.step-goal .step-num { background: var(--emerald-dark); }
.step-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; }
.step-desc { font-size: 0.78rem; color: var(--gray-500); line-height: 1.4; }

/* REJECT SECTION */
.reject-intro {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 16px;
  font-style: italic;
}
.reject-group {
  margin-bottom: 16px;
  border: 1px solid var(--gray-100);
  border-radius: 10px;
  overflow: hidden;
}
.reject-group h4 {
  background: var(--gray-50);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--gray-100);
}
.reject-count {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.reject-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reject-table td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--gray-50);
  vertical-align: top;
}
.reject-table td:first-child {
  width: 200px;
  font-weight: 500;
  color: var(--gray-700);
  white-space: nowrap;
}
.reject-table td:last-child { color: var(--gray-500); }
.reject-table tr:last-child td { border-bottom: none; }

/* DISC */
.disc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.disc-card {
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.disc-d { background: #fef2f2; border: 1px solid #fecaca; }
.disc-i { background: #fffbeb; border: 1px solid #fde68a; }
.disc-s { background: #f0fdf4; border: 1px solid #bbf7d0; }
.disc-c { background: #eff6ff; border: 1px solid #bfdbfe; }
.disc-letter {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: 'Playfair Display', serif;
}
.disc-d .disc-letter { color: #dc2626; }
.disc-i .disc-letter { color: #f59e0b; }
.disc-s .disc-letter { color: #22c55e; }
.disc-c .disc-letter { color: #3b82f6; }
.disc-name { font-weight: 700; font-size: 0.85rem; margin: 4px 0; }
.disc-sign { font-size: 0.78rem; color: var(--gray-500); }
.disc-adjust { font-size: 0.78rem; color: var(--gray-700); margin-top: 6px; font-weight: 500; }
.disc-note {
  font-size: 0.82rem;
  color: var(--gray-500);
  text-align: center;
  margin-top: 4px;
}

/* CLINIC */
.clinic-card {
  background: white;
  border-radius: 16px;
  padding: 28px 32px;
  margin-top: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--gray-200);
}
.clinic-card h2 {
  font-family: 'Playfair Display', serif;
  color: var(--emerald-dark);
  margin-bottom: 16px;
  font-size: 1.2rem;
}
.clinic-details { display: flex; flex-direction: column; gap: 12px; }
.clinic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}
.clinic-icon { font-size: 1.3rem; }

/* EDIT AREAS */
.edit-area {
  position: relative;
  margin: 16px 0 4px;
  border-top: 1px dashed var(--gray-200);
  padding-top: 16px;
}
.edit-area label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--emerald);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.edit-area textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}
.edit-area textarea:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(13,122,78,0.1);
}
.edit-area textarea::placeholder { color: var(--gray-300); font-style: italic; }
.btn-save-inline {
  margin-top: 8px;
  padding: 6px 20px;
  border: none;
  border-radius: 6px;
  background: var(--emerald);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-save-inline:hover { background: var(--emerald-dark); transform: translateY(-1px); }

/* SAVE BAR */
.save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 12px 24px;
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.btn {
  padding: 10px 28px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--emerald-dark), var(--emerald));
  color: white;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(13,122,78,0.3); }
.btn-secondary {
  background: white;
  color: var(--emerald-dark);
  border: 1.5px solid var(--emerald);
}
.btn-secondary:hover { background: var(--emerald-light); }

/* TOAST */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--emerald-dark);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.3s;
  z-index: 200;
}
.toast.show { transform: translateX(0); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .header h1 { font-size: 1.5rem; }
  .container { padding: 0 12px 40px; }
  .branch-body { padding: 0 16px 16px; }
  .flowchart-section { padding: 16px; }
  .steps-grid { grid-template-columns: repeat(2, 1fr); }
  .disc-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-split { flex-direction: column; gap: 16px; }
  .reject-table td:first-child { white-space: normal; width: 140px; }
  .overview-box { padding: 20px; }
}
@media (max-width: 480px) {
  .steps-grid { grid-template-columns: 1fr 1fr; }
  .disc-grid { grid-template-columns: 1fr 1fr; }
  .tab-btn { font-size: 0.88rem; padding: 12px 16px; }
  .save-bar { padding: 10px 12px; gap: 8px; }
  .btn { padding: 10px 16px; font-size: 0.82rem; }
  .reject-table td:first-child { width: 120px; font-size: 0.8rem; }
  .reject-table td { padding: 6px 10px; font-size: 0.8rem; }
  .header h1 { font-size: 1.3rem; letter-spacing: 1px; }
  .header .clinic-info { font-size: 0.72rem; }
}
