:root {
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  /* Cloud Kite brand */
  --brand-navy:      #0F172A;
  --brand-navy-2:    #1E293B;
  --brand-sky:       #0284C7;
  --brand-sky-light: #38BDF8;
  --brand-charcoal:  #475569;
  --brand-slate:     #F1F5F9;

  --series-blue:    var(--brand-sky);
  --series-aqua:    #1baf7a;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);

    --series-blue:    var(--brand-sky-light);
    --series-aqua:    #199e70;

    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #d03b3b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

/* ---------- Login ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--brand-navy);
  padding: 16px;
}
.login-box { width: 100%; max-width: 360px; }
.login-brand {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  color: #fff; font-weight: 600; font-size: 18px; margin-bottom: 24px;
}
.brand-chip { width: 8px; height: 22px; background: var(--brand-sky); display: inline-block; border-radius: 1px; }
.login-box form {
  background: var(--brand-navy-2);
  border-radius: 12px;
  padding: 26px;
}
.login-box h1 { color: #fff; font-size: 16px; margin: 0 0 2px; }
.login-box .muted { color: #94A3B8; margin-bottom: 20px; }
.login-box label {
  display: block; font-size: 12px; color: #94A3B8; margin-bottom: 6px; margin-top: 14px;
}
.login-box input {
  width: 100%; padding: 9px 10px; border-radius: 8px;
  background: var(--brand-navy); border: 1px solid #334155; color: #fff; font-size: 14px;
}
.login-box .btn.full { width: 100%; margin-top: 18px; }

/* ---------- App shell / sidebar ---------- */
.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--brand-navy);
  color: var(--brand-slate);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 20px 16px; font-weight: 600; font-size: 16px; color: #fff;
}
.nav-group { padding: 6px 12px; margin-bottom: 4px; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: #64748B; padding: 8px 10px 4px; margin: 0;
}
.nav-link {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none; cursor: pointer;
  color: #94A3B8; font-size: 14px; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px;
}
.nav-link:hover { background: var(--brand-navy-2); color: var(--brand-slate); }
.nav-link.active { background: var(--brand-navy-2); color: #fff; font-weight: 500; }
.sidebar-footer { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--brand-navy-2); }
.sidebar-footer .btn { color: #94A3B8; border-color: #334155; }
.sidebar-footer .btn:hover { color: #fff; }

.content { flex: 1; padding: 28px; max-width: 1100px; width: 100%; }

.panel { display: none; }
.panel.active { display: block; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.panel-head h1 { font-size: 20px; margin: 0; }
.section-h { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface-1);
  color: var(--text-primary);
}
.btn.primary { background: var(--brand-sky); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: default; }

select, input[type=text], input[type=email], input[type=password], input[type=file], textarea {
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
}
textarea { width: 100%; resize: vertical; margin-bottom: 12px; }

.block-label {
  display: block; font-size: 12px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; margin-top: 4px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h3 { margin-top: 0; }
.muted { color: var(--text-secondary); font-size: 13px; }
code {
  background: var(--gridline);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

.navy-card { background: var(--brand-navy); border: none; }
.navy-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #64748B; margin: 0 0 10px; }
.rotation-jobs { display: flex; gap: 8px; flex-wrap: wrap; }
.rotation-job-chip {
  background: var(--brand-navy-2); color: var(--brand-slate);
  font-size: 13px; padding: 7px 12px; border-radius: 8px;
}
.rotation-empty { color: #94A3B8; font-size: 13px; }

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Meter */
.meter-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.meter-label { color: var(--text-secondary); }
.meter-value { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: 4px; background: var(--gridline); overflow: hidden; }
.meter-fill { height: 100%; background: var(--brand-sky); border-radius: 4px; transition: width 0.3s ease; }

/* Pipeline rail (Social Pilot) */
.pipeline-rail { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--gridline); margin-bottom: 18px; }
.pipeline-rail-seg { height: 100%; }
.pipeline-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.pipeline-stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.pipeline-stat-dot { width: 7px; height: 7px; border-radius: 50%; }
.pipeline-stat-value { font-size: 22px; font-weight: 600; }

/* Table */
.table-card { padding: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.empty { color: var(--text-muted); text-align: center; padding: 24px !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--gridline);
  color: var(--text-primary);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }

.result-box {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* Review (Outreach) */
.review-list { display: flex; flex-direction: column; gap: 12px; }
.review-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.review-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.review-card-head strong { font-size: 14px; }
.review-card textarea, .review-card input[type=text] {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.review-card textarea { min-height: 100px; }
.review-actions { display: flex; gap: 8px; }

/* Post list / post card (Social Pilot) */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-card {
  display: flex; gap: 14px; padding: 14px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
}
.post-card:hover { border-color: var(--brand-sky); }
.post-thumb {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
  background: var(--gridline); display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-muted); font-family: monospace;
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card-body { flex: 1; min-width: 0; }
.post-card-meta { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); margin-bottom: 4px; }
.post-card-caption {
  font-size: 13px; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-foot { display: flex; align-items: center; gap: 10px; }
.post-card-date { font-size: 12px; color: var(--text-muted); }

.filter-pills { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  font-size: 13px; padding: 7px 13px; border-radius: 999px; cursor: pointer;
}
.pill.active { background: var(--brand-navy); color: #fff; border-color: transparent; }

.hashtags { color: var(--brand-sky); font-size: 13px; margin: 0 0 14px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface-1);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal.modal-wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-grid label { grid-column: span 2; font-size: 12px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
.form-grid label input, .form-grid label select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-msg { margin-top: 10px; margin-bottom: 10px; font-size: 13px; }

.post-media { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.post-media img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }

/* Connections */
.connection-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 12px;
}
.connection-name { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 4px; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--baseline); }
.connection-dot.connected { background: var(--status-good); }

/* Brand DNA */
.brand-field { margin-bottom: 14px; }
.brand-field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); margin: 0 0 4px; }
.brand-field ul { margin: 0; padding-left: 18px; font-size: 13px; }
