@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;700;800&family=Rajdhani:wght@400;500;600;700&display=swap');

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

:root {
  --bg:       #ffffff;
  --bg2:      #f5f5f7;
  --bg3:      #ebebef;
  --bg4:      #e0e0e6;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --red:      #e8192c;
  --red2:     #c0001a;
  --red-dim:  rgba(232,25,44,0.08);
  --red-glow: rgba(232,25,44,0.3);
  --yellow:   #d4840a;
  --green:    #00913f;
  --text:     #0d0d0d;
  --text2:    rgba(13,13,13,0.5);
  --text3:    rgba(13,13,13,0.28);
  --sidebar:  220px;
  --radius:   4px;
  --radius-sm: 2px;
}

/* ── Dark Mode ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg:      #111111;
  --bg2:     #1a1a1a;
  --bg3:     #222222;
  --bg4:     #2c2c2c;
  --border:  rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text:    #ededed;
  --text2:   rgba(237,237,237,0.5);
  --text3:   rgba(237,237,237,0.28);
}

html[data-theme="dark"] .sidebar               { background: var(--bg2); }
html[data-theme="dark"] .pipeline-card            { background: var(--bg2); }
html[data-theme="dark"] .pipeline-hdr             { background: var(--bg); }
html[data-theme="dark"] .mob-list              { background: var(--bg2); }
html[data-theme="dark"] .mob-invoice-list      { background: var(--bg2); }

/* smooth theme transitions */
body, .sidebar, .table-card, .stat-card, .table-hdr, th, td, .modal, .filter-panel {
  transition: background-color 0.2s, border-color 0.2s, color 0.15s;
}

body {
  font-family: 'Rajdhani', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before { display: none; }
body::after { display: none; }

/* LAYOUT */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar);
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

/* Red gradient on sidebar right edge */
.sidebar::after {
  content: '';
  position: absolute; right: 0; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(232,25,44,0.5) 30%, rgba(232,25,44,0.5) 70%, transparent);
  pointer-events: none;
}

.sidebar-brand {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Top red accent bar on brand */
.sidebar-brand::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--red), rgba(232,25,44,0.3) 60%, transparent);
}

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

.sidebar-brand .logo-mark {
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(232,25,44,0.4);
}

.sidebar-brand .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1;
}

/* Fallback: old .logo span red */
.sidebar-brand .logo span { color: var(--red); }

.sidebar-brand .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(13,13,13,0.35);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* Nav section headers */
.nav-section {
  padding: 14px 18px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text3);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-section::after {
  content: '';
  flex: 1; height: 1px;
  background: var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 0 8px;
  border-radius: 0;
  border-left: 2px solid transparent;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.12s;
  cursor: pointer;
  border-top: none;
  border-right: none;
  border-bottom: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  position: relative;
  font-family: 'Rajdhani', sans-serif;
}

.nav-item .icon { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; line-height: 1; }

/* SVG icons in nav */
.nav-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(232,25,44,0.05);
  border-left-color: rgba(232,25,44,0.3);
}

.nav-item.active {
  color: var(--red);
  background: rgba(232,25,44,0.07);
  border-left-color: var(--red);
}

/* Remove old yellow active — Option B uses red */
.nav-item.active::before {
  display: none;
}

.nav-sep { height: 1px; background: var(--border); margin: 6px 10px; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

/* Version badge */
.sb-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sb-live { color: var(--green); }

/* MAIN CONTENT */
.main {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
  position: relative; z-index: 1;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.topbar::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; width: 120px; height: 1px;
  background: linear-gradient(90deg, var(--red), transparent);
}

.page-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 4px;
  opacity: 0.7;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1;
}

.page-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* CARDS */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, rgba(232,25,44,0.4), transparent 50%);
  pointer-events: none;
}

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

.card-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 3px;
  opacity: 0.7;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* TABLE CARD */
.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.table-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(232,25,44,0.3) 40%, transparent 70%);
}

.table-hdr {
  padding: 16px 22px 0;
  position: relative;
  background: var(--bg);
}

.table-hdr::before { display: none; }

.table-hdr::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, rgba(232,25,44,0.6) 0%, rgba(232,25,44,0.15) 45%, transparent 100%);
}

.table-hdr-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: relative; z-index: 1;
  padding-bottom: 14px;
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(232,25,44,0.22) 50%, transparent 80%);
}
.kpi-card:hover { border-color: var(--border2); }
.kpi-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--red); opacity: 0.7;
  margin-bottom: 10px;
}
.kpi-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 40px; letter-spacing: 1px;
  line-height: 1; color: var(--text);
  margin-bottom: 8px;
}
.kpi-footer { display: flex; align-items: center; gap: 8px; }
.kpi-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; color: var(--text3);
  letter-spacing: 0.3px; flex: 1;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 3px; flex-shrink: 0;
}
.kpi-delta.up      { background: rgba(0,145,63,0.12); color: #00913f; }
.kpi-delta.down    { background: rgba(232,25,44,0.10); color: #e8192c; }
.kpi-delta.warn    { background: rgba(212,132,10,0.12); color: #d4840a; }
.kpi-delta.neutral { background: var(--bg3); color: var(--text3); }

/* ── Review Pipeline ── */
.pipeline-section { margin-bottom: 24px; }
.pipeline-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; position: relative;
}
.pipeline-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(232,25,44,0.3) 40%, transparent 70%);
}
.pipeline-hdr {
  padding: 16px 22px 14px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; position: relative;
}
.pipeline-hdr::after {
  content: ''; position: absolute; bottom: -1px; left: 0; width: 140px; height: 1px;
  background: linear-gradient(90deg, rgba(232,25,44,0.5), transparent);
}
.pipeline-tabs {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px;
}
.pipeline-tab {
  padding: 5px 12px; border-radius: 4px; border: none; background: none;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase; color: var(--text2);
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.pipeline-tab.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.pipeline-tab:hover:not(.active) { color: var(--text); }
.stage-flow {
  display: flex; align-items: center;
  padding: 10px 22px; border-bottom: 1px solid var(--border);
  background: var(--bg); overflow-x: auto;
}
.stage-flow::-webkit-scrollbar { display: none; }
.stage-step {
  display: flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text3); white-space: nowrap; padding: 4px 10px;
}
.stage-step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border2); flex-shrink: 0; }
.stage-step.active .stage-step-dot { background: var(--red); }
.stage-step.active { color: var(--text2); }
.stage-arrow { color: var(--border2); font-size: 10px; padding: 0 2px; }
.review-rows { display: flex; flex-direction: column; }
.review-row {
  display: grid;
  grid-template-columns: 44px 1fr 130px 90px 180px;
  gap: 12px; align-items: center;
  padding: 13px 22px; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.review-row:last-child { border-bottom: none; }
.review-row:hover { background: rgba(232,25,44,0.025); }
.review-row.needs-action {
  background: rgba(212,132,10,0.03);
  border-left: 2px solid rgba(212,132,10,0.4);
  padding-left: 20px;
}
.review-row.needs-action:hover { background: rgba(212,132,10,0.05); }
.rv-avatar {
  width: 36px; height: 36px; border-radius: 50%; color: #fff;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rv-client-name { font-size: 13px; font-weight: 700; color: var(--text); }
.rv-project { font-size: 11px; color: var(--text2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-inv-id { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text3); margin-top: 2px; }
.stage-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 4px 8px; border-radius: var(--radius); white-space: nowrap;
}
.stage-badge .dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.stage-draft    { background: var(--bg3); color: var(--text3); }
.stage-draft .dot { background: var(--text3); }
.stage-sent     { background: rgba(212,132,10,0.1); color: #d4840a; }
.stage-sent .dot { background: #d4840a; }
.stage-viewed   { background: rgba(212,132,10,0.14); color: #d4840a; }
.stage-viewed .dot { background: #d4840a; box-shadow: 0 0 4px #d4840a; }
.stage-approved { background: rgba(0,145,63,0.1); color: #00913f; }
.stage-approved .dot { background: #00913f; }
.stage-paid     { background: rgba(0,145,63,0.14); color: #00913f; }
.stage-paid .dot { background: #00913f; box-shadow: 0 0 4px #00913f; }
.stage-delivered { background: rgba(14,127,197,0.1); color: #0e7fc5; }
.stage-delivered .dot { background: #0e7fc5; }
.rv-meta { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text3); text-align: center; }
.rv-actions { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.rv-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Rajdhani', sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: 0.3px; text-transform: uppercase;
  padding: 5px 10px; border-radius: var(--radius); border: none; cursor: pointer;
  transition: all 0.12s; white-space: nowrap;
}
.rv-btn-ghost { background: none; color: var(--text2); border: 1px solid var(--border2); }
.rv-btn-ghost:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.rv-btn-primary { background: var(--red); color: #fff; }
.rv-btn-primary:hover { background: var(--red2); }
.rv-btn-green { background: rgba(0,145,63,0.12); color: #00913f; border: 1px solid rgba(0,145,63,0.2); }
.rv-btn-green:hover { background: rgba(0,145,63,0.2); }
.rv-btn-amber { background: rgba(212,132,10,0.1); color: #d4840a; border: 1px solid rgba(212,132,10,0.25); }
.rv-btn-amber:hover { background: rgba(212,132,10,0.18); }

/* COUNT BADGE */
.count-badge {
  background: rgba(232,25,44,0.1);
  color: var(--red);
  border: 1px solid rgba(232,25,44,0.25);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 2px;
  letter-spacing: 1px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all 0.12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: 'Rajdhani', sans-serif;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  border: 1px solid rgba(232,25,44,0.5);
  box-shadow: 0 2px 14px rgba(232,25,44,0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover {
  background: var(--red2);
  box-shadow: 0 4px 22px rgba(232,25,44,0.5);
}

.btn-success {
  background: rgba(0,240,136,0.1);
  color: var(--green);
  border: 1px solid rgba(0,240,136,0.2);
}
.btn-success:hover { background: rgba(0,240,136,0.18); }

.btn-danger {
  background: rgba(232,25,44,0.1);
  color: var(--red);
  border: 1px solid rgba(232,25,44,0.2);
}
.btn-danger:hover { background: rgba(232,25,44,0.2); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: rgba(255,255,255,0.18); }

.btn-yellow {
  background: rgba(255,229,102,0.1);
  color: var(--yellow);
  border: 1px solid rgba(255,229,102,0.22);
}
.btn-yellow:hover { background: rgba(255,229,102,0.18); }

.btn-sm { padding: 5px 10px; font-size: 9.5px; letter-spacing: 1px; }
.btn-lg { padding: 10px 22px; font-size: 13px; }

.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid;
}

.badge-green  { background: rgba(0,240,136,0.08);   color: var(--green);  border-color: rgba(0,240,136,0.2); }
.badge-yellow { background: rgba(255,229,102,0.08);  color: var(--yellow); border-color: rgba(255,229,102,0.22); }
.badge-red    { background: rgba(232,25,44,0.08);    color: var(--red);    border-color: rgba(232,25,44,0.25); }
.badge-gray   { background: rgba(255,255,255,0.04);  color: var(--text2);  border-color: var(--border); }

/* TABLES */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(232,25,44,0.04); }

/* FORMS */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border2);
  border-left: 2px solid rgba(232,25,44,0.3);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 9px 13px;
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-left-color: rgba(232,25,44,0.75);
  border-color: rgba(232,25,44,0.22);
  background: rgba(232,25,44,0.03);
}

input::placeholder, textarea::placeholder {
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
}
select option { background: var(--bg2); color: var(--text); }
textarea { resize: vertical; min-height: 80px; border-radius: 0 var(--radius) var(--radius) var(--radius); }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* SEARCH */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-left: 2px solid rgba(232,25,44,0.3);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 7px 12px;
  transition: border-color 0.15s, background 0.15s;
  width: 260px;
}

.search-wrap:focus-within {
  border-left-color: rgba(232,25,44,0.75);
  border-color: rgba(232,25,44,0.22);
  background: rgba(232,25,44,0.03);
}

.search-wrap input {
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: 12px;
  width: 100%;
  color: var(--text);
}

.search-wrap input::placeholder { color: var(--text3); }
.search-wrap input:focus { box-shadow: none; }
.search-icon { color: rgba(232,25,44,0.6); flex-shrink: 0; width:14px; height:14px; display:flex; align-items:center; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-top: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96);
  transition: transform 0.2s;
  position: relative;
}
.modal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--red), rgba(232,25,44,0.3) 60%, transparent);
}

.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 3px;
  opacity: 0.7;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.close-btn {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  width: 28px; height: 28px;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
  line-height: 1;
}
.close-btn:hover { color: var(--text); background: var(--bg4); border-color: rgba(232,25,44,0.3); }

/* TABS */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 10px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.12s;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}

.tab-btn:hover { color: var(--text2); }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }

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

/* FILE GRID */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.file-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: border-color 0.12s;
}

.file-card:hover { border-color: rgba(232,25,44,0.35); }

.file-preview { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg3); }
.file-preview-video { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--bg3); }

.file-info { padding: 10px 12px; border-top: 1px solid var(--border); }
.file-name { font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.file-meta { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text2); letter-spacing: 0.3px; }
.file-actions { display: flex; gap: 5px; margin-top: 8px; }

/* UPLOAD ZONE */
.upload-zone {
  border: 1px dashed rgba(232,25,44,0.3);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: block;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: rgba(232,25,44,0.65);
  background: rgba(232,25,44,0.04);
}

.upload-icon { font-size: 32px; margin-bottom: 10px; }
.upload-text { color: var(--text2); font-size: 13px; font-weight: 600; }
.upload-sub { font-family: 'JetBrains Mono', monospace; color: var(--text3); font-size: 9.5px; margin-top: 5px; letter-spacing: 0.5px; }

/* TOAST */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 11px 16px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  animation: slide-in 0.22s ease;
  max-width: 300px;
}

.toast.success { border-left: 2px solid var(--green); }
.toast.error   { border-left: 2px solid var(--red); }
.toast.info    { border-left: 2px solid var(--yellow); }

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text3);
}
.empty-state .icon { font-size: 34px; margin-bottom: 10px; }
.empty-state .text { font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 6px; letter-spacing: 0.5px; }
.empty-state .sub  { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.5px; }

/* PROGRESS BAR */
.progress-bar  { background: var(--bg4); border-radius: 2px; height: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--red); box-shadow: 0 0 8px rgba(232,25,44,0.4); transition: width 0.3s; }

/* AVATAR */
.avatar {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: linear-gradient(135deg, #8b0010, var(--red));
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 800; color: white; flex-shrink: 0;
  border: 1px solid rgba(232,25,44,0.35);
}

/* MISC */
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.text-muted  { color: var(--text2); }
.text-small  { font-size: 13px; }
.text-mono   { font-family: 'JetBrains Mono', monospace; letter-spacing: 0.3px; }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* INVOICE TABLE */
.invoice-items-table td, .invoice-items-table th { padding: 10px 12px; }

/* INFO PILLS */
.info-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 22px; }
.info-pill {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}
.info-pill::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 8px; height: 8px;
  border-right: 1px solid rgba(232,25,44,0.4);
  border-top: 1px solid rgba(232,25,44,0.4);
}
.info-pill .label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.info-pill .value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}

/* SYS READOUT — sidebar footer panel */
.sys-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.readout-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 2px;
}

.readout-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 6.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 2px;
}

.readout-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.3px;
}

.readout-val.warn { color: var(--yellow); }

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.user-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text2);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* HAMBURGER */
.hamburger {
  display: none;
  position: fixed; top: 14px; right: 14px; z-index: 200;
  background: rgba(9,9,13,0.97);
  border: 1px solid rgba(232,25,44,0.35);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 12px rgba(232,25,44,0.2);
}
.hamburger span { display: block; width: 20px; height: 1.5px; background: #ffffff; border-radius: 2px; transition: all 0.2s; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 99;
}

/* CYBORG scan line animation */
@keyframes cyborg-scan {
  0%   { transform: translateY(-100px); opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}
@keyframes cyborg-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(232,25,44,0.6), 0 0 14px rgba(232,25,44,0.3); }
  50%       { box-shadow: 0 0 16px rgba(232,25,44,1),  0 0 32px rgba(232,25,44,0.6); }
}

/* Scan line element — hidden on desktop, shown on mobile */
.sidebar::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 2px; height: 90px;
  background: linear-gradient(to bottom, transparent, #e8192c 40%, #ff3346 60%, transparent);
  z-index: 10;
  pointer-events: none;
  display: none;
  animation: cyborg-scan 2.4s linear infinite, cyborg-glow 2.4s ease-in-out infinite;
}

/* ── SHARED MOBILE CARD PATTERN ─────────────────────────── */
/* Used across all list pages (orders, links, requests, contracts) */
.mob-list { display: none; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 80px; }
.mob-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: background 0.12s; cursor: pointer;
}
.mob-card:last-child { border-bottom: none; }
.mob-card:active { background: var(--bg2); }
.mob-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.mob-body { flex: 1; min-width: 0; }
.mob-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mob-sub { font-size: 13px; color: var(--text); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mob-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mob-right { flex-shrink: 0; text-align: right; display: flex; align-items: center; gap: 8px; }
.mob-val { font-size: 15px; font-weight: 700; }
.mob-val-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.mob-chevron { color: var(--text3); font-size: 22px; line-height: 1; }

/* FAB — shared across all pages */
.fab {
  display: none;
  position: fixed; bottom: 24px; right: 20px; z-index: 90;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--red); color: #fff;
  border: none; font-size: 26px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(232,25,44,0.45);
  align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.93); }

/* ── DASHBOARD MOBILE ────────────────────────────────────── */
.dash-invoice-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: inherit;
  transition: background 0.12s;
}
.dash-invoice-card:last-child { border-bottom: none; }
.dash-invoice-card:active { background: var(--bg2); }
.mob-invoice-list { display: none; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* RESPONSIVE — Tablet */
@media (max-width: 900px) {
  .hamburger { display: flex; }

  /* Sidebar slides in from the RIGHT */
  .sidebar {
    left: auto; right: 0;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 150;
    background: var(--bg2);
    box-shadow: -6px 0 32px rgba(0,0,0,0.22);
  }
  .sidebar.open { transform: translateX(0); }

  /* Flip red edge gradient to left side */
  .sidebar::after {
    right: auto; left: 0;
    background: linear-gradient(to bottom, transparent, rgba(232,25,44,0.5) 30%, rgba(232,25,44,0.5) 70%, transparent);
  }

  /* Show cyborg scan line */
  .sidebar::before { display: block; }

  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; padding: 72px 16px 24px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 30px; }
  .kpi-card { padding: 16px 14px 12px; }
  .review-row { grid-template-columns: 36px 1fr 110px; gap: 10px; padding: 12px 16px; }
  .review-row .rv-meta, .review-row .rv-actions { display: none; }
  .search-wrap { width: 100%; }

  /* Switch list pages to card view */
  .table-card { display: none; }
  .mob-list { display: block; }
  .mob-invoice-list { display: block; }
  .fab { display: flex; }

  /* Topbar: stack title + actions vertically */
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar-title-row { display: flex; align-items: center; justify-content: space-between; }
  .topbar-actions { display: none; }

  /* Dashboard specific */
  .dash-actions { display: none; }
  /* Hide top-of-page primary action buttons — FAB replaces them on mobile */
  .mob-hide { display: none; }
  table th:nth-child(n+5), table td:nth-child(n+5) { display: none; }
}

/* RESPONSIVE — Mobile */
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 14px 12px 10px; }
  .kpi-value { font-size: 26px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { padding: 20px 16px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 12px 12px 0 0; max-height: 92vh; max-width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }
  table th:nth-child(n+5), table td:nth-child(n+5) { display: table-cell; }
  .file-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr 1fr !important; }
  #toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

/* Sidebar logo — larger on desktop only */
@media (min-width: 901px) {
  .sb-logo-img { width: 60% !important; }
}

/* ── REPORTING SECTION ──────────────────────────────────── */
.report-section { margin-bottom: 24px; }
.report-section-hdr {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px;
}
.report-section-title {
  font-size: 12px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text2);
  font-family: 'JetBrains Mono', monospace;
}
.report-section-hdr::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.report-row { display: grid; gap: 14px; margin-bottom: 14px; }
.report-row-2 { grid-template-columns: 2fr 1fr; }
.report-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.report-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  position: relative; padding: 18px 20px;
}
.report-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(232,25,44,0.2) 50%, transparent 100%);
}
.report-card-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.report-card-meta { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text3); margin-top: 2px; }
.report-kpi { text-align: right; }
.report-kpi-val {
  font-family: 'Bebas Neue', sans-serif; font-size: 26px;
  letter-spacing: 1px; color: var(--text); line-height: 1;
}
.report-kpi-sub { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.chart-wrap { position: relative; width: 100%; }

/* Donut */
.donut-layout { display: flex; align-items: center; gap: 20px; margin-top: 4px; }
.donut-canvas-wrap { flex-shrink: 0; position: relative; width: 130px; height: 130px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center-val { font-family: 'Bebas Neue', sans-serif; font-size: 22px; color: var(--text); line-height: 1; }
.donut-center-lbl { font-family: 'JetBrains Mono', monospace; font-size: 8px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }
.donut-legend { flex: 1; }
.donut-leg-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.donut-leg-item:last-child { border-bottom: none; }
.donut-leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.donut-leg-label { font-size: 12px; font-weight: 600; color: var(--text2); font-family: 'Rajdhani', sans-serif; flex: 1; }
.donut-leg-val { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text); }

/* Top clients */
.client-rank-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.client-rank-item { display: flex; align-items: center; gap: 10px; }
.rank-num { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; color: var(--text3); width: 16px; text-align: right; flex-shrink: 0; }
.rank-avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar-wrap { height: 3px; background: var(--border2); border-radius: 2px; margin-top: 4px; }
.rank-bar { height: 3px; background: var(--red); border-radius: 2px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }
.rank-val { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text); flex-shrink: 0; }

/* Month vs Month */
.mom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.mom-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.mom-label { font-family: 'JetBrains Mono', monospace; font-size: 8px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text3); margin-bottom: 6px; }
.mom-vals { display: flex; align-items: baseline; gap: 6px; }
.mom-current { font-family: 'Bebas Neue', sans-serif; font-size: 22px; color: var(--text); line-height: 1; }
.mom-delta { display: inline-flex; align-items: center; gap: 2px; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 3px; }
.mom-delta.up   { background: rgba(0,145,63,0.12); color: #00913f; }
.mom-delta.down { background: rgba(232,25,44,0.10); color: #e8192c; }
.mom-prev { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--text3); margin-top: 2px; }

/* Payment velocity */
.velocity-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.vel-metric { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.vel-label { font-size: 12px; font-weight: 600; color: var(--text2); font-family: 'Rajdhani', sans-serif; }
.vel-val { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 800; color: var(--text); }
.vel-val.warn { color: var(--red); }
.vel-val.good { color: var(--green); }
.overdue-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.overdue-row:last-child { border-bottom: none; }
.overdue-id { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 800; color: var(--text); }
.overdue-client { font-size: 12px; color: var(--text2); margin-top: 1px; }
.overdue-days { font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 800; color: var(--red); }
.overdue-amt { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--yellow); }

@media (max-width: 900px) {
  .report-row-2, .report-row-3 { grid-template-columns: 1fr; }
}
