/* ============================================================
   PGS CRM — Main Stylesheet
   ============================================================ */

:root {
  --primary:       #1a237e;
  --primary-light: #3949ab;
  --primary-dark:  #0d1454;
  --accent:        #ff6f00;
  --accent-light:  #ffa040;
  --sidebar-w:     260px;
  --sidebar-bg:    #0f1535;
  --sidebar-text:  #c5cae9;
  --topbar-h:      60px;
  --white:         #ffffff;
  --bg:            #f4f6fb;
  --card-bg:       #ffffff;
  --border:        #e0e4ef;
  --text:          #1e2a45;
  --text-muted:    #6b7a99;
  --success:       #2e7d32;
  --success-bg:    #e8f5e9;
  --error:         #c62828;
  --error-bg:      #ffebee;
  --warning:       #e65100;
  --warning-bg:    #fff3e0;
  --info:          #01579b;
  --info-bg:       #e1f5fe;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 8px rgba(0,0,0,.08);
  --shadow-lg:     0 4px 20px rgba(0,0,0,.12);
  --transition:    .2s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────── */
.app-wrapper   { display: flex; min-height: 100vh; }
.main-content  { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin-left var(--transition); }
.main-content.sidebar-collapsed { margin-left: 0; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 200;
  transition: transform var(--transition), width var(--transition);
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { flex-shrink: 0; }
.company-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; }
.logo-text {
  width: 40px; height: 40px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
}
.brand-name  { display: block; color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub   { display: block; color: var(--sidebar-text); font-size: 11px; opacity: .7; }

.sidebar-nav  { padding: 12px 0 24px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; color: var(--sidebar-text);
  text-decoration: none; transition: all var(--transition);
  font-size: 13.5px; border-left: 3px solid transparent;
}
.nav-item:hover     { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active    { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); }
.nav-item i         { width: 18px; text-align: center; font-size: 14px; }
.nav-child          { padding-left: 36px; font-size: 13px; }
.nav-group          { margin-top: 8px; }
.nav-group-label {
  padding: 10px 18px 4px;
  color: rgba(197,202,233,.5);
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.nav-group-label i  { font-size: 11px; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 16px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  padding: 6px 8px; color: var(--text-muted); font-size: 18px;
  border-radius: 6px; transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }
.topbar-title { font-size: 17px; font-weight: 600; color: var(--text); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date  { color: var(--text-muted); font-size: 13px; }

/* ── Notifications ────────────────────────────────────────── */
.topbar-notifications { position: relative; }
.topbar-icon-btn {
  background: none; border: none; cursor: pointer;
  padding: 8px 10px; color: var(--text-muted); font-size: 17px;
  border-radius: 8px; transition: all var(--transition);
  position: relative; display: flex; align-items: center; justify-content: center;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--primary); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid var(--white); line-height: 1;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 10px); right: -10px;
  width: 340px; background: var(--white);
  border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,.15);
  border: 1px solid var(--border); z-index: 1000;
  display: none; flex-direction: column; overflow: hidden;
  animation: notifFadeIn 0.2s ease-out forwards;
}
@keyframes notifFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notif-dropdown.show { display: flex; }
.notif-dropdown-header {
  padding: 14px 16px; background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; font-size: 14px;
}
.btn-link-text {
  background: none; border: none; color: var(--primary);
  font-size: 12px; font-weight: 600; cursor: pointer; padding: 0;
}
.btn-link-text:hover { text-decoration: underline; }
.notif-dropdown-body { max-height: 320px; overflow-y: auto; }
.notif-dropdown-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text); transition: background var(--transition);
}
.notif-dropdown-item:hover { background: var(--bg); }
.notif-dropdown-item.unread { background: rgba(99,102,241,0.04); }
.notif-dd-icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(99,102,241,0.1); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 13px;
}
.notif-dd-icon.reminder { background: rgba(234,88,12,0.12); color: #ea580c; }
.notif-dd-content { flex: 1; min-width: 0; }
.notif-dd-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-dd-msg { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.notif-dd-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-dropdown-footer {
  padding: 10px 16px; background: var(--bg);
  border-top: 1px solid var(--border); text-align: center;
}
.notif-dropdown-footer a { font-size: 12.5px; font-weight: 600; color: var(--primary); text-decoration: none; }
.notif-dropdown-footer a:hover { text-decoration: underline; }

/* ── Page Content ────────────────────────────────────────── */
.page-content  { flex: 1; padding: 24px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
}
.card-title  { font-size: 15px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title i{ color: var(--primary); }
.card-body   { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #fafbff; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header-left h1 {
  font-size: 22px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.page-header-left h1 i { color: var(--primary); font-size: 20px; }
.page-header-left .breadcrumb { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-header-left .breadcrumb a { color: var(--primary-light); text-decoration: none; }
.page-header-left .breadcrumb a:hover { text-decoration: underline; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid  { display: grid; gap: 16px; }
.stats-4     { grid-template-columns: repeat(4, 1fr); }
.stats-3     { grid-template-columns: repeat(3, 1fr); }
.stats-2     { grid-template-columns: repeat(2, 1fr); }

.stat-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue   { background: #e8eaf6; color: var(--primary); }
.stat-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.red    { background: #ffebee; color: #c62828; }
.stat-icon.purple { background: #f3e5f5; color: #7b1fa2; }
.stat-icon.teal   { background: #e0f2f1; color: #00695c; }
.stat-icon.indigo { background: #e8eaf6; color: #283593; }
.stat-icon.cyan   { background: #e0f7fa; color: #00838f; }

.stat-body   { flex: 1; min-width: 0; }
.stat-value  { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label  { color: var(--text-muted); font-size: 12px; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.stat-sub    { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }
.btn-danger   { background: var(--error); color: #fff; }
.btn-danger:hover { background: #8e0000; }
.btn-warning  { background: #f57f17; color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-sm  { padding: 5px 11px; font-size: 12.5px; }
.btn-xs  { padding: 3px 8px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon{ padding: 6px 8px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap    { overflow-x: auto; }
.table         { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th      { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); background: #f8f9ff; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f8f9ff; }
.table-striped tbody tr:nth-child(even) td { background: #fafbff; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-new, .badge-draft     { background: #e3f2fd; color: #0d47a1; }
.badge-active, .badge-paid, .badge-won, .badge-completed, .badge-approved { background: var(--success-bg); color: var(--success); }
.badge-pending, .badge-not_started { background: #fff3e0; color: #e65100; }
.badge-in_progress, .badge-sent, .badge-contacted { background: #e8eaf6; color: var(--primary); }
.badge-qualified, .badge-proposal_ready { background: #f3e5f5; color: #7b1fa2; }
.badge-lost, .badge-cancelled, .badge-inactive, .badge-rejected { background: var(--error-bg); color: var(--error); }
.badge-on_hold, .badge-expired, .badge-overdue { background: #fff8e1; color: #f57f17; }
.badge-partial, .badge-partially_paid, .badge-negotiation { background: #e0f7fa; color: #006064; }
.badge-verified, .badge-accepted { background: var(--success-bg); color: var(--success); }
.badge-received { background: #e8eaf6; color: var(--primary-dark); }
.badge-follow_up, .badge-in_review, .badge-under_review { background: #fff8e1; color: #b78103; }
.badge-changes_requested { background: #fce4ec; color: #c2185b; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid   { display: grid; gap: 16px; }
.form-2col   { grid-template-columns: 1fr 1fr; }
.form-3col   { grid-template-columns: 1fr 1fr 1fr; }
.form-4col   { grid-template-columns: repeat(4, 1fr); }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-label  { font-size: 13px; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--error); margin-left: 2px; }
.form-control {
  padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px; color: var(--text);
  background: var(--white); width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--primary-light); outline: none; box-shadow: 0 0 0 3px rgba(57,73,171,.12); }
.form-control.is-invalid { border-color: var(--error); }
.form-hint   { font-size: 12px; color: var(--text-muted); }
.form-error  { font-size: 12px; color: var(--error); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check  { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.form-section-title { font-size: 14px; font-weight: 700; color: var(--primary); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.form-full   { grid-column: 1 / -1; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius); margin: 12px 24px 0;
  font-size: 13.5px; position: relative;
}
.alert ul    { margin: 0; padding-left: 16px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a5d6a7; }
.alert-error   { background: var(--error-bg); color: var(--error); border: 1px solid #ef9a9a; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #ffcc80; }
.alert-info    { background: var(--info-bg); color: var(--info); border: 1px solid #81d4fa; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; margin-left: auto; color: inherit; opacity: .7; }
.alert-close:hover { opacity: 1; }
.alert { transition: opacity .4s; }

/* ── Toast notifications ─────────────────────────────────── */
.toast-container { position: fixed; top: calc(var(--topbar-h) + 16px); right: 20px; z-index: 1200; display: flex; flex-direction: column; gap: 10px; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 14px 14px 14px 16px; border-radius: 10px; box-shadow: 0 10px 28px rgba(15, 21, 53, .18); font-size: 13.5px; line-height: 1.45; animation: toast-in .25s ease-out; pointer-events: auto; transition: opacity .25s ease, transform .25s ease; }
.toast > i { margin-top: 2px; font-size: 16px; }.toast > span, .toast ul { flex: 1; }.toast ul { margin: 0; padding-left: 17px; }
.toast-close { flex: 0 0 auto; margin: -3px -3px 0 0; padding: 0 4px; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 19px; line-height: 1; opacity: .7; }.toast-close:hover { opacity: 1; }
.toast-leaving { opacity: 0; transform: translateX(18px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-nav  { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-link {
  padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
  transition: all var(--transition);
}
.tab-link:hover  { color: var(--primary); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Info Rows ────────────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-label{ font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.info-value{ font-size: 14px; color: var(--text); font-weight: 500; }
.info-value a { color: var(--primary-light); text-decoration: none; }
.info-value a:hover { text-decoration: underline; }

/* ── Financial Summary Panels ─────────────────────────────── */
.fin-panel { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.fin-panel-header { background: var(--primary); color: #fff; padding: 12px 16px; font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.fin-panel-body   { background: var(--card-bg); }
.fin-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.fin-row:last-child { border-bottom: none; }
.fin-row.total { background: #f8f9ff; font-weight: 600; }
.fin-row.outstanding { background: var(--error-bg); color: var(--error); }
.fin-row.received    { background: var(--success-bg); color: var(--success); }
.fin-amount { font-weight: 600; font-size: 14px; }

/* ── Pipeline / Flow ──────────────────────────────────────── */
.flow-chart { display: flex; align-items: flex-start; gap: 0; flex-wrap: wrap; }
.flow-step  { display: flex; flex-direction: column; align-items: center; min-width: 110px; }
.flow-bubble{
  width: 90px; min-height: 70px; border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.flow-bubble:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.flow-bubble a { text-decoration: none; color: inherit; }
.flow-bubble .flow-num  { font-size: 10px; opacity: .7; margin-bottom: 2px; }
.flow-bubble .flow-name { font-size: 12px; }
.flow-bubble.done    { background: var(--success-bg); color: var(--success); border: 1.5px solid #a5d6a7; }
.flow-bubble.active  { background: #e8eaf6; color: var(--primary); border: 1.5px solid var(--primary); }
.flow-bubble.pending { background: #fafafa; color: var(--text-muted); border: 1.5px solid var(--border); }
.flow-arrow { padding: 0 4px; color: var(--text-muted); font-size: 18px; margin-top: 22px; }

/* ── Dynamic rows (line items, phases, etc.) ──────────────── */
.dynamic-row {
  display: grid; gap: 8px; align-items: center;
  background: #fafbff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
}
.dynamic-row .row-handle { cursor: grab; color: var(--text-muted); }
.dynamic-row .row-delete { color: var(--error); background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.dynamic-row .row-delete:hover { background: var(--error-bg); }
.add-row-btn { display: flex; align-items: center; gap: 6px; color: var(--primary-light); background: none; border: 1.5px dashed var(--primary-light); padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; width: 100%; justify-content: center; margin-top: 4px; transition: all var(--transition); }
.add-row-btn:hover { background: #e8eaf6; }

/* ── Phase Cards ──────────────────────────────────────────── */
.phase-card { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 16px; }
.phase-card-header { background: var(--primary); color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.phase-card-body   { padding: 16px; }
.phase-fin-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.phase-fin-item    { background: #f8f9ff; border-radius: var(--radius); padding: 10px 14px; }
.phase-fin-label   { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.phase-fin-value   { font-size: 16px; font-weight: 700; color: var(--text); }
.phase-fin-item.income  { border-left: 3px solid var(--success); }
.phase-fin-item.expense { border-left: 3px solid var(--accent); }
.phase-fin-item.paid    { border-left: 3px solid var(--primary); }
.phase-fin-item.pending { border-left: 3px solid var(--error); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex !important; }
.modal, .modal-container { background: #ffffff !important; border-radius: 12px !important; width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important; border: 1px solid #e2e8f0; }
.modal-lg  { max-width: 800px !important; }
.modal-header { padding: 18px 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; background: #ffffff; border-radius: 12px 12px 0 0; }
.modal-title  { font-size: 16px; font-weight: 700; color: #0f172a; }
.modal-close  { background: none; border: none; cursor: pointer; font-size: 22px; color: #64748b; padding: 2px 6px; }
.modal-close:hover { color: #0f172a; }
.modal-body   { padding: 20px; background: #ffffff; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; background: #f8fafc; border-radius: 0 0 12px 12px; }

/* ── Search / Filter Bar ──────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar .form-control { max-width: 240px; }
.filter-bar .search-input { max-width: 280px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination-wrap { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.pagination-wrap .pagination { display: flex; gap: 4px; list-style: none; }
.pagination-wrap .pagination .page-link { padding: 6px 11px; border-radius: var(--radius); color: var(--primary); border: 1px solid var(--border); text-decoration: none; font-size: 13px; display: block; }
.pagination-wrap .pagination .active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination-wrap .pagination .disabled .page-link { opacity: .4; pointer-events: none; }

/* ── PDF Preview Styles ───────────────────────────────────── */
.pdf-preview-wrap { background: #525659; padding: 20px; border-radius: var(--radius); }
.pdf-page { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto 16px; padding: 20mm 18mm; position: relative; box-shadow: 0 4px 20px rgba(0,0,0,.3); }
.pdf-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.pdf-company-name { font-size: 22px; font-weight: 800; color: var(--primary); }
.pdf-section-title { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 2px solid var(--primary); }
.pdf-table th, .pdf-table td { font-size: 12px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 48px; color: var(--border); margin-bottom: 12px; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 6px; }
.empty-state p  { color: var(--text-muted); font-size: 13px; }

/* ── Utilities ────────────────────────────────────────────── */
.d-flex     { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2      { gap: 8px; }
.gap-3      { gap: 12px; }
.gap-4      { gap: 16px; }
.mt-1       { margin-top: 6px; }
.mt-2       { margin-top: 12px; }
.mt-3       { margin-top: 18px; }
.mt-4       { margin-top: 24px; }
.mb-0       { margin-bottom: 0; }
.mb-2       { margin-bottom: 12px; }
.mb-3       { margin-bottom: 18px; }
.mb-4       { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12.5px; }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.text-success{ color: var(--success); }
.text-danger { color: var(--error); }
.text-warning{ color: var(--warning); }
.text-primary{ color: var(--primary); }
.w-100      { width: 100%; }
.no-wrap    { white-space: nowrap; }
.amount     { font-weight: 600; color: var(--text); }
.amount-large { font-size: 20px; font-weight: 700; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) { .stats-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  {
  .form-2col, .form-3col, .form-4col { grid-template-columns: 1fr; }
  .stats-3 { grid-template-columns: 1fr 1fr; }
  .sidebar  { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}
@media (max-width: 600px)  {
  .stats-4, .stats-3, .stats-2 { grid-template-columns: 1fr; }
  .page-content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .pdf-page { width: 100%; padding: 10mm; }
  .toast-container { top: 12px; right: 16px; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .page-header .btn-group,
  .tab-nav, .filter-bar, .pagination-wrap, .alert, .toast-container { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; }
  .pdf-preview-wrap { background: none; padding: 0; }
  .pdf-page { box-shadow: none; margin: 0; width: 100%; }
  body { background: white; }
}

/* ── Authentication ─────────────────────────────────────── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0d1454, #1a237e 55%, #3949ab); }
.auth-card { width: min(100%, 420px); padding: 36px; border-radius: 16px; background: var(--white); box-shadow: 0 24px 64px rgba(0, 0, 0, .28); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 38px; color: var(--primary); }
.auth-brand-mark { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .5px; }
.auth-brand strong, .auth-brand span { display: block; }
.auth-brand strong { font-size: 17px; }.auth-brand span { color: var(--text-muted); font-size: 12px; }
.auth-heading { margin-bottom: 26px; }.auth-heading h1 { margin-bottom: 6px; color: var(--text); font-size: 25px; }.auth-heading p { color: var(--text-muted); }
.auth-form .form-group { margin-bottom: 18px; }.input-with-icon { position: relative; }.input-with-icon i { position: absolute; top: 50%; left: 13px; transform: translateY(-50%); color: var(--text-muted); }.input-with-icon .form-control { padding-left: 38px; }
.field-error { margin-top: 5px; color: var(--error); font-size: 12px; }.is-invalid { border-color: var(--error) !important; }
.remember-control { display: flex; align-items: center; gap: 8px; margin: 4px 0 22px; color: var(--text-muted); cursor: pointer; font-size: 13px; }.auth-submit { width: 100%; justify-content: center; padding: 11px 16px; }
.topbar-user { color: var(--text-muted); font-size: 13px; }.logout-form { display: inline; }

/* ── Markdown & ChatGPT Document Content Rendering ───────── */
.markdown-body {
  font-family: inherit;
  color: var(--text);
  font-size: 14px;
  line-height: 1.68;
  word-break: break-word;
}
.markdown-body > *:first-child { margin-top: 0 !important; }
.markdown-body > *:last-child { margin-bottom: 0 !important; }

.markdown-body h1, .markdown-body .requirement-heading-1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin: 24px 0 12px;
  padding-bottom: 2px;
  border-bottom: none;
}
.markdown-body h2, .markdown-body .requirement-heading-2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin: 20px 0 10px;
  padding-bottom: 2px;
  border-bottom: none;
}
.markdown-body h3, .markdown-body .requirement-heading-3 {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 16px 0 8px;
}
.markdown-body h4, .markdown-body .requirement-heading-4 {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin: 14px 0 6px;
}
.markdown-body p, .markdown-body .requirement-paragraph {
  margin: 0 0 12px;
  color: #1e293b;
}
.markdown-body strong {
  font-weight: 700;
  color: #0f172a;
}
.markdown-body em {
  font-style: italic;
}
.markdown-body ul, .markdown-body ol {
  margin: 0 0 14px;
  padding-left: 24px;
}
.markdown-body ul li::marker {
  color: #0d2d52;
}
.markdown-body li {
  margin: 4px 0;
  color: #1e293b;
}
ul.requirement-list {
  list-style: none;
  padding-left: 20px;
}
ul.requirement-list li::before {
  content: '❖';
  display: inline-block;
  width: 14px;
  margin-left: -18px;
  color: #0d2d52;
  font-size: 9px;
}
.markdown-body blockquote {
  margin: 0 0 14px;
  padding: 10px 16px;
  background: #f8fafc;
  border-left: 4px solid var(--primary-light);
  color: #475569;
  border-radius: 0 6px 6px 0;
}

/* ChatGPT Style Tables */
.markdown-body table, .markdown-table, .requirement-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 13.5px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}
.markdown-body table thead th, .markdown-table th, .requirement-table th {
  background: #0f172a;
  color: #ffffff;
  font-weight: 600;
  text-align: left;
  padding: 11px 14px;
  font-size: 12.5px;
  letter-spacing: 0.3px;
  border-bottom: 2px solid #0f172a;
  white-space: nowrap;
}
.markdown-body table tbody td, .markdown-table td, .requirement-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #f1f5f9;
  vertical-align: top;
  color: #1e293b;
  line-height: 1.5;
}
.markdown-body table tbody tr:nth-child(even), .markdown-table tbody tr:nth-child(even) {
  background: #f8fafc;
}
.markdown-body table tbody tr:hover, .markdown-table tbody tr:hover {
  background: #f1f5f9;
}

/* ChatGPT Style Code Blocks */
.markdown-body pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 18px;
  border-radius: 8px;
  margin: 14px 0 18px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid #1e293b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  position: relative;
}
.markdown-body pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border: none !important;
  font-size: inherit;
  font-family: inherit;
  white-space: pre;
}
.markdown-body :not(pre) > code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

/* Global Pagination Styles & SVG Fix */
nav[role="navigation"] svg {
  width: 14px !important;
  height: 14px !important;
  display: inline-block !important;
  vertical-align: middle;
}
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 10px;
}

