/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #1e293b;
  background: #f8fafc;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Accessibility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: #0F4C5C;
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* ===== Header ===== */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #0F4C5C;
  font-weight: 700;
  font-size: 1.2rem;
}

.logo-text {
  letter-spacing: -0.02em;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.nav-list a {
  text-decoration: none;
  color: #475569;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  border-bottom-color: #0F4C5C;
  color: #0F4C5C;
}

/* ===== Main Layout ===== */
main {
  flex: 1;
}

/* ===== Worksheet Section ===== */
.worksheet-section {
  padding: 2rem 1rem;
  background: #f1f5f9;
}

.worksheet-layout {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

.worksheet-main h1 {
  font-size: 1.8rem;
  color: #0F4C5C;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: #475569;
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}

/* ===== Panels ===== */
.panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-size: 1.15rem;
  color: #0F4C5C;
  font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  background: #fff;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: #0F4C5C;
  color: #fff;
  border-color: #0F4C5C;
}

.btn-primary:hover {
  background: #0a3945;
}

.btn-outline {
  border-color: #cbd5e1;
  color: #334155;
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

/* ===== Members List ===== */
.members-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.member-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
}

.member-card input[type="text"] {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  width: 100%;
  min-width: 120px;
}

.member-card select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  background: #fff;
  max-width: 140px;
}

.member-card .remove-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
  line-height: 1;
}

.member-card .remove-btn:hover {
  color: #b91c1c;
}

/* ===== Roles Grid ===== */
.roles-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.role-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
}

.role-row .role-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #0F4C5C;
}

.role-row select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #fff;
}

.role-row .remove-role-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
}

.role-row .remove-role-btn:hover {
  color: #b91c1c;
}

.role-row.unassigned {
  border-left: 4px solid #d97706;
}

.custom-role-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.custom-role-row input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* ===== Empty States ===== */
.empty-state {
  color: #94a3b8;
  font-style: italic;
  padding: 1rem 0;
  text-align: center;
  font-size: 0.9rem;
}

/* ===== Sidebar ===== */
.worksheet-sidebar {
  position: sticky;
  top: 80px;
}

.balance-panel h2 {
  font-size: 1.1rem;
  color: #0F4C5C;
  margin-bottom: 0.75rem;
}

.balance-meter {
  margin-bottom: 0.75rem;
}

.meter-bar {
  height: 12px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.meter-fill {
  height: 100%;
  background: #16a34a;
  border-radius: 6px;
  transition: width 0.3s ease, background 0.3s;
}

.meter-fill.warning {
  background: #d97706;
}

.meter-fill.danger {
  background: #b91c1c;
}

.meter-label {
  font-size: 0.82rem;
  color: #475569;
}

.balance-details {
  list-style: none;
  font-size: 0.85rem;
  color: #334155;
}

.balance-details li {
  padding: 0.3rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.balance-details li:last-child {
  border-bottom: none;
}

.assumptions-panel h2 {
  font-size: 1rem;
  color: #0F4C5C;
  margin-bottom: 0.5rem;
}

.assumptions-panel ul {
  list-style: disc;
  padding-left: 1.2rem;
  font-size: 0.82rem;
  color: #475569;
}

.assumptions-panel li {
  margin-bottom: 0.25rem;
}

.action-feedback {
  font-size: 0.82rem;
  color: #16a34a;
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ===== Support Section ===== */
.support-section {
  padding: 2.5rem 1rem;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

.support-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.support-inner h2 {
  font-size: 1.5rem;
  color: #0F4C5C;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.support-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
}

.support-card h3 {
  font-size: 1.05rem;
  color: #0F4C5C;
  margin-bottom: 0.5rem;
}

.support-card p {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.5;
}

.scenario-walkthrough {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.scenario-walkthrough h3 {
  font-size: 1.05rem;
  color: #166534;
  margin-bottom: 0.5rem;
}

.scenario-walkthrough p {
  font-size: 0.9rem;
  color: #14532d;
  line-height: 1.6;
}

.common-mistakes {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 1.25rem;
}

.common-mistakes h3 {
  font-size: 1.05rem;
  color: #9a3412;
  margin-bottom: 0.5rem;
}

.common-mistakes ul {
  list-style: disc;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  color: #7c2d12;
  line-height: 1.6;
}

/* ===== Ecosystem Section ===== */
.ecosystem-section {
  padding: 1.5rem 1rem;
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
}

.ecosystem-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.9rem;
  color: #475569;
}

.ecosystem-inner h2 {
  font-size: 1.1rem;
  color: #0F4C5C;
  margin-bottom: 0.5rem;
}

.ecosystem-inner a {
  color: #0F4C5C;
  font-weight: 600;
}

/* ===== Footer ===== */
.site-footer {
  background: #1e293b;
  color: #cbd5e1;
  padding: 1.5rem 1rem;
  font-size: 0.85rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.footer-inner a {
  color: #e2e8f0;
  text-decoration: none;
  margin-left: 1rem;
}

.footer-inner a:hover {
  text-decoration: underline;
}

.footer-note {
  width: 100%;
  color: #94a3b8;
  font-size: 0.78rem;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .worksheet-layout {
    grid-template-columns: 1fr;
  }

  .worksheet-sidebar {
    position: static;
  }

  .member-card {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .role-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .support-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-list {
    gap: 1rem;
    flex-wrap: wrap;
  }

  .worksheet-section {
    padding: 1rem 0.5rem;
  }

  .panel {
    padding: 1rem;
  }
}

/* ===== About Page (shared) ===== */
.about-page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.about-page h1 {
  font-size: 1.8rem;
  color: #0F4C5C;
  margin-bottom: 1rem;
}

.about-page .about-content {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #334155;
}

/* ===== Legal Pages ===== */
.legal-page {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.legal-page h1 {
  font-size: 1.8rem;
  color: #0F4C5C;
  margin-bottom: 1rem;
}

.legal-content {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #334155;
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
