:root {
  --navy: #24416b;
  --blue: #00abed;
  --orange: #ea7400;
  --green: #009900;
  --light: #f5f7fa;
  --border: #dde3ec;
  --text: #1a1a2e;
  --muted: #6b7a99;
}

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

body {
  font-family: Arial, sans-serif;
  background: var(--light);
  color: var(--text);
  min-height: 100vh;
}

/* ── Auth ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo h1 {
  font-size: 28px;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-card .logo span {
  color: var(--blue);
}

.auth-card .logo p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: Arial, sans-serif;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
}
.btn-primary:hover { background: #1a3055; }

.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #0099d4; }

.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: #cc6600; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--navy);
}
.btn-outline:hover { background: var(--light); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-logo span { color: var(--blue); }

.sidebar-logo .subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.user-info .name { font-weight: 600; color: #fff; }
.user-info .role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: capitalize; }

/* ── Main content ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.top-bar h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.top-bar .actions { display: flex; gap: 12px; align-items: center; }

.page-body {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* ── Client Cards ── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.client-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.18s;
}

.client-card:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 16px rgba(0,171,237,0.12);
  transform: translateY(-1px);
}

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-active { background: #e6f4e6; color: var(--green); }
.status-at_risk { background: #fff3e0; color: var(--orange); }
.status-on_hold { background: #f5f5f5; color: var(--muted); }
.status-inactive { background: #feeee; color: #e53e3e; }

.client-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.client-card-footer {
  display: flex;
  justify-content: flex-end;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
  gap: 4px;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--blue); }

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

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th {
  background: var(--light);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--light); }

/* ── Cards / Panels ── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── COMPASS content ── */
.compass-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  font-family: Arial, sans-serif;
}

/* ── Agent Run ── */
.agent-output {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 600px;
  overflow-y: auto;
}

.workflow-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.workflow-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.workflow-option:hover { border-color: var(--blue); }
.workflow-option.selected { border-color: var(--navy); background: #f0f4ff; }
.workflow-option .icon { font-size: 28px; margin-bottom: 8px; }
.workflow-option .label { font-size: 14px; font-weight: 600; color: var(--navy); }
.workflow-option .desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fff5f5; border: 1px solid #feb2b2; color: #c53030; }
.alert-success { background: #f0fff4; border: 1px solid #9ae6b4; color: #276749; }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px;
  color: var(--muted);
  font-size: 15px;
}

/* ── Misc ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  max-width: 300px;
}
.search-bar input {
  border: none;
  outline: none;
  font-size: 14px;
  width: 100%;
  font-family: Arial, sans-serif;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  text-decoration: none;
}
.back-link:hover { color: var(--navy); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}
