/* ============================================================
   GoodEarth Client Insights — Stylesheet
   ============================================================ */

:root {
  --bg:            #F4F5F7;
  --sidebar:       #1E2832;
  --sidebar-hover: rgba(255,255,255,0.05);
  --sidebar-act:   #2C7BE5;
  --primary:       #2C7BE5;
  --primary-h:     #1A68D1;
  --primary-light: #E9F2FF;
  --accent:        #F4A100;
  --accent-light:  #FFF8E1;
  --white:         #FFFFFF;
  --text:          #212529;
  --text-2:        #495057;
  --text-3:        #8B959E;
  --border:        #E3E6EB;
  --card-bg:       #FFFFFF;
  --shadow:        0 2px 4px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:     0 12px 32px rgba(0,0,0,0.12);
  --r:             8px;
  --r-sm:          4px;
  --sidebar-w:     240px;
  --header-h:      60px;
  --font:          'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 15.5px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input  { font-family: var(--font); }

/* ── Login ─────────────────────────────────────────────────── */

.login-page { background: var(--bg); }

.login-wrap {
  display: flex;
  min-height: 100vh;
}

.login-brand {
  width: 420px;
  flex-shrink: 0;
  background: var(--sidebar);
  background-image:
    radial-gradient(ellipse 60% 80% at 20% 80%, rgba(60,100,68,0.4) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 80% 20%, rgba(191,153,102,0.2) 0%, transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.brand-inner { color: #fff; }

.brand-logo { margin-bottom: 20px; }

.brand-name {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.brand-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 48px;
  font-weight: 400;
}

.brand-stats {
  display: flex;
  gap: 0;
  align-items: center;
}

.bs-item { display: flex; flex-direction: column; gap: 2px; }

.bs-num {
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
}

.bs-lbl {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bs-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  margin: 0 24px;
}

.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-header { margin-bottom: 32px; }

.login-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-header p {
  color: var(--text-2);
  font-size: 0.9rem;
}

.alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.alert-error {
  background: #FEF2F2;
  color: #C04040;
  border: 1px solid #FECACA;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-group input,
.pw-wrap input {
  width: 100%;
  padding: 12px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}

.field-group input:focus,
.pw-wrap input:focus {
  border-color: var(--primary);
}

.pw-wrap { position: relative; }

.pw-wrap input { padding-right: 44px; }

.pw-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  padding: 4px;
  display: flex;
  transition: color 0.15s;
}

.pw-toggle:hover { color: var(--text); }

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}

.btn-login:hover  { background: var(--primary-h); }
.btn-login:active { transform: scale(0.99); }

.login-help {
  font-size: 0.8rem;
  color: var(--text-3);
  text-align: center;
  margin-top: 24px;
}

@media (max-width: 720px) {
  .login-brand { display: none; }
}


/* ── App Layout ─────────────────────────────────────────────── */

.app-wrap {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #2C3E50;
}

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

.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.4);
  padding: 12px 20px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--sidebar-act);
  color: #fff;
  font-weight: 500;
}

/* Table */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #F3F4F7;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-transform: none;
  letter-spacing: 0;
}

tbody td {
  padding: 12px 18px;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid #EEF0F4;
  border-right: 1px solid #EEF0F4;
  background: #fff;
}

tbody tr:hover td {
  background: #F8FAFC;
}

.client-name {
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}

.client-name:hover {
  text-decoration: underline;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  font-weight: 500;
  transition: background 0.2s;
}

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

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text-2);
  background: #fff;
  border-radius: 4px;
  font-weight: 500;
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-left p {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}

.btn-refresh:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-refresh svg { transition: transform 0.4s; }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
}

.page-content {
  padding: 32px;
  flex: 1;
}


/* ── Stat Cards ─────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 18px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}

.stat-card.accent-tan::before  { background: var(--accent); }
.stat-card.accent-blue::before { background: #5272A0; }
.stat-card.accent-purple::before { background: #7253A0; }

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.green  { background: #EBF4ED; color: var(--primary); }
.stat-icon.tan    { background: #FBF5EE; color: var(--accent); }
.stat-icon.blue   { background: #EEF3FB; color: #5272A0; }
.stat-icon.purple { background: #F3EEFB; color: #7253A0; }

.stat-body { flex: 1; min-width: 0; }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 6px;
}

.stat-sub .up   { color: #3A8C52; font-weight: 600; }
.stat-sub .down { color: #C04040; font-weight: 600; }


/* ── Chart Grid ─────────────────────────────────────────────── */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.chart-card:hover { box-shadow: var(--shadow-md); }

.chart-card.full { grid-column: 1 / -1; }

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.chart-header-left {}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}

.chart-sub {
  font-size: 0.78rem;
  color: var(--text-3);
}

.unknown-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 10px;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
}

.chart-wrap {
  position: relative;
  height: 300px;
}

.chart-wrap.tall  { height: 360px; }
.chart-wrap.short { height: 220px; }

.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.donut-center .dc-num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.donut-center .dc-lbl {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* ── Legend ─────────────────────────────────────────────────── */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}


/* ── Bar List (horizontal) ──────────────────────────────────── */

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 8px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.bar-name {
  font-size: 0.84rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72%;
}

.bar-count {
  font-size: 0.78rem;
  color: var(--text-2);
  font-weight: 600;
}

.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), #4D8A58);
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}

.bar-fill.accent {
  background: linear-gradient(90deg, var(--accent), #D4AD78);
}


/* ── Setup Banner ───────────────────────────────────────────── */

.setup-banner {
  background: var(--card-bg);
  border: 1.5px dashed var(--border);
  border-radius: var(--r);
  padding: 40px;
  text-align: center;
  margin-bottom: 24px;
}

.setup-banner h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.setup-banner p {
  color: var(--text-2);
  font-size: 0.875rem;
  margin-bottom: 24px;
  line-height: 1.7;
}

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-align: left;
  max-width: 560px;
  margin: 0 auto 24px;
}

.setup-step {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.setup-step:last-child { border-bottom: none; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-body { }

.step-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.5;
}

.step-desc code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
  color: var(--primary);
  border: 1px solid var(--border);
}

.setup-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s;
}

.setup-link:hover { background: var(--primary-h); }


/* ── Clients Table ──────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--primary); }

.filter-select {
  padding: 9px 32px 9px 12px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  color: var(--text-2);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9A9A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

.filter-select:focus { border-color: var(--primary); }

.filter-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.78rem;
  color: var(--text-2);
  font-weight: 500;
}

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 14px 18px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #F0EDE8;
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFAF9; }

tbody td {
  padding: 14px 18px;
  font-size: 0.87rem;
  color: var(--text);
  vertical-align: middle;
}

.client-name {
  font-weight: 600;
  color: var(--text);
}

.client-email {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: #EBF4ED; color: #2F6637; }
.badge-tan    { background: #FBF5EE; color: #8C6030; }
.badge-blue   { background: #EEF3FB; color: #3052A0; }
.badge-gray   { background: #F2F2F2; color: #5C5C5C; }
.badge-purple { background: #F3EEFB; color: #5C30A0; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.table-info {
  font-size: 0.78rem;
  color: var(--text-3);
}

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
}

.pg-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
  border: 1.5px solid transparent;
}

.pg-btn:hover { background: var(--white); border-color: var(--border); }

.pg-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pg-btn:disabled { opacity: 0.3; cursor: not-allowed; }


/* ── Error / Loading states ────────────────────────────────── */

.error-card {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--r);
  padding: 24px;
  color: #B94040;
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.error-card strong { display: block; margin-bottom: 4px; font-size: 0.95rem; }

.skeleton {
  background: linear-gradient(90deg, #E8E4DC 25%, #F0ECE4 50%, #E8E4DC 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow);
}

.no-data {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 0.875rem;
}

.no-data svg { margin-bottom: 12px; opacity: 0.3; }


/* ── Number Stats (custom currency/number fields) ───────────── */

.num-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.ns-item {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 14px;
  text-align: center;
}

.ns-val {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-all;
}

.ns-lbl {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}


/* ── Settings Page ──────────────────────────────────────────── */

.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  margin-bottom: 20px;
}

.settings-card-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.settings-card-sub {
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 2px;
}

.field-count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
}

.add-field-form {
  padding: 0 24px 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}

.form-row-checks {
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 24px;
  margin-bottom: 20px;
}

.field-group-sm { min-width: 160px; }

.field-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 6px;
}

.req { color: #C04040; }

.field-group input,
.field-group select {
  width: 100%;
  padding: 9px 12px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.field-group input:focus,
.field-group select:focus { border-color: var(--primary); }

.field-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9A9A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-3);
  display: block;
  margin-top: 4px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.check-label input[type=checkbox] { display: none; }

.check-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.check-label input:checked + .check-box {
  background: var(--primary);
  border-color: var(--primary);
}

.check-label input:checked + .check-box::after {
  content: '';
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Fields Table */
.fields-table { padding: 0 24px; }

.ft-head, .ft-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 100px 90px 70px 100px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
}

.ft-head {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.ft-row {
  border-bottom: 1px solid #F0EDE8;
  font-size: 0.85rem;
}

.ft-row:last-child { border-bottom: none; }

.ft-api code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.78rem;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--primary);
  border: 1px solid var(--border);
}

.ft-label { font-weight: 500; }

.type-chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}

.type-category { background: #EBF4ED; color: #2F6637; }
.type-currency  { background: #FBF5EE; color: #8C6030; }
.type-number    { background: #EEF3FB; color: #3052A0; }

.tick  { color: var(--primary); font-weight: 700; font-size: 0.95rem; }
.cross { color: var(--text-3); }

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}

.btn-delete:hover { border-color: #C04040; color: #C04040; background: #FEF2F2; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 0.875rem;
}

.empty-state svg { margin-bottom: 12px; display: block; margin-left: auto; margin-right: auto; }

.sync-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  margin-top: 8px;
}

/* Type Guide */
.type-guide {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.tg-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}

.tg-item:last-child { border-bottom: none; }

.tg-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.tg-green  { background: #EBF4ED; color: var(--primary); }
.tg-tan    { background: #FBF5EE; color: var(--accent);  }
.tg-blue   { background: #EEF3FB; color: #3052A0; }

.tg-eg {
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
}


/* ── Export & Enrich Buttons ────────────────────────────────── */

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-export:hover { background: var(--primary-h); }

.btn-enrich-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--white);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-enrich-all:hover  { background: var(--primary); color: #fff; }
.btn-enrich-all:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-enrich-setup { color: var(--accent); border-color: var(--accent); }
.btn-enrich-setup:hover { background: var(--accent); color: #fff; }

.btn-enrich-row {
  padding: 4px 10px;
  border: 1.5px solid var(--primary);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  white-space: nowrap;
}

.btn-enrich-row:hover { background: var(--primary); color: #fff; }
.btn-enrich-retry { border-color: var(--accent); color: var(--accent); }
.btn-enrich-retry:hover { background: var(--accent); color: #fff; }
.btn-enrich-nodata { border-color: var(--text-3); color: var(--text-3); cursor: default; }
.btn-enrich-nodata:hover { background: transparent; color: var(--text-3); }

.btn-re-enrich {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  cursor: pointer;
  background: transparent;
  transition: all 0.15s;
}

.btn-re-enrich:hover { border-color: var(--primary); color: var(--primary); }

.enrich-no-email {
  font-size: 0.72rem;
  color: var(--text-3);
}

.enrich-head {
  background: #F0EEF8 !important;
}

.enrich-cell {
  font-size: 0.82rem;
  color: var(--text-2);
}

.enrich-tag {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7253A0;
  background: #EDE8F7;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 3px;
}

/* Progress bar */
.enrich-progress-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.epb-inner { display: flex; align-items: center; gap: 14px; }

.epb-label {
  font-size: 0.8rem;
  color: var(--text-2);
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.epb-track {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

.epb-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.epb-count {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Enrichment Settings ─────────────────────────────────────── */

.enrich-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
}

.enrich-ok  { background: #EBF4ED; color: #2F6637; }
.enrich-off { background: #F2F2F2; color: #7A7A7A; }

.enrich-how {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.eh-step {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
  line-height: 1.5;
}

.eh-step:last-child { border-bottom: none; }

.eh-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.enrich-key-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 4px;
}

.btn-outline {
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  background: var(--white);
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.alert-success {
  background: #EBF4ED;
  color: #2F6637;
  border: 1px solid #B4D8BA;
}

.enrich-fields-preview {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.efp-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 10px;
}

.efp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Provider selection cards */
.provider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.provider-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.provider-card input[type=radio] { display: none; }

.provider-card:hover { border-color: var(--primary); }

.provider-selected {
  border-color: var(--primary) !important;
  background: #F0F7F1;
}

.pc-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.pc-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.pc-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 99px;
}
.pc-badge-blue {
  background: #2563EB;
}

.pc-free {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.pc-desc {
  font-size: 0.78rem;
  color: var(--text-2);
  line-height: 1.5;
}

.efp-chip {
  font-size: 0.78rem;
  padding: 4px 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-2);
  font-weight: 500;
}

/* ── CEO Insights ───────────────────────────────────────────── */

.insights-page {
  background:
    linear-gradient(180deg, #F7F9FC 0%, #F3F6F8 42%, #F7F8FA 100%);
}

.insights-kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: #EAF2FF;
  border: 1px solid #CFE1FF;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.preset-card {
  --preset: #2C7BE5;
  --preset-soft: #EAF2FF;
  text-align: left;
  min-height: 126px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--preset) 15%, #fff) 0%, #fff 58%);
  border: 1.5px solid color-mix(in srgb, var(--preset) 24%, var(--border));
  border-radius: var(--r);
  padding: 17px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s, background 0.18s;
}

.preset-card:nth-child(2) { --preset: #F4A100; --preset-soft: #FFF5D9; }
.preset-card:nth-child(3) { --preset: #3A8C52; --preset-soft: #E7F5EC; }
.preset-card:nth-child(4) { --preset: #7253A0; --preset-soft: #F1EAF9; }
.preset-card:nth-child(5) { --preset: #D05A42; --preset-soft: #FCECE8; }
.preset-card:nth-child(6) { --preset: #168B8B; --preset-soft: #E5F6F6; }
.preset-card:nth-child(7) { --preset: #5272A0; --preset-soft: #EAF0F8; }
.preset-card:nth-child(8) { --preset: #8B6E47; --preset-soft: #F3EEE6; }

.preset-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--preset);
  transform: scaleY(0.42);
  transform-origin: top;
  transition: transform 0.22s ease;
}

.preset-card::after {
  content: '';
  position: absolute;
  right: -28px;
  top: -28px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--preset) 16%, transparent);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.preset-card:hover {
  border-color: color-mix(in srgb, var(--preset) 62%, var(--border));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--preset) 16%, rgba(20,35,50,0.12));
  transform: translateY(-3px);
}

.preset-card:hover::before,
.preset-card.active::before {
  transform: scaleY(1);
}

.preset-card:hover::after,
.preset-card.active::after {
  transform: scale(1.18);
  opacity: 0.9;
}

.preset-card.active {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--preset) 22%, #fff) 0%, #fff 64%);
  border-color: color-mix(in srgb, var(--preset) 72%, var(--border));
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--preset) 16%, transparent),
    0 12px 28px color-mix(in srgb, var(--preset) 12%, rgba(20,35,50,0.12));
}

.preset-card:active {
  transform: translateY(-1px) scale(0.99);
}

.preset-card span {
  display: inline-flex;
  align-items: center;
  position: relative;
  z-index: 1;
  background: var(--preset-soft);
  border: 1px solid color-mix(in srgb, var(--preset) 22%, transparent);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--preset) 72%, var(--text));
  line-height: 1.25;
  margin-bottom: 10px;
}

.preset-card small {
  display: block;
  position: relative;
  z-index: 1;
  font-size: 0.74rem;
  color: var(--text-2);
  line-height: 1.45;
}

.insight-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.25fr);
  gap: 20px;
  margin-bottom: 20px;
  max-width: 100%;
}

.insight-story,
.insight-chart-panel,
.insight-list-panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), #fff);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(32,44,58,0.07);
  min-width: 0;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}

.insight-story:hover,
.insight-chart-panel:hover,
.insight-list-panel:hover {
  border-color: #CDD9E8;
  box-shadow: 0 14px 34px rgba(32,44,58,0.10);
  transform: translateY(-1px);
}

.insight-story,
.insight-chart-panel {
  padding: 24px;
}

.insight-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.insight-panel-head h3 {
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.insight-panel-head p {
  color: var(--text-2);
  font-size: 0.85rem;
  margin-top: 4px;
  line-height: 1.55;
}

.takeaway-box {
  background:
    linear-gradient(135deg, #F0F6FF 0%, #F8FBFF 52%, #FFF8EA 100%);
  border: 1px solid #DCE9FB;
  border-radius: var(--r-sm);
  padding: 16px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.takeaway-box::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.takeaway-box span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  border: 1px solid #DCE9FB;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 6px;
}

.takeaway-box p {
  position: relative;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
}

.insight-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.insight-metric {
  background: #fff;
  border: 1px solid #DEE6F0;
  border-radius: var(--r-sm);
  padding: 14px;
  min-width: 0;
  box-shadow: 0 4px 14px rgba(32,44,58,0.04);
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.insight-metric:hover {
  border-color: #B8CBE5;
  box-shadow: 0 8px 22px rgba(44,123,229,0.10);
  transform: translateY(-2px);
}

.insight-metric span {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #F2F6FA;
  font-size: 0.68rem;
  color: var(--text-3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.insight-metric strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--primary);
  letter-spacing: -0.03em;
  white-space: normal;
  overflow-wrap: anywhere;
}

.insight-metric small {
  display: block;
  margin-top: 5px;
  font-size: 0.75rem;
  color: var(--text-2);
}

.insight-chart-wrap {
  height: 356px;
  padding: 10px;
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, #FBFCFE, #fff);
}

.insight-list-panel {
  padding: 20px 24px 8px;
}

.insight-row-list {
  display: flex;
  flex-direction: column;
}

.insight-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid #EEF0F4;
  background: transparent;
  font-family: var(--font);
  transition: background 0.16s, padding 0.16s;
}

.insight-row:hover {
  background: #F8FBFF;
  padding-left: 10px;
  padding-right: 10px;
}

.insight-row-drillable {
  cursor: pointer;
}

.insight-row-drillable:hover strong {
  color: var(--primary);
}

.insight-row-drillable:focus-visible {
  outline: 3px solid rgba(44,123,229,0.18);
  outline-offset: -3px;
}

.insight-row strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 2px;
}

.insight-row span {
  display: block;
  color: var(--text-3);
  font-size: 0.78rem;
}

.insight-row em {
  display: inline-flex;
  align-items: center;
  font-style: normal;
  font-weight: 700;
  color: #1C5FB8;
  background: #EAF2FF;
  border: 1px solid #CFE1FF;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.insight-list-panel .btn-outline {
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s, color 0.16s;
}

.insight-list-panel .btn-outline:hover {
  box-shadow: 0 8px 18px rgba(44,123,229,0.12);
  transform: translateY(-1px);
}

@keyframes insightPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--preset) 22%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

.preset-card.active {
  animation: insightPulse 0.65s ease-out;
}

.modal-open {
  overflow: hidden;
}

.insight-modal[hidden] {
  display: none;
}

.insight-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.insight-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16,24,32,0.54);
  backdrop-filter: blur(5px);
}

.insight-modal-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(78vh, 760px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #D7E2EF;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(12,24,36,0.28);
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}

.insight-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  background:
    linear-gradient(135deg, #F0F6FF 0%, #FFFFFF 58%, #FFF8EA 100%);
  border-bottom: 1px solid #E6ECF3;
}

.insight-modal-head h3 {
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.insight-modal-head p {
  margin-top: 4px;
  color: var(--text-2);
  font-size: 0.88rem;
}

.insight-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #D7E2EF;
  color: var(--text-2);
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s, border-color 0.16s, color 0.16s, box-shadow 0.16s;
}

.insight-modal-close:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(44,123,229,0.12);
  transform: rotate(8deg);
}

.insight-modal-list {
  overflow: auto;
  padding: 8px 24px 20px;
}

.insight-modal-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid #EEF0F4;
}

.insight-modal-client:last-child {
  border-bottom: none;
}

.insight-modal-client strong {
  display: block;
  font-size: 0.94rem;
  color: var(--text);
  margin-bottom: 2px;
}

.insight-modal-client span {
  display: block;
  color: var(--text-3);
  font-size: 0.8rem;
  line-height: 1.4;
}

.insight-modal-client em {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #EAF2FF;
  border: 1px solid #CFE1FF;
  color: #1C5FB8;
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.insight-empty {
  padding: 28px 0;
  color: var(--text-3);
  font-size: 0.875rem;
  border-top: 1px solid #EEF0F4;
}


/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1280px) {
  .chart-grid-4 { grid-template-columns: 1fr 1fr; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-grid-3 { grid-template-columns: 1fr 1fr; }
  .chart-grid-4 { grid-template-columns: 1fr 1fr; }
  .insight-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .main {
    width: calc(100% - var(--sidebar-w));
    flex: 0 0 calc(100% - var(--sidebar-w));
  }
  .sidebar-logo-text,
  .nav-link span,
  .nav-label { display: none; }
  .sidebar-logo { justify-content: center; padding: 20px 0; }
  .nav-link { justify-content: center; padding: 11px; }
  .nav-link svg { opacity: 0.8; }
  .topbar { padding: 0 14px; }
  .topbar-left { min-width: 0; }
  .topbar-left h1 { font-size: 1rem !important; }
  .topbar-left p {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page-content { padding: 20px; }
  .insights-hero { align-items: flex-start; flex-direction: column; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid-3 { grid-template-columns: 1fr; }
  .chart-grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { gap: 8px; }
  .topbar-left p { display: none; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn-refresh { padding: 7px 10px !important; }
  .insight-story,
  .insight-chart-panel,
  .insight-list-panel,
  .insights-hero,
  .preset-card {
    max-width: 100%;
  }
  .insight-story,
  .insight-chart-panel {
    padding: 16px;
  }
  .insight-list-panel {
    padding: 16px 16px 6px;
  }
  .insight-chart-wrap {
    height: 300px;
  }
  .preset-grid { grid-template-columns: 1fr; }
  .insight-metrics { grid-template-columns: 1fr; }
  .insight-row { align-items: flex-start; flex-direction: column; gap: 6px; }
  .insight-modal { padding: 14px; align-items: flex-end; }
  .insight-modal-panel { max-height: 86vh; }
  .insight-modal-head { padding: 18px; }
  .insight-modal-list { padding: 4px 18px 18px; }
  .insight-modal-client { align-items: flex-start; flex-direction: column; gap: 6px; }
  .insights-hero h2 { font-size: 1.35rem; }
}

/* ── Assist AI Chatbot ───────────────────────────────────────── */

.assist-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font);
}

.assist-toggle {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  gap: 8px;
  padding: 0 18px;
}

.assist-toggle span {
  display: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.assist-toggle:hover {
  width: 120px;
  background: var(--primary);
}

.assist-toggle:hover span {
  display: block;
}

.assist-toggle.active {
  background: var(--primary);
  transform: rotate(90deg);
}

.assist-window {
  width: 360px;
  height: 500px;
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: assistSlideUp 0.3s ease;
}

/* hidden attribute must override display:flex */
.assist-window[hidden] { display: none !important; }

@keyframes assistSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.assist-header {
  padding: 16px 20px;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.assist-header-info strong { display: block; font-size: 0.95rem; }
.assist-header-info span { font-size: 0.75rem; color: rgba(255,255,255,0.6); }

.assist-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  color: rgba(255,255,255,0.7);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.assist-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.assist-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #F8FAFC;
}

.assist-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.assist-msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-3);
  font-style: italic;
  font-size: 0.8rem;
  text-align: center;
  max-width: 100%;
}

.assist-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.assist-msg.assistant {
  align-self: flex-start;
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
  box-shadow: var(--shadow);
}

.assist-msg.assistant li {
  margin-left: 18px;
  margin-top: 4px;
}

.assist-msg.loading {
  opacity: 0.6;
}

.assist-input-area {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.assist-input-area textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: var(--font);
}

.assist-input-area textarea:focus { border-color: var(--primary); }

.assist-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.assist-send:hover { background: var(--primary); color: #fff; }

@media (max-width: 480px) {
  .assist-window {
    width: calc(100vw - 40px);
    right: 20px;
    bottom: 80px;
  }
}


/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — KPI Strip
══════════════════════════════════════════════════════════════ */

.ins-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.ins-kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 18px 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ins-kpi-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0 0 var(--r) var(--r);
  opacity: 0.7;
  transition: opacity 0.2s;
}

.ins-kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.ins-kpi-card:hover::after { opacity: 1; }

.ins-kpi-green::after  { background: linear-gradient(90deg, #3C6444, #7A9E82); }
.ins-kpi-gold::after   { background: linear-gradient(90deg, #BF9966, #C4A04A); }
.ins-kpi-blue::after   { background: linear-gradient(90deg, #6090A8, #5272A0); }
.ins-kpi-purple::after { background: linear-gradient(90deg, #9E6B9E, #7253A0); }
.ins-kpi-teal::after   { background: linear-gradient(90deg, #4A9E9E, #168B8B); }

.ins-kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ins-kpi-green  .ins-kpi-icon { background: #EBF4ED; color: #3C6444; }
.ins-kpi-gold   .ins-kpi-icon { background: #FBF5EE; color: #BF9966; }
.ins-kpi-blue   .ins-kpi-icon { background: #EEF3FB; color: #6090A8; }
.ins-kpi-purple .ins-kpi-icon { background: #F3EEFB; color: #9E6B9E; }
.ins-kpi-teal   .ins-kpi-icon { background: #E5F6F6; color: #4A9E9E; }

.ins-kpi-body { flex: 1; min-width: 0; }

.ins-kpi-body span {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 4px;
}

.ins-kpi-body strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ins-kpi-body small {
  display: block;
  font-size: 0.73rem;
  color: var(--text-3);
}

/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — Tab Navigation
══════════════════════════════════════════════════════════════ */

.ins-tabs-wrap {
  margin-bottom: 22px;
}

.ins-tabs {
  display: flex;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  width: fit-content;
  box-shadow: var(--shadow);
}

.ins-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}

.ins-tab svg { opacity: 0.6; transition: opacity 0.18s; flex-shrink: 0; }

.ins-tab:hover {
  background: var(--bg);
  color: var(--text);
}
.ins-tab:hover svg { opacity: 0.9; }

.ins-tab.active {
  background: var(--sidebar);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(30,40,50,0.18);
}
.ins-tab.active svg { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — Tab Panels
══════════════════════════════════════════════════════════════ */

.ins-panel {
  display: none;
  animation: panelFadeIn 0.3s ease;
}

.ins-panel.active { display: block; }

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — Callout Box
══════════════════════════════════════════════════════════════ */

.ins-callout {
  background: linear-gradient(135deg, #F0F6FF 0%, #F9FBFD 50%, #FFFBF0 100%);
  border: 1px solid #DCE9FB;
  border-left: 4px solid #3C6444;
  border-radius: var(--r-sm);
  padding: 14px 18px;
  margin-bottom: 22px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.65;
  animation: panelFadeIn 0.4s ease 0.1s both;
}

.ins-callout:empty { display: none; }

.ins-callout strong { color: #3C6444; }

/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — Project List
══════════════════════════════════════════════════════════════ */

.ins-proj-list {
  padding: 4px 0 8px;
}

.ins-proj-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 4px;
  border-bottom: 1px solid #F0EDE8;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease, background 0.15s;
}

.ins-proj-row:last-child { border-bottom: none; }

.ins-proj-row.visible {
  opacity: 1;
  transform: translateX(0);
}

.ins-proj-row:hover { background: #FAFAF9; border-radius: 6px; }

.ins-proj-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-3);
  flex-shrink: 0;
}

.ins-proj-row:nth-child(1) .ins-proj-rank { background: #FBF5EE; border-color: #BF9966; color: #8C6030; }
.ins-proj-row:nth-child(2) .ins-proj-rank { background: #EBF4ED; border-color: #7A9E82; color: #3C6444; }
.ins-proj-row:nth-child(3) .ins-proj-rank { background: #EEF3FB; border-color: #6090A8; color: #3052A0; }

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

.ins-proj-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ins-proj-info span {
  font-size: 0.78rem;
  color: var(--text-3);
}

.ins-proj-row em {
  font-style: normal;
  font-weight: 700;
  font-size: 0.88rem;
  color: #6B3E00;
  background: #FBF5EE;
  border: 1px solid #E8D8C0;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   CEO INSIGHTS — Premium List
══════════════════════════════════════════════════════════════ */

.ins-prem-list {
  padding: 4px 0 8px;
  max-height: 460px;
  overflow-y: auto;
}

.ins-prem-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid #F0EDE8;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.15s;
}

.ins-prem-row:last-child { border-bottom: none; }

.ins-prem-row.visible {
  opacity: 1;
  transform: translateY(0);
}

.ins-prem-row:hover { background: #FAFAF9; border-radius: 6px; }

.ins-prem-rank {
  width: 26px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  flex-shrink: 0;
}

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

.ins-prem-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.ins-prem-info span {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ins-prem-row em {
  font-style: normal;
  font-weight: 700;
  font-size: 0.9rem;
  color: #2F6637;
  background: #EBF4ED;
  border: 1px solid #C2DEC6;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.ins-empty {
  padding: 32px 20px;
  color: var(--text-3);
  font-size: 0.875rem;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════
   Responsive overrides for KPI & Tabs
══════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .ins-kpi-strip { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .ins-kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .ins-tabs { flex-wrap: wrap; width: 100%; }
  .ins-tab { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
  .ins-kpi-strip { grid-template-columns: 1fr 1fr; }
  .ins-kpi-body strong { font-size: 1.15rem; }
  .ins-tabs { gap: 4px; padding: 4px; }
  .ins-tab { padding: 8px 10px; font-size: 0.8rem; }
  .ins-tab svg { display: none; }
}
