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

/* ── Light Theme ── */
:root {
  --bg:            #F3F4F6;
  --surface:       #FFFFFF;
  --surface2:      #F9FAFB;
  --border:        #E5E7EB;
  --accent:        #FFA21F;
  --accent-dim:    rgba(255,162,31,0.08);
  --accent-border: rgba(255,162,31,0.25);
  --text:          #111827;
  --text2:         #4B5563;
  --muted:         #9CA3AF;
  --muted2:        #6B7280;
  --red:           #EF4444;
  --red-bg:        #FEF2F2;
  --red-border:    #FEE2E2;
  --green:         #10B981;
  --green-bg:      #ECFDF5;
  --green-border:  #D1FAE5;
  --shadow:        0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg:            #0B0F17;
  --surface:       #151D2A;
  --surface2:      #1C2637;
  --border:        #263349;
  --accent:        #FFA21F;
  --accent-dim:    rgba(255,162,31,0.12);
  --accent-border: rgba(255,162,31,0.35);
  --text:          #F9FAFB;
  --text2:         #E5E7EB;
  --muted:         #6B7280;
  --muted2:        #9CA3AF;
  --red:           #F87171;
  --red-bg:        rgba(239, 68, 68, 0.08);
  --red-border:    rgba(239, 68, 68, 0.2);
  --green:         #34D399;
  --green-bg:      rgba(16, 185, 129, 0.08);
  --green-border:  rgba(16, 185, 129, 0.2);
  --shadow:        0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title span { color: var(--accent); }

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

.btn-theme {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.btn-theme:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.btn-nav {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-nav:hover { border-color: var(--accent); color: var(--accent); }

.btn-login {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  padding: 7px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-login:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Layout ── */
main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: start;
}

main > div {
  min-width: 0;
}

@media (max-width: 1024px) {
  main { grid-template-columns: 1fr; }
}

.panel-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-title i { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Form Styling ── */
.form-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.form-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.section-hdr {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface2);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}

.section-hdr:hover {
  background: var(--accent-dim);
}

.section-hdr span {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-hdr .arrow-icon {
  font-size: 11px;
  color: var(--muted2);
  transition: transform 0.2s ease;
}

.form-section.collapsed .arrow-icon {
  transform: rotate(-90deg);
}

.form-section.collapsed .section-content {
  display: none;
}

.section-content {
  padding: 14px 6px 4px 6px;
}

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

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: all 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--surface);
}

/* ── Recommendation Banner ── */
.login-recommendation {
  grid-column: 1 / -1;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.login-recommendation i {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.login-recommendation span {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.5;
  flex: 1;
  min-width: 0;
}

.login-recommendation a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
}

.login-status-ok {
  grid-column: 1 / -1;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.login-status-ok i {
  font-size: 20px;
  color: var(--green);
  flex-shrink: 0;
}

.login-status-ok span {
  font-size: 12.5px;
  color: var(--text2);
  flex: 1;
  min-width: 0;
}

/* ── Family Sub-table Form (Responsive Card Style) ── */
.family-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.family-member-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  box-sizing: border-box;
}

.family-member-num {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.family-member-fields {
  flex: 1;
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.2fr 1.3fr 1.2fr 1.2fr;
  gap: 12px;
}

.family-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.family-field label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted2);
  letter-spacing: 0.5px;
}

.btn-remove-member {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  margin-top: 17px;
}

.btn-remove-member:hover {
  background: var(--red);
  color: white;
}

.btn-add-row {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.btn-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

@media (max-width: 1024px) {
  .family-member-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .family-member-item {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .family-member-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .btn-remove-member {
    margin-top: 0;
    width: 100%;
  }
}

/* ── Classic Table Styling ── */
.classic-table-container {
  background: #FFFFFF;
  color: #000000;
  border: 2px solid #000000;
  padding: 20px;
  font-family: 'Times New Roman', Times, serif;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.classic-table-title {
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 3px;
  border-bottom: 1px solid #00;
  padding-bottom: 8px;
  color: #000 !important;
}

.classic-table-subtitle {
  text-align: center;
  font-size: 11px;
  font-style: italic;
  margin-bottom: 15px;
  color: #333 !important;
}

.classic-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  font-size: 12.5px;
}

.classic-table th, .classic-table td {
  border: 1px solid #000000;
  padding: 6px 8px;
  text-align: left;
  color: #000000 !important;
  background: #ffffff !important;
}

.classic-table th {
  background-color: #F2F2F2 !important;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 11.5px;
  text-align: center;
}

.classic-table .section-header {
  background-color: #E6E6E6 !important;
  font-weight: bold;
  font-size: 12px;
}

.classic-table .text-center {
  text-align: center;
}

.classic-table .text-right {
  text-align: right;
}

.classic-badge {
  border: 1px solid #000000;
  padding: 2px 6px;
  font-weight: bold;
  font-size: 11px;
  display: inline-block;
}

/* ── Action Buttons ── */
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
  text-decoration: none;
}

.btn-danger { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.btn-danger:hover { filter: brightness(0.95); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:hover { opacity: 0.9; }

.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }
.btn-secondary:hover { border-color: var(--text2); color: var(--text); }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  font-size: 12px;
  color: var(--muted2);
  text-align: center;
  background: var(--surface);
  margin-top: auto;
}
.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  body, html {
    overflow-x: hidden;
    width: 100%;
  }
  header {
    padding: 0 12px;
  }
  .btn-nav span, .btn-login span {
    display: none;
  }
  .btn-nav, .btn-login {
    padding: 8px 10px;
  }
  main {
    padding: 12px 10px;
    gap: 16px;
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }
  .card {
    padding: 12px;
    gap: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .classic-table-container {
    padding: 10px;
    border-width: 1px;
    overflow-x: auto;
  }
  .classic-table th, .classic-table td {
    padding: 4px 6px;
    font-size: 10.5px;
  }
  .classic-table-title {
    font-size: 14px;
  }
  .btn-row {
    flex-direction: column;
  }
}

/* ── Info Alert Box ── */
.info-alert {
  background: var(--surface2);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.info-alert i {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.info-alert-body {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.6;
  flex: 1;
}
