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

:root {
  --bg: #f8f8f8;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Nav */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { text-decoration: none; color: var(--muted); font-size: .9rem; }
.nav-links a:hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: .875rem;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 24px; }
.card-header { padding: 16px 24px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 600; }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.container-sm { max-width: 480px; margin: 0 auto; padding: 32px 24px; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: .8rem; color: var(--muted); }

/* Status badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: .75rem; font-weight: 600;
}
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-ready { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-org { background: #e0e7ff; color: #3730a3; font-weight: 500; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .875rem; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

/* Page section */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--muted); margin-top: 4px; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* Stat box */
.stat { text-align: center; padding: 20px; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* Spinner */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Org vertical tabs */
.org-tab-btn {
  display: block; width: 100%; padding: 9px 14px;
  text-align: left; border: none; background: none;
  font-size: .875rem; color: var(--muted); cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-tab-btn:hover { background: var(--bg); color: var(--text); }
.org-tab-btn.active { color: var(--accent); font-weight: 600; border-left-color: var(--accent); background: #eff6ff; }
.org-tab-btn.action { font-size: .8rem; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
@media (max-width: 700px) { .dash-grid { grid-template-columns: 1fr; } }

/* Icon buttons */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
  padding: 0; flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon-danger:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--danger);
  border-radius: 99px; transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Misc */
.text-muted { color: var(--muted); }
.text-sm { font-size: .875rem; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.justify-between { justify-content: space-between; }
