/* CompanyTrack Portal v4.7 — Kredibble Brand */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --navy:      #1B2A6B;   /* Kredibble primary */
  --navy2:     #14205A;
  --navy3:     #243380;
  --gold:      #f59e0b;
  --gold2:     #fbbf24;
  --white:     #ffffff;
  --bg:        #f4f6fb;
  --bg2:       #eef1f8;
  --border:    #dde3f0;
  --text:      #1B2A6B;
  --muted:     #6b7fa8;
  --green:     #059669;
  --green-bg:  #d1fae5;
  --blue:      #2563eb;
  --blue-bg:   #dbeafe;
  --amber:     #d97706;
  --amber-bg:  #fef3c7;
  --red:       #dc2626;
  --red-bg:    #fee2e2;
  --sidebar-w: 240px;
  --topbar-h:  62px;
  --r:         12px;
  --r-sm:      8px;
  --shadow-sm: 0 1px 3px rgba(27,42,107,.08), 0 1px 2px rgba(27,42,107,.04);
  --shadow:    0 4px 12px rgba(27,42,107,.1), 0 2px 4px rgba(27,42,107,.05);
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --trans:     all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --white:     #fff;
  --navy-rgb:  27,42,107;
}

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

/* =======================================================
   LOGIN PAGE
======================================================= */
/* ================================================================
   PROFILE FORM LAYOUT
================================================================ */
.ctp-prof-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ctp-prof-field { display: flex; flex-direction: column; }
.ctp-prof-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); margin-bottom: 5px;
  display: flex; align-items: center; gap: 4px;
}

/* Admin page embedded in portal */
.ctp-admin-embed { padding: 0; }
.ctp-admin-embed .ct-app { background: transparent; }
.ctp-admin-embed .ct-topbar { display: none; }
.ctp-admin-embed .ct-page { padding: 16px 0; }

.ctp-login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1B2A6B 0%, #243380 50%, #14205A 100%);
  font-family: var(--font);
}
.ctp-login-card {
  background: var(--white); border-radius: 20px; padding: 44px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 25px 60px rgba(27,42,107,.4);
  animation: loginIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.ctp-login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px; font-size: 20px; font-weight: 800; color: var(--navy);
}
.ctp-login-card h1 {
  font-size: 26px; font-weight: 800; color: var(--navy); margin-bottom: 6px; line-height: 1.2;
}
.ctp-login-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; }

/* =======================================================
   APP SHELL
======================================================= */
.ctp-app {
  display: flex; min-height: 100vh;
  font-family: var(--font); color: var(--text); background: var(--bg);
}

/* =======================================================
   SIDEBAR
======================================================= */
.ctp-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--navy);
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; height: 100vh; z-index: 200;
  transition: transform 240ms cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.06);
}
.ctp-sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px; font-size: 16px; font-weight: 800; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.ctp-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ctp-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; text-decoration: none; color: rgba(255,255,255,.65);
  font-size: 13px; font-weight: 500; transition: var(--trans); position: relative;
}
.ctp-nav-item svg { flex-shrink: 0; }
.ctp-nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.ctp-nav-item.active { color: var(--gold); background: rgba(245,158,11,.12); font-weight: 600; }
.ctp-nav-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.ctp-nav-dot--done { background: var(--green); }
.ctp-nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; flex-shrink: 0;
}
.ctp-sidebar-user {
  display: flex; align-items: center; gap: 9px; padding: 14px 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.ctp-user-info { flex: 1; min-width: 0; overflow: hidden; }
.ctp-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctp-user-role { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctp-logout-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; flex-shrink: 0;
  color: rgba(255,255,255,.5); transition: var(--trans); text-decoration: none;
}
.ctp-logout-btn:hover { background: rgba(220,38,38,.25); color: #f87171; }

/* =======================================================
   MAIN AREA
======================================================= */
.ctp-main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
}
.ctp-topbar {
  height: var(--topbar-h); background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 100;
}
.ctp-menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 6px; border-radius: 6px;
}
.ctp-menu-toggle:hover { background: var(--bg); color: var(--text); }
.ctp-page-title { font-size: 15px; font-weight: 700; flex: 1; }
.ctp-topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ctp-score-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.ctp-content { flex: 1; padding: 22px; overflow-y: auto; }

/* =======================================================
   AVATAR
======================================================= */
.ctp-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.ctp-avatar--sm { width: 28px; height: 28px; font-size: 11px; }

/* =======================================================
   ALERTS — HIGH CONTRAST, !important overrides
======================================================= */
.ctp-alert {
  display: flex !important; align-items: flex-start !important; gap: 10px !important;
  padding: 12px 16px !important; border-radius: var(--r-sm) !important;
  font-size: 13px !important; border: 2px solid !important; font-family: var(--font) !important;
  line-height: 1.5;
}
.ctp-alert--success { background: #d1fae5 !important; color: #064e3b !important; border-color: #6ee7b7 !important; }
.ctp-alert--error   { background: #fee2e2 !important; color: #7f1d1d !important; border-color: #f87171 !important; font-weight: 600 !important; }
.ctp-alert--warning { background: #fef3c7 !important; color: #78350f !important; border-color: #fcd34d !important; }
.ctp-alert--info    { background: #dbeafe !important; color: #1e3a8a !important; border-color: #93c5fd !important; }

/* =======================================================
   DASHBOARD
======================================================= */
.ctp-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; margin-bottom: 18px;
}
.ctp-banner--warn { background: #fef3c7; color: #78350f; border: 2px solid #fcd34d; }
.ctp-banner a { color: inherit; font-weight: 700; }
.ctp-dash-hero {
  display: flex; align-items: flex-start; gap: 28px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.ctp-score-ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.ctp-score-ring { display: block; }
.ctp-score-label { font-size: 13px; font-weight: 700; }
.ctp-score-month { font-size: 11px; color: var(--muted); }
.ctp-dash-stats { flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ctp-stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; }
.ctp-stat-icon {
  width: 34px; height: 34px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; margin-bottom: 8px; flex-shrink: 0;
  color: var(--navy);
}
.ctp-stat-num { font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.ctp-stat-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 500; }

/* =======================================================
   SECTIONS
======================================================= */
.ctp-section { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 18px; }
.ctp-section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.ctp-section-head h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex: 1; }

/* =======================================================
   TABLES
======================================================= */
.ctp-table-wrap { overflow-x: auto; }
.ctp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctp-table thead th {
  padding: 9px 16px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  border-bottom: 2px solid var(--border); background: #f8fafc; white-space: nowrap;
}
.ctp-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ctp-table tbody tr:last-child td { border-bottom: none; }
.ctp-table tfoot td { background: var(--navy); color: #fff; padding: 12px 16px; font-weight: 700; }
.ctp-table tbody tr:hover { background: var(--bg); }
.ctp-task-title { font-weight: 600; font-size: 13px; }
.ctp-task-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ctp-empty-row { text-align: center; padding: 36px; color: var(--muted); }
.overdue-row { background: #fff8f8 !important; }
.ctp-overdue { color: var(--red); font-weight: 600; }
.ctp-muted { color: var(--muted); font-size: 12px; }

/* =======================================================
   CHIPS / BADGES
======================================================= */
.ctp-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.ctp-chip--success { background: var(--green-bg); color: #065f46; }
.ctp-chip--info    { background: var(--blue-bg);  color: #1e3a8a; }
.ctp-chip--warning { background: var(--amber-bg); color: #78350f; }
.ctp-chip--danger  { background: var(--red-bg);   color: #7f1d1d; }
.ctp-chip--neutral { background: #f1f5f9;          color: var(--muted); }

/* =======================================================
   REPORT FORMS
======================================================= */
.ctp-form-block { border-bottom: 1px solid var(--border); }
.ctp-form-block:last-child { border-bottom: none; }
.ctp-form-block-title {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px 10px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--border); background: #fafbfc;
}
.ctp-hint-inline { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.ctp-field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 16px 18px; }
.ctp-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ctp-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.ctp-field .ctp-input, .ctp-field .ctp-select { width: 100%; box-sizing: border-box; }
.ctp-hint { font-size: 10px; color: var(--muted); margin-top: 1px; }
.ctp-input, .ctp-select {
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 11px; font-family: var(--font); font-size: 13px;
  color: var(--text); background: var(--white); width: 100%;
  transition: border-color 110ms;
}
.ctp-input:focus, .ctp-select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}

/* Daily target progress bar */
.ctp-daily-target { padding: 0 18px 16px; }
.ctp-target-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 6px; }
.ctp-target-bar-wrap { height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 5px; }
.ctp-target-bar { height: 100%; border-radius: 99px; transition: width 500ms cubic-bezier(.4,0,.2,1); }
.ctp-target-pct { font-size: 18px; font-weight: 800; line-height: 1; }

/* Form actions */
.ctp-form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--border); background: #fafbfc;
}

/* =======================================================
   KPI TAB
======================================================= */
.ctp-kpi-header {
  display: flex; align-items: center; gap: 24px;
  padding: 20px; border-bottom: 1px solid var(--border);
}
.ctp-kpi-score-big { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.ctp-kpi-rating  { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.ctp-kpi-month   { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ctp-kpi-meta { flex: 1; }
.ctp-kpi-bar-wrap { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; max-width: 280px; }
.ctp-kpi-bar { height: 100%; border-radius: 99px; transition: width 700ms cubic-bezier(.4,0,.2,1); }

/* =======================================================
   HISTORY TAB
======================================================= */
.ctp-history-day {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.ctp-history-day:last-child { border-bottom: none; }
.ctp-history-date { font-size: 13px; font-weight: 600; min-width: 140px; }
.ctp-history-status { flex-shrink: 0; }

/* =======================================================
   BUTTONS
======================================================= */
.ctp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1.5px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 9px 18px; cursor: pointer; text-decoration: none; transition: var(--trans);
  white-space: nowrap; line-height: 1.3;
}
.ctp-btn:disabled { opacity: .5; cursor: not-allowed; }
.ctp-btn--primary  { background: var(--navy); color: #fff; border-color: var(--navy); }
.ctp-btn--primary:hover { background: var(--navy2); }
.ctp-btn--outline  { background: transparent; color: var(--text); border-color: var(--border); }
.ctp-btn--outline:hover { background: var(--bg); }
.ctp-btn--full     { width: 100%; }
.ctp-btn--sm       { padding: 5px 12px; font-size: 12px; }

/* =======================================================
   FORM (login)
======================================================= */
.ctp-form { display: flex; flex-direction: column; gap: 16px; }
.ctp-field label { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 4px; display: block; }

/* =======================================================
   TOASTS
======================================================= */
#ctp-toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 9999;
  display: flex; flex-direction: column; gap: 7px; pointer-events: none;
}
.ctp-toast {
  background: #1e293b !important; color: #fff !important;
  padding: 12px 16px; border-radius: 10px; font-family: var(--font);
  font-size: 13px; font-weight: 500; border-left: 4px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0,0,0,.25); pointer-events: all; max-width: 340px;
  animation: ctpIn 220ms;
}
.ctp-toast.success { border-left-color: var(--green); }
.ctp-toast.error   { border-left-color: var(--red); }
.ctp-toast.out { animation: ctpOut 220ms forwards; }
@keyframes ctpIn  { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes ctpOut { to   { opacity: 0; transform: translateX(14px); } }

/* =======================================================
   RESPONSIVE
======================================================= */
@media (max-width: 768px) {
  .ctp-sidebar { transform: translateX(-100%); }
  .ctp-sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .ctp-main { margin-left: 0; }
  .ctp-menu-toggle { display: flex; }
  .ctp-dash-hero { flex-direction: column; }
  .ctp-dash-stats { grid-template-columns: repeat(2, 1fr); }
  .ctp-field-grid { grid-template-columns: 1fr; padding: 12px 14px; }
  .ctp-content { padding: 14px; }
  .ctp-topbar { padding: 0 14px; }
  .ctp-score-pill strong { display: none; }
  .ctp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ctp-kpi-header { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .ctp-kpi-score-big { font-size: 40px; }
  .ctp-kpi-bar-wrap { max-width: 100%; }
  /* KPI table on mobile — force scroll */
  .ctp-table-wrap table { min-width: 500px; }
  /* Form grids collapse */
  div[style*="grid-template-columns:1fr 1fr"] { display: block !important; }
  div[style*="grid-template-columns: 1fr 1fr"] { display: block !important; }
  div[style*="grid-template-columns:repeat(3"] { display: block !important; }
  div[style*="grid-template-columns:repeat(2"] { display: block !important; }
  .ctp-form-block-title { flex-wrap: wrap; }
  /* Client reports tab cards */
  div[style*="justify-content:space-between;align-items:center"] { flex-direction: column !important; gap: 10px !important; }
  /* Month pills wrap */
  div[style*="display:flex;gap:8px;flex-wrap:wrap"] > a { font-size: 11px; padding: 5px 10px; }
  /* Baseline grid on report form */
  div[style*="grid-template-columns:repeat(3,1fr);gap:6px"] { display: grid !important; grid-template-columns: 1fr 1fr !important; }
  /* Section headers */
  .ctp-section { padding: 0; }
}
@media (max-width: 480px) {
  .ctp-prof-row { grid-template-columns: 1fr; }
  .ctp-login-card { padding: 28px 18px; }
  .ctp-dash-stats { grid-template-columns: 1fr 1fr; }
  .ctp-kpi-score-big { font-size: 34px; }
  .ctp-content { padding: 10px; }
  .ctp-section-head { padding: 12px 14px; }
  .ctp-form-actions { flex-direction: column; }
  .ctp-form-actions .ctp-btn { width: 100%; justify-content: center; }
  input[type="number"].ctp-input { height: 50px !important; font-size: 17px !important; }
  .ctp-history-date { min-width: unset; font-size: 12px; }
  #ctp-toasts { right: 10px; left: 10px; bottom: 10px; }
  .ctp-toast { max-width: 100%; }
  /* Draft/Submit buttons full width */
  #ctp-draft-btn, #ctp-submit-btn { width: 100%; justify-content: center; }
  /* KPI metric cards 2-col */
  div[style*="display:grid;grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr 1fr !important; }
  /* Profile form */
  div[style*="grid-template-columns:1fr 1fr;gap:"] { display: block !important; }
  div[style*="grid-template-columns:1fr 1fr;gap:"] > div { margin-bottom: 12px; }
}

/* Admin page iframe embed */
.ctp-content:has(iframe) { padding: 0 !important; }

/* ================================================================
   ADMIN VIEW EMBEDDED IN PORTAL
================================================================ */
.ct-admin-portal-embed { width: 100%; }
.ct-admin-portal-embed .ct-app { background: transparent; min-height: auto; }
.ct-admin-portal-embed .ct-page { padding: 0 4px; }
/* Ensure admin modals appear on top of portal */
.ct-admin-portal-embed ~ .ct-modal-overlay,
.ct-modal-overlay { z-index: 99999; }

/* ================================================================
   EMBEDDED ADMIN VIEWS — layout fixes
================================================================ */
.ct-admin-portal-embed { width: 100%; min-height: 400px; }
.ct-admin-portal-embed .ct-app { min-height: auto; background: transparent; }
/* Prevent admin sticky headers from overlapping in portal scroll context */
.ct-admin-portal-embed .ct-topbar { display: none !important; }
/* Ensure admin modal overlays cover the full viewport */
.ct-modal-overlay { position: fixed !important; }

/* ================================================================
   PORTAL TOPBAR — ensure proper title display and no overflow
================================================================ */
.ctp-page-title { font-size: 16px; font-weight: 800; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
