/* =========================================================
   DigiRox CRM - Modern Design System (Theme: "Ledger Pro")
   Optimized Typography, Contrast, Depth, and Responsiveness
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600;700&display=swap');

:root {
  --navy-900: #0A0F1D;
  --navy-800: #10172A;
  --navy-700: #1E293B;
  --navy-600: #334155;
  --gold-500: #C9A34E;
  --gold-600: #B5892F;
  --paper: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-focus: #C9A34E;
  --ink-900: #0F172A;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-400: #94A3B8;
  --green-600: #059669;
  --green-500: #10B981;
  --green-50: #ECFDF5;
  --red-600: #DC2626;
  --red-500: #EF4444;
  --red-50: #FEF2F2;
  --amber-600: #D97706;
  --amber-500: #F59E0B;
  --amber-50: #FFFBEB;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-50: #EFF6FF;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink-900);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin: 0;
}

.mono, .amount, td.num, th.num {
  font-family: 'IBM Plex Mono', monospace;
  font-feature-settings: "tnum";
}

a { color: inherit; text-decoration: none; }

/* ---------- Clickable links in content ---------- */
.content a:not(.btn):not(.nav-link):not(.side-link):not(.act-btn):not(.launchpad-btn):not(.kpi-link) {
    color: var(--navy-900);
    font-weight: 600;
    transition: color .15s ease;
}
.content a:not(.btn):not(.nav-link):not(.side-link):not(.act-btn):not(.launchpad-btn):not(.kpi-link):hover {
    color: var(--gold-600);
    text-decoration: underline;
}

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

.main {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content { 
  padding: 24px 28px 60px;
  flex: 1;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.topbar h1 { font-size: 18px; font-weight: 700; }

.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-600);
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  transition: all .15s ease;
}

.topbar .user-chip:hover {
  background: #FFFFFF;
  border-color: #CBD5E1;
}

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy-900);
  color: var(--gold-500);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  box-shadow: 0 1px 3px rgba(10, 15, 29, 0.2);
}

/* ---------- Cards & Panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: box-shadow 0.15s ease;
}

.card + .card { margin-top: 16px; }

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

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title-row h3 { 
  display: flex; 
  align-items: center; 
  gap: 8px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink-900);
}

.count-pill {
  background: var(--paper);
  color: var(--ink-600);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ---------- Stat Cards Across All Modules ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-500);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

.stat-card .stat-icon {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 10px;
  background: rgba(201,163,78,0.14);
  color: var(--gold-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.stat-card .label { 
  font-size: 11.5px; 
  color: var(--ink-600); 
  text-transform: uppercase; 
  letter-spacing: .05em; 
  font-weight: 700;
}
.stat-card .value { 
  font-family: 'IBM Plex Mono', monospace; 
  font-size: 24px; 
  font-weight: 700; 
  margin-top: 4px; 
  color: var(--ink-900);
  line-height: 1.2;
}

.stat-card.income { border-left-color: var(--green-600); }
.stat-card.income .stat-icon { background: var(--green-50); color: var(--green-600); }

.stat-card.expense { border-left-color: var(--red-600); }
.stat-card.expense .stat-icon { background: var(--red-50); color: var(--red-600); }

/* ---------- Tables System-Wide ---------- */
.table-wrap { 
  overflow-x: auto; 
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

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

thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-600);
  padding: 12px 16px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
  font-size: 13.5px;
  color: var(--ink-900);
}

tbody tr { 
  transition: background .12s ease; 
  background: #FFFFFF;
}

tbody tr:hover { 
  background: #F8FAFC; 
}

tbody tr:last-child td {
  border-bottom: none;
}

td.num, th.num { text-align: right; }

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

/* ---------- Badges Upgrade ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  text-transform: capitalize;
}

.badge-won, .badge-paid, .badge-active, .badge-completed, .badge-accepted {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.badge-lost, .badge-overdue, .badge-cancelled, .badge-rejected, .badge-inactive {
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
}

.badge-qualified, .badge-partially_paid {
  background: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.badge-contacted, .badge-sent {
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid #BFDBFE;
}

.badge-new, .badge-draft {
  background: #F1F5F9;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.badge-hot {
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FECACA;
  font-weight: 700;
}

.badge-warm {
  background: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
  font-weight: 700;
}

.badge-cold {
  background: #F0F9FF;
  color: #0284C7;
  border: 1px solid #BAE6FD;
}

/* ---------- Modern Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
  text-decoration: none;
  line-height: 1.3;
}

.btn-primary { 
  background: var(--navy-900); 
  color: #FFFFFF; 
  border-color: var(--navy-900);
  box-shadow: 0 1px 3px rgba(10,15,29,0.15);
}
.btn-primary:hover { 
  background: var(--navy-700); 
  border-color: var(--navy-700); 
  color: #FFFFFF;
  transform: translateY(-1px); 
  box-shadow: 0 3px 8px rgba(10,15,29,0.25); 
}

.btn-gold { 
  background: var(--gold-500); 
  color: #0A0F1D; 
  border-color: var(--gold-500);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(201,163,78,0.25);
}
.btn-gold:hover { 
  background: #dbb55e; 
  border-color: #dbb55e;
  transform: translateY(-1px); 
  box-shadow: 0 4px 12px rgba(201,163,78,0.35); 
}

.btn-outline {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #1E293B;
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
  color: #0F172A;
  transform: translateY(-1px);
}

.btn-danger { 
  background: #FEF2F2; 
  border-color: #FECACA; 
  color: #DC2626; 
}
.btn-danger:hover { 
  background: #DC2626; 
  border-color: #DC2626; 
  color: #FFFFFF; 
  transform: translateY(-1px);
}

.btn-blue { 
  background: #2563EB; 
  color: #FFFFFF; 
  border-color: #2563EB; 
}
.btn-blue:hover { 
  background: #1D4ED8; 
  border-color: #1D4ED8; 
  color: #FFFFFF;
  transform: translateY(-1px);
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-icon { padding: 6px 8px; border-radius: var(--radius-xs); }

/* ---------- Form Controls Modernization ---------- */
label { 
  display: block; 
  font-size: 12.5px; 
  font-weight: 600; 
  color: var(--ink-700); 
  margin-bottom: 6px; 
}
.optional { color: var(--ink-400); font-weight: 400; }
.form-group { margin-bottom: 16px; }

input[type="text"], 
input[type="email"], 
input[type="password"], 
input[type="number"], 
input[type="date"], 
input[type="datetime-local"], 
select, 
textarea,
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #CBD5E1;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: #FFFFFF;
  color: var(--ink-900);
  transition: all .15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus, .form-control:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201,163,78,0.2);
}

.filter-bar { 
  display: flex; 
  gap: 12px; 
  flex-wrap: wrap; 
  align-items: flex-end; 
  margin-bottom: 20px; 
  background: #FFFFFF;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Alerts & Toast Banners ---------- */
.alert {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-xs);
}

.alert-success { 
  background: #ECFDF5; 
  border: 1px solid #A7F3D0; 
  color: #065F46; 
}
.alert-success::before {
  content: "✓";
  font-weight: 800;
  font-size: 14px;
}

.alert-error { 
  background: #FEF2F2; 
  border: 1px solid #FECACA; 
  color: #991B1B; 
}
.alert-error::before {
  content: "⚠";
  font-weight: 800;
  font-size: 14px;
}

/* ===== MODERN DARK NAVY SIDEBAR ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #0A0F1D !important;
  color: #FFFFFF !important;
  border-right: 1px solid #1A233A !important;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}

.sidebar-logo {
  padding: 20px 20px 14px;
}

.sidebar-logo img {
  max-width: 140px;
  max-height: 34px;
  display: block;
}

.sidebar-search { padding: 0 16px 12px; }
.sidebar-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #141C31 !important;
  border: 1px solid #1C263F !important;
  border-radius: 9px;
  padding: 8px 12px;
}
.sidebar-search-box svg { flex-shrink: 0; color: rgba(255,255,255,0.45) !important; }
.sidebar-search-box input {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  width: 100%;
  color: #FFFFFF !important;
  box-shadow: none !important;
}
.sidebar-search-box input::placeholder { color: rgba(255,255,255,0.45) !important; }
.sidebar-search-box input:focus { outline: none; border: none; }

.sidebar-nav { padding: 4px 10px; flex: 1; overflow-y: auto; }

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.4) !important;
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72) !important;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all .15s ease;
  position: relative;
}

.nav-link:hover { 
  background: #141D34 !important; 
  color: #FFFFFF !important; 
}

.nav-link.active {
  background: rgba(201, 163, 78, 0.15) !important;
  color: #C9A34E !important;
  font-weight: 600;
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: #C9A34E;
  border-radius: 0 4px 4px 0;
}

.nav-link .ico { width: 17px; text-align: center; opacity: 0.9; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid #1A233A !important;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.45) !important;
}

.sidebar-footer strong {
  color: #FFFFFF !important;
}

/* =========================================================
   REMAINDER MODULE STYLES (Cleaned & Harmonized)
   ========================================================= */

/* ---------- Dashboard hero ---------- */
.dash-hero {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
  border-radius: var(--radius);
  padding: 24px 28px;
  color: #fff;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-hero .greeting { font-family: 'Sora', sans-serif; font-size: 20px; font-weight: 600; }
.dash-hero .date { color: rgba(255,255,255,0.55); font-size: 13px; margin-top: 4px; }
.dash-hero .quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-hero .btn-gold { box-shadow: var(--shadow-sm); }

/* ---------- Dashboard two-column layout ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title-row h3 { display: flex; align-items: center; gap: 8px; }

.count-pill {
  background: var(--paper);
  color: var(--ink-600);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

/* ---------- Deltas & pipeline ---------- */
.delta {
  font-size: 11.5px;
  font-weight: 600;
  margin-top: 4px;
}

.delta-up { color: var(--green-600); }
.delta-down { color: var(--red-600); }

.pipeline-row { margin-bottom: 14px; }
.pipeline-row:last-child { margin-bottom: 0; }
.pipeline-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.pipeline-track {
  background: var(--paper);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.pipeline-fill { height: 100%; border-radius: 999px; }
.pipeline-new { background: var(--ink-400); }
.pipeline-contacted { background: #2A5CAD; }
.pipeline-qualified, .pipeline-negotiation { background: var(--gold-500); }
.pipeline-won { background: var(--green-600); }
.pipeline-lost { background: var(--red-600); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-600);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #F5F1E6; }
td.num, th.num { text-align: right; }

/* ---------- Line-item builder (quotations/invoices) ---------- */
#items-table input, .table-wrap input[type="text"], .table-wrap input[type="number"] {
    padding: 6px 8px;
    font-size: 13px;
    margin: 0;
}
.item-row td { padding: 6px 10px; }
.btn-icon { padding: 5px 9px; line-height: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter .15s ease, background .15s ease, box-shadow .15s ease, transform .1s ease;
}

.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { filter: brightness(1.2); box-shadow: 0 2px 8px rgba(14,21,38,0.25); }
.btn-primary:active { transform: translateY(1px); }
.btn-gold { background: var(--gold-500); color: #1A1400; }
.btn-gold:hover { background: var(--gold-600); box-shadow: 0 2px 10px rgba(201,163,78,0.35); }
.btn-gold:active { transform: translateY(1px); }
.btn-outline {
  background: #FFFFFF;
  border: 1px solid var(--navy-700);
  color: var(--navy-900);
}

.btn-outline:hover {
  background: var(--gold-500);
  border-color: var(--gold-500);
  color: #1A1400;
  box-shadow: 0 2px 8px rgba(201,163,78,0.25);
}
.btn-danger { background: #fff; border-color: var(--red-600); color: var(--red-600); }
.btn-danger:hover { background: var(--red-600); color: #fff; box-shadow: 0 2px 8px rgba(181,72,42,0.3); }
.btn-blue { background: #2A5CAD; color: #ffffff; border-color: #2A5CAD; opacity: 1; }
.btn-blue:hover { background: #1E4A8C; border-color: #1E4A8C; color: #ffffff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 7px 9px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-600); margin-bottom: 6px; }
.optional { color: var(--ink-400); font-weight: 400; }
.form-group { margin-bottom: 16px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink-900);
  transition: border-color .15s ease;
}

select { cursor: pointer; }
select:hover, input:hover, textarea:hover { border-color: #c8ccd6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201,163,78,0.15);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-new, .badge-draft { background: #EEF1F6; color: var(--ink-600); }
.badge-contacted, .badge-sent { background: #E7EEFB; color: #2A5CAD; }
.badge-qualified, .badge-partially_paid { background: #FBF1DC; color: var(--amber-600); }
.badge-negotiation { background: #F4E7D9; color: #A05A2C; }
.badge-won, .badge-paid, .badge-active, .badge-accepted, .badge-completed { background: #E4F1EC; color: var(--green-600); }
.badge-lost, .badge-overdue, .badge-cancelled, .badge-rejected, .badge-inactive { background: #FBE7E1; color: var(--red-600); }

/* ---------- Utility ---------- */
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.muted { color: var(--ink-600); }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-400); }
.empty-state .ico { font-size: 30px; margin-bottom: 10px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert-success { background: #E4F1EC; color: var(--green-600); }
.alert-error { background: #FBE7E1; color: var(--red-600); }

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(14,21,38,0.45);
  z-index: 100;
  align-items: center; justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}

/* ============================================================
   Mobile responsiveness
   ============================================================ */
.mobile-menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--ink-900); padding: 4px;
  align-items: center; justify-content: center;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(14,21,38,0.5);
  z-index: 19;
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 880px) {
  .mobile-menu-toggle { display: flex; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .user-chip-name { display: none; }
  .content { padding: 16px 14px 50px; }

  .stat-grid, .mini-stat-row, .info-grid-3, .info-grid-3[style] { grid-template-columns: 1fr !important; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  .dash-hero { flex-direction: column; align-items: flex-start; padding: 18px; }
  .dash-hero .quick-actions { width: 100%; }
  .dash-hero .quick-actions .btn { flex: 1; justify-content: center; }

  .client-header-card { flex-direction: column; align-items: flex-start; }
  .client-header-actions { width: 100%; }
  .client-header-actions .btn, .client-header-actions .btn-chip { flex: 1; justify-content: center; }

  .card, .panel { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-group { min-width: 0; width: 100%; }

  .notes-grid { grid-template-columns: 1fr; }

  /* Tables scroll horizontally rather than squeezing unreadably */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }

  .modal { padding: 20px; max-width: calc(100vw - 32px); }
}

@media (max-width: 480px) {
  .header-row, .hero-ctas { flex-direction: column; }
  .price-grid, .pricing-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Client dashboard (view.php) — avatar header, stat row, panels
   ============================================================ */

.back-link-arrow {
  display: inline-block;
  color: var(--ink-600);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
.back-link-arrow:hover { color: var(--gold-600); }

.client-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.client-header-left { display: flex; align-items: center; gap: 16px; }
.client-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--navy-900); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}
.client-name-row { display: flex; align-items: center; gap: 10px; }
.client-name-row h2 { font-size: 19px; }
.status-dot-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.status-dot-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-dot-badge.on { background: #E4F1EC; color: var(--green-600); }
.status-dot-badge.on::before { background: var(--green-600); }
.status-dot-badge.off { background: #EEF1F6; color: var(--ink-600); }
.status-dot-badge.off::before { background: var(--ink-400); }
.client-meta { font-size: 12.5px; color: var(--ink-600); margin: 3px 0 0; }

.client-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-chip {
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 700;
  background: #fff; border: 1px solid var(--border);
}
.chip-blue { color: var(--blue-600); border-color: rgba(42,92,173,0.3); }
.chip-blue:hover { background: var(--blue-600); color: #fff; }
.chip-green { color: var(--green-600); border-color: rgba(47,111,94,0.3); }
.chip-green:hover { background: var(--green-600); color: #fff; }
.chip-purple { color: #8B5CF6; border-color: rgba(139,92,246,0.3); }
.chip-purple:hover { background: #8B5CF6; color: #fff; }

.mini-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.mini-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; display: flex; align-items: flex-start; gap: 12px;
}
.mini-stat-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.icon-blue { background: rgba(42,92,173,0.12); color: var(--blue-600); }
.icon-green { background: rgba(47,111,94,0.12); color: var(--green-600); }
.icon-amber { background: rgba(201,163,78,0.15); color: var(--gold-600); }
.icon-red { background: rgba(181,72,42,0.12); color: var(--red-600); }
.icon-purple { background: rgba(139,92,246,0.12); color: #8B5CF6; }
.icon-navy { background: rgba(14,21,38,0.08); color: var(--navy-900); }

.mini-stat-label { font-size: 11.5px; color: var(--ink-600); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.mini-stat-value { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 700; margin: 3px 0; }
.mini-stat-link { font-size: 12px; color: var(--gold-600); font-weight: 600; }

.info-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
@media (max-width: 1000px) { .info-grid-3 { grid-template-columns: 1fr; } }

.panel-icon-title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-icon {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.panel-icon-title h3 { font-size: 15px; }

.info-list { display: flex; flex-direction: column; gap: 12px; }
.info-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-label { color: var(--ink-600); }

.empty-state-icon { text-align: center; padding: 24px 12px; color: var(--ink-600); font-size: 13px; }
.empty-circle {
  width: 48px; height: 48px; border-radius: 50%; background: var(--paper);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-size: 18px;
}

.cred-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cred-row:last-child { border-bottom: none; }

/* ============================================================
   Task detail — assignees, update timeline
   ============================================================ */
.assignee-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.assignee-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--border);
  padding: 5px 12px 5px 5px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.assignee-pill .mini-avatar {
  width: 20px; height: 20px; border-radius: 50%; background: var(--navy-900); color: var(--gold-500);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy-900); color: var(--gold-500);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.timeline-body { flex: 1; }
.timeline-header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.timeline-author { font-weight: 700; font-size: 13.5px; }
.timeline-time { font-size: 11.5px; color: var(--ink-400); white-space: nowrap; }
.timeline-text { font-size: 13.5px; color: var(--ink-900); margin-top: 4px; white-space: pre-wrap; }

/* ============================================================
   Notes — card grid
   ============================================================ */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.note-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px; position: relative;
}
.note-card.pinned { border-color: var(--gold-500); background: rgba(201,163,78,0.04); }
.note-pin-flag { position: absolute; top: 12px; right: 14px; color: var(--gold-500); font-size: 14px; }
.note-content { font-size: 13.5px; color: var(--ink-900); white-space: pre-wrap; flex: 1; }
.note-meta { font-size: 11.5px; color: var(--ink-400); }
.note-related { font-size: 11.5px; }
.note-actions { display: flex; gap: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.note-actions a, .note-actions button {
  font-size: 12px; font-weight: 600; color: var(--ink-600); background: none; border: none; cursor: pointer; padding: 0;
}
.note-actions a:hover, .note-actions button:hover { color: var(--gold-600); }
.note-actions .danger:hover { color: var(--red-600); }


/* ===== DARK NAVY SIDEBAR ===== */

.sidebar {
    background: #0E1526 !important;
    color: #FFFFFF !important;
    border-right: 1px solid #1C263F !important;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.75) !important;
}

.sidebar .nav-link:hover {
    background: #1C263F !important;
    color: #FFFFFF !important;
}

.sidebar .nav-link.active {
    background: rgba(201, 163, 78, 0.15) !important;
    color: #C9A34E !important;
}

.sidebar .nav-section-label {
    color: rgba(255, 255, 255, 0.45) !important;
}

.sidebar .sidebar-search-box {
    background: #141C31 !important;
    border-color: #1C263F !important;
}

.sidebar .sidebar-search-box input {
    color: #FFFFFF !important;
}

.sidebar .sidebar-search-box input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.sidebar .sidebar-search-box svg {
    color: rgba(255, 255, 255, 0.5) !important;
}

.sidebar .sidebar-footer {
    border-top-color: #1C263F !important;
    color: rgba(255, 255, 255, 0.5) !important;
}

.sidebar .sidebar-footer strong {
    color: #FFFFFF !important;
}





/* -------------------------------------------------------------
 * UPGRADED UI POLISH: TOAST ALERTS, BREADCRUMBS & SMOOTHNESS
 * ------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast-alert {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 12px 36px rgba(14, 21, 38, 0.22);
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: toastSlideIn 0.3s ease-out;
    max-width: 440px;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-14px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast-alert.hide {
    opacity: 0;
    transform: translateY(-14px) scale(0.96);
}
.toast-success {
    background: #064E3B;
    color: #ECFDF5;
    border: 1px solid #10B981;
}
.toast-error {
    background: #7F1D1D;
    color: #FEF2F2;
    border: 1px solid #EF4444;
}
.toast-close {
    background: none;
    border: none;
    color: currentColor;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.8;
    line-height: 1;
    padding: 0 4px;
    transition: opacity 0.15s ease;
}
.toast-close:hover { opacity: 1; }

/* Breadcrumbs */
.crm-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-500);
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.crm-breadcrumbs a {
    color: var(--ink-600);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.12s ease;
}
.crm-breadcrumbs a:hover {
    color: var(--gold-600);
}
.crm-breadcrumbs .sep {
    color: var(--border);
    font-size: 11px;
}
.crm-breadcrumbs .current {
    color: var(--navy-900);
    font-weight: 600;
}

/* Enhanced 360 Workspace Cards */
.workspace-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 960px) {
    .workspace-grid { grid-template-columns: 1fr; }
}

.timeline-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    padding-left: 18px;
    border-left: 2px solid var(--paper);
}
.timeline-item {
    position: relative;
    font-size: 13px;
    line-height: 1.5;
}
.timeline-item::before {
    content: "";
    position: absolute;
    left: -24px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold-600);
    border: 2px solid #FFF;
}
