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

body {
  font-family: var(--font-sans);
  background-color: var(--surface-subtle);
  color: var(--text-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
.font-display {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.font-mono-label {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 11px;
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 256px;
  background: var(--surface-page);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-img {
  height: 24px;
  width: auto;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-ink);
}

.sidebar-nav {
  padding: 16px 12px;
}

.nav-section-title {
  padding: 8px 12px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  text-decoration: none;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 120ms ease-out;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-sunken);
  color: var(--text-ink);
}

.nav-item.active {
  background: var(--sage-50);
  color: var(--sage-800);
  font-weight: 600;
  border-left: 3px solid var(--sage-700);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.nav-item.active svg {
  color: var(--sage-700);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--sage-700);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-page);
}

.app-content {
  flex: 1;
  padding: 32px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.app-topbar {
  display: none;
  height: 56px;
  padding: 0 16px;
  background: var(--surface-page);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
}

.topbar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cards & Surfaces */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-ink);
}

.card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 120ms ease-out;
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--sage-700);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--sage-800);
}

.btn-secondary {
  background: transparent;
  color: var(--text-ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-sunken);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #FFF5F5;
  color: #C53030;
  border-color: #FEB2B2;
}

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

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.badge-sage {
  background: var(--sage-50);
  color: var(--sage-800);
  border: 1px solid var(--sage-300);
}

.badge-gray {
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-pulse {
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

/* Progress bar */
.progress-container {
  width: 100%;
  background: var(--border);
  height: 6px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  background: var(--sage-700);
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 300ms ease-out;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-body);
}

.input-field, .select-field {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-body);
  background: var(--surface-page);
  width: 100%;
  font-family: inherit;
  transition: border-color 120ms ease-out;
}

.input-field:focus, .select-field:focus {
  outline: none;
  border-color: var(--sage-700);
  box-shadow: 0 0 0 1px var(--sage-700);
}

.select-field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235F5F58' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.data-table th {
  background: var(--surface-sunken);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 32, 54, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-content {
  background: var(--surface-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-md);
  animation: modal-pop 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Signup account type */
.account-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 132px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-page);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.account-type-card:hover {
  border-color: var(--sage-400);
  transform: translateY(-1px);
}

.account-type-card:has(input:checked) {
  border-color: var(--sage-700);
  background: var(--sage-50);
  box-shadow: 0 0 0 1px var(--sage-700);
}

.account-type-card:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--sage-700) 25%, transparent);
  outline-offset: 2px;
}

.account-type-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.account-type-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: white;
}

.account-type-card:has(input:checked) .account-type-check {
  border: 5px solid var(--sage-700);
}

.account-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  color: var(--sage-700);
  background: var(--surface-sunken);
}

.account-type-icon svg {
  width: 18px;
  height: 18px;
}

.account-type-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.account-type-copy strong {
  font-size: 13px;
  color: var(--text-body);
}

.account-type-copy small {
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.organization-signup-fields {
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: signup-fields-in 160ms ease-out;
}

.organization-signup-fields[hidden] {
  display: none;
}

@keyframes signup-fields-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .app-shell {
    flex-direction: column;
  }
  .app-topbar {
    display: flex;
  }
  .app-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    width: 280px;
    height: 100vh;
    box-shadow: var(--shadow-md);
  }
  .app-sidebar.open {
    display: flex;
  }
  .app-content {
    padding: 20px 16px;
  }

  .account-type-grid {
    grid-template-columns: 1fr;
  }

  .account-type-card {
    min-height: 104px;
  }
}
