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

:root {
  --navy: #1a2744;
  --navy-light: #2c3e5a;
  --navy-hover: #354a6b;
  --orange: #e8841a;
  --orange-light: #f5a623;
  --bg: #f5f7fa;
  --white: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --text-muted: #a0aec0;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --green: #38a169;
  --green-bg: #f0fff4;
  --yellow: #d69e2e;
  --yellow-bg: #fffff0;
  --red: #e53e3e;
  --red-bg: #fff5f5;
  --blue: #3182ce;
  --purple: #805ad5;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --transition: all .2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ═══ LAYOUT ═══ */
.app { display: flex; min-height: 100vh; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: 260px; background: var(--navy); position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 100; transition: width .3s;
}
.sidebar-brand {
  padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand h1 { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.sidebar-brand h1 span { color: var(--orange); }
.sidebar-brand p { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 2px; letter-spacing: .5px; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: rgba(255,255,255,.6);
  text-decoration: none; font-size: 13px; font-weight: 500; transition: var(--transition);
  cursor: pointer; border-left: 3px solid transparent; margin: 1px 0;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.9); }
.sidebar-nav a.active { background: rgba(255,255,255,.08); color: var(--orange); border-left-color: var(--orange); }
.sidebar-nav a .icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.sidebar-nav .divider { height: 1px; background: rgba(255,255,255,.06); margin: 12px 16px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.3); display: block; margin-bottom: 6px; }
.sidebar-footer select {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.06); color: #fff; font-size: 12px; font-family: inherit;
}

/* ═══ MAIN CONTENT ═══ */
.main { flex: 1; margin-left: 260px; min-height: 100vh; }
.top-bar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 50;
}
.top-bar h1 { font-size: 20px; font-weight: 700; color: var(--navy); }
.top-bar-actions { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 28px 32px; }

/* ═══ STAT CARDS ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); transition: var(--transition); border: 1px solid var(--border-light);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; font-weight: 600; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.purple .stat-value { color: var(--purple); }

/* ═══ TRAFFIC LIGHTS ═══ */
.tl { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.tl-red { background: var(--red); box-shadow: 0 0 6px rgba(229,62,62,.4); animation: tlPulse 2s infinite; }
.tl-yellow { background: var(--yellow); box-shadow: 0 0 4px rgba(214,158,46,.3); }
.tl-green { background: var(--green); }
@keyframes tlPulse { 0%,100%{ opacity:1; box-shadow: 0 0 6px rgba(229,62,62,.4); } 50%{ opacity:.7; box-shadow: 0 0 12px rgba(229,62,62,.6); } }

.pillar-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:20px; margin-bottom:28px; }
.pillar-card {
  background: linear-gradient(180deg, #fffdf8 0%, #ffffff 100%);
  border: 1px solid rgba(214,158,46,.35);
  border-top: 3px solid #d6ae2e;
  border-radius: 22px;
  padding: 24px 22px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  text-align: center;
}
.pillar-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: #f6f2e8;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
}
.pillar-title { font-size: 18px; font-weight: 800; color: var(--navy); line-height: 1.25; margin-bottom: 8px; }
.pillar-subtitle {
  display:inline-block;
  padding:6px 12px;
  border-radius:999px;
  background:#eef1fb;
  color:#4c5b94;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.12em;
  margin-bottom:18px;
}
.pillar-metric-band {
  background:#1e2a57;
  color:#fff;
  border-radius:16px;
  padding:14px 16px;
  margin-bottom:18px;
  box-shadow:0 12px 28px rgba(30,42,87,.18);
}
.pillar-band-label, .pillar-kpi-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.14em; opacity:.8; }
.pillar-band-value { font-size:26px; font-weight:800; margin-top:4px; }
.pillar-band-foot, .pillar-kpi-foot { font-size:12px; margin-top:4px; color:#cbd5e1; }
.pillar-kpi-box {
  border:1px solid rgba(214,158,46,.35);
  border-radius:16px;
  padding:16px;
  background:linear-gradient(180deg,#fffefb 0%,#faf6ea 100%);
}
.pillar-kpi-main { font-size:34px; font-weight:800; line-height:1.1; margin-top:4px; }
.pillar-kpi-foot { color:#64748b; }

.quote-sheet-builder { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(320px,.9fr); gap:24px; align-items:start; }
.quote-sheet-preview { border:1px solid #d7dee8; border-radius:18px; padding:20px; background:#fff; box-shadow:0 10px 30px rgba(15,23,42,.06); }
.quote-sheet-hero { background:#3e5163; color:#fff; border-radius:8px 8px 0 0; padding:18px 22px; display:flex; justify-content:space-between; align-items:flex-start; }
.quote-sheet-brand { display:inline-block; background:#f5821f; color:#fff; font-weight:800; font-size:30px; letter-spacing:.02em; padding:4px 12px; line-height:1; }
.quote-sheet-brand-sub { margin-top:8px; font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; }
.quote-sheet-title { font-size:22px; font-weight:300; margin-top:8px; }
.quote-sheet-meta-grid { display:grid; grid-template-columns:180px 1fr; border-left:1px solid #ff7a2f; border-right:1px solid #ff7a2f; }
.quote-sheet-meta-label, .quote-sheet-meta-value { padding:10px 12px; border-bottom:1px solid #ff7a2f; min-height:44px; display:flex; align-items:center; }
.quote-sheet-meta-label { background:#d9d9d9; color:#294766; font-size:16px; font-weight:700; justify-content:flex-end; }
.quote-sheet-meta-value { background:#fff; font-size:16px; color:#1f2937; }
.quote-sheet-section-head { background:#ff6b2d; color:#fff; font-size:16px; font-weight:800; letter-spacing:.08em; text-align:center; padding:12px; margin-top:16px; }
.quote-sheet-license { text-align:right; padding:12px 8px; font-size:16px; font-weight:700; color:#111827; border-bottom:1px solid #ff7a2f; }
.quote-sheet-category { font-size:16px; font-weight:800; padding:8px 4px; border-bottom:1px solid #ff7a2f; color:#111827; }
.quote-sheet-row { display:grid; grid-template-columns:36px 1fr 120px 42px; gap:8px; align-items:center; border-bottom:1px solid #ff7a2f; padding:6px 0; }
.quote-sheet-row-off { opacity:.45; }
.quote-sheet-check { display:flex; justify-content:center; }
.quote-sheet-item-input, .quote-sheet-assign { border:0; background:transparent; font-size:15px; padding:4px 6px; min-width:0; }
.quote-sheet-item-input:focus, .quote-sheet-assign:focus { outline:1px solid #cbd5e1; background:#fff; border-radius:6px; }
.quote-sheet-sidepanel { border:1px solid #d7dee8; border-radius:18px; padding:18px; background:#f8fafc; }

.tl-summary { display: flex; gap: 20px; margin-bottom: 20px; }
.tl-summary-item { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }

/* ═══ PANELS / CARDS ═══ */
.panel {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.9);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.panel-header h2 { font-size: 15px; font-weight: 800; color: var(--navy); letter-spacing: -.01em; }
.panel-body { padding: 22px; }
.panel-body.compact { padding: 16px; }
.panel-body.flush { padding: 0; }

/* ═══ TABLES ═══ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 13px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 700;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
td { padding: 15px 16px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: middle; }
tbody tr:nth-child(even) td { background: rgba(248, 250, 252, 0.55); }
tr:hover td { background: #f2f7fb; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eaf2f8; }

/* Reports page table alignment */
.reports-table th.text-center,
.reports-table td.text-center {
  text-align: center !important;
}

.reports-table thead th {
  vertical-align: middle;
}

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap; letter-spacing: .2px;
}
.badge-request { background: #edf2f7; color: #4a5568; }
.badge-budgetary { background: #ebf8ff; color: #2b6cb0; }
.badge-submitted { background: #e9d8fd; color: #6b46c1; }
.badge-negotiation { background: #fefcbf; color: #975a16; }
.badge-won { background: #f0fff4; color: #276749; }
.badge-lost { background: #fff5f5; color: #c53030; }
.badge-no-quotes { background: #f7fafc; color: #a0aec0; }
.badge-call { background: var(--red); color: #fff; animation: tlPulse 2s infinite; }
.badge-follow-up { background: #fffff0; color: #975a16; }
.badge-override { background: #ebf8ff; color: var(--blue); }
.badge-sm { padding: 2px 8px; font-size: 10px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 10px; font-size: 13px; font-weight: 700;
  border: none; cursor: pointer; text-decoration: none; transition: var(--transition);
  font-family: inherit; line-height: 1; white-space: nowrap;
}
.btn-primary { background: linear-gradient(180deg, var(--navy) 0%, #223554 100%); color: #fff; box-shadow: 0 8px 20px rgba(26,39,68,.16); }
.btn-primary:hover { background: linear-gradient(180deg, var(--navy-light) 0%, #274164 100%); box-shadow: 0 10px 24px rgba(26,39,68,.2); transform: translateY(-1px); }
.btn-orange { background: linear-gradient(180deg, var(--orange) 0%, #d97706 100%); color: #fff; }
.btn-orange:hover { background: linear-gradient(180deg, var(--orange-light) 0%, #ea8f2f 100%); }
.btn-green { background: linear-gradient(180deg, var(--green) 0%, #2f855a 100%); color: #fff; }
.btn-green:hover { background: linear-gradient(180deg, #48bb78 0%, #2f855a 100%); }
.btn-red { background: linear-gradient(180deg, var(--red) 0%, #c53030 100%); color: #fff; }
.btn-red:hover { background: linear-gradient(180deg, #fc8181 0%, #e53e3e 100%); }
.btn-outline { background: rgba(255,255,255,.85); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-light); padding: 8px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 8px; min-width: 36px; }
.btn-sharepoint { background: #036c70; color: #fff; }
.btn-sharepoint:hover { background: #025a5e; }

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

/* ═══ FORMS ═══ */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-light);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }

input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date],
input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--white);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,130,206,.12);
}
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--white); border-radius: var(--radius); width: 90%; max-width: 640px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }
.modal.wide { max-width: 900px; }
.modal.xl { max-width: 1100px; }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: var(--radius-xs); transition: var(--transition); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══ TABS ═══ */
.tabs { display: flex; border-bottom: 2px solid var(--border-light); margin-bottom: 24px; gap: 4px; }
.tab {
  padding: 12px 20px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: var(--transition); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--navy); border-bottom-color: var(--orange); }

/* ═══ SEARCH BAR ═══ */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(15,23,42,.04);
}
.search-input {
  flex: 1; min-width: 240px; position: relative;
}
.search-input input { padding-left: 38px; }
.search-input::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; pointer-events: none;
}
.filter-select { width: 180px; }

/* ═══ TOGGLE SWITCH ═══ */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { display: none; }
.toggle .slider {
  width: 40px; height: 22px; background: var(--border); border-radius: 11px;
  position: relative; transition: var(--transition);
}
.toggle .slider::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: var(--white); top: 2px; left: 2px; transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::after { left: 20px; }

/* ═══ EMAIL PREVIEW ═══ */
.email-preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; font-family: 'Courier New', monospace; font-size: 13px;
  white-space: pre-wrap; line-height: 1.6; max-height: 400px; overflow-y: auto;
}

/* ═══ NOTIFICATION BADGE ═══ */
.notif-badge {
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px;
}

/* ═══ ACTIVITY TIMELINE ═══ */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--border); border: 2px solid var(--white);
}
.timeline-item.auto::before { background: var(--text-muted); }
.timeline-item.manual::before { background: var(--blue); }
.timeline-item.won::before { background: var(--green); }
.timeline-item .tl-time { font-size: 11px; color: var(--text-muted); }
.timeline-item .tl-title { font-size: 13px; font-weight: 600; margin-top: 2px; }
.timeline-item .tl-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* ═══ FOLLOW-UP ITEMS ═══ */
.fu-list { display: flex; flex-direction: column; gap: 10px; }
.fu-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  transition: var(--transition);
}
.fu-item:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.fu-item .fu-date { font-size: 13px; font-weight: 600; min-width: 100px; }
.fu-item .fu-actions { margin-left: auto; display: flex; gap: 6px; }

/* ═══ CHART AREA ═══ */
.chart-container { position: relative; height: 200px; }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 10px 0; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar .bar {
  width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .4s ease;
}
.chart-bar .bar-label { font-size: 10px; color: var(--text-muted); }
.chart-bar .bar-value { font-size: 10px; font-weight: 600; color: var(--navy); }

/* ═══ BREADCRUMB ═══ */
.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--blue); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }

/* ═══ PAGE TITLE ═══ */
.page-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title h1 { font-size: 24px; font-weight: 800; color: var(--navy); }

/* ═══ EMPTY STATE ═══ */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
  background: linear-gradient(180deg, #fbfdff 0%, #f8fafc 100%);
  border-radius: 14px;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ═══ LOADING ═══ */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--orange);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ COMPARISON ARROWS ═══ */
.change { font-size: 12px; font-weight: 600; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.change.up { color: var(--green); }
.change.down { color: var(--red); }
.change.neutral { color: var(--text-muted); }

/* ═══ UTILITIES ═══ */
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-orange { color: var(--orange); }
.text-navy { color: var(--navy); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.hidden { display: none !important; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: 'SF Mono', Menlo, monospace; }

/* ═══ RESPONSIVE ═══ */

/* The AI chat panel was a fixed 400x500px box, which overflowed the screen on
   phones. Size it to the viewport with a comfortable cap on desktop. */
#aiChatPanel {
  width: min(400px, calc(100vw - 32px));
  height: min(500px, calc(100vh - 140px));
}

/* Wide screens: stop the content sprawling into unreadably long lines while
   still filling the window. Cap only kicks in past ~1800px. */
@media (min-width: 1800px) {
  .page-content { max-width: 1720px; margin: 0 auto; }
}

@media (max-width: 768px) {
  /* The sidebar was width:0 and part of the flex row, so opening it squeezed
     the page instead of overlaying it. Slide it over the content instead. */
  .sidebar {
    width: 260px; overflow: hidden;
    transform: translateX(-260px);
    transition: transform .2s ease;
    z-index: 1100;
  }
  .sidebar.open { width: 260px; transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; width: 100%; min-width: 0; }
  .top-bar { padding: 12px 16px; }
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .pillar-grid { grid-template-columns: 1fr; gap: 14px; }
  .pillar-card { padding: 18px 16px; border-radius: 18px; }
  .pillar-band-value { font-size: 22px; }
  .pillar-kpi-main { font-size: 28px; }
  .quote-sheet-builder { grid-template-columns: 1fr; }
  .quote-sheet-meta-grid { grid-template-columns: 1fr; }
  .quote-sheet-meta-label { justify-content: flex-start; }
  .quote-sheet-row { grid-template-columns: 28px 1fr; }
  .quote-sheet-assign { grid-column: 2; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
  .search-bar { flex-direction: column; }
  .search-input { min-width: auto; }
  .filter-select { width: 100%; }
  .hamburger { display: block; }

  /* Modals sat centred at 90% width with 5% margins that vanished on small
     screens. Pin them to the bottom as a sheet, which is easier to reach. */
  .modal-overlay { align-items: flex-end; }
  .modal, .modal.wide, .modal.xl, .modal-lg {
    width: 100%; max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .modal-header { position: sticky; top: 0; background: var(--white); z-index: 2; }

  /* Calendar cells at min-height:100px in a 7-column grid forced the page
     wider than the screen. Let it scroll sideways as a unit instead. */
  .cal-grid { min-width: 640px; }
  .cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cal-cell { min-height: 72px; padding: 6px; }

  /* Give scrollable tables momentum scrolling on touch. */
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* iOS zooms the whole page when focusing an input under 16px. */
  input, select, textarea { font-size: 16px; }
}

/* Tablets and small laptops: two-up stat cards read better than four cramped ones. */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-content { padding: 20px 22px; }
}

@media (min-width: 769px) {
  .hamburger { display: none; }
}

.hamburger {
  background: none; border: none; font-size: 24px; cursor: pointer; color: var(--navy); padding: 4px;
}

/* ═══ CALENDAR ═══ */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border-light); }
.cal-header { padding: 10px; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); background: var(--bg); }
.cal-cell { background: var(--white); padding: 8px; min-height: 100px; }
.cal-cell.empty { background: var(--bg); }
.cal-cell.today { background: #fffff0; }
.cal-cell.has-items { background: #fafffe; }
.cal-day { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-light); }
.cal-cell.today .cal-day { color: var(--orange); font-weight: 700; }
.cal-item { padding: 4px 6px; margin-bottom: 3px; border-radius: 4px; background: var(--bg); font-size: 11px; cursor: pointer; }
.cal-item:hover { background: #edf2f7; }

/* ═══ ACTIVITY TIMELINE ═══ */
.activity-timeline { position: relative; padding-left: 24px; }
.activity-timeline::before { content: ''; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--border-light); }
.activity-item { position: relative; padding-bottom: 16px; }
.activity-dot { position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--border); border: 2px solid var(--white); }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-purple { background: var(--purple); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--text-muted); }
.activity-content { padding-left: 4px; }
.activity-title { font-size: 13px; }
.activity-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.activity-meta { margin-top: 2px; }

/* ═══ INLINE EDITS ═══ */
.inline-input { border: 1px solid var(--border); padding: 10px 12px; border-radius: 6px; font-size: 14px; font-family: inherit; background: var(--white); color: var(--text); min-width: 80px; }
.inline-input:focus { border-color: var(--blue); background: var(--white); outline: none; box-shadow: 0 0 0 3px rgba(49,130,206,.12); }
.inline-select { border: 1px solid var(--border); padding: 10px 12px; border-radius: 6px; font-size: 14px; font-family: inherit; background: var(--white); color: var(--text); min-width: 80px; }
.inline-select:focus { border-color: var(--blue); background: var(--white); box-shadow: 0 0 0 3px rgba(49,130,206,.12); }

/* ═══ TAGS ═══ */
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; background: #edf2f7; color: #4a5568; font-size: 10px; font-weight: 600; margin: 1px; }

/* ═══ PROJECT HEADER ═══ */
.project-header { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border-light); }
.project-command-header { padding: 28px; }
.project-command-main { display:flex; justify-content:space-between; align-items:flex-start; gap:24px; }
.project-kicker { font-size:11px; text-transform:uppercase; letter-spacing:.16em; color:#718096; font-weight:700; margin-bottom:10px; }
.project-title-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.project-title-row h2 { margin:0; font-size:30px; color:var(--navy); }
.project-header-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.project-meta { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-light); }
.project-command-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-top:22px; }
.command-card { background:linear-gradient(180deg,#f8fafc 0%,#ffffff 100%); border:1px solid var(--border); border-radius:16px; padding:18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.command-card-warn { border-color:#f6ad55; background:linear-gradient(180deg,#fffaf0 0%,#ffffff 100%); }
.command-label { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.12em; color:#718096; }
.command-value { font-size:30px; font-weight:800; color:var(--navy); margin-top:4px; line-height:1.1; }
.command-value-sm { font-size:20px; }
.command-foot { margin-top:6px; font-size:12px; color:#718096; }
.project-layout-grid { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(320px,.9fr); gap:24px; align-items:start; }
.project-main-column, .project-side-column { min-width:0; }
.project-side-panel .panel-body { padding:20px; }
.project-financials-compact { grid-template-columns:1fr 1fr; }

/* ═══ PROJECT DETAIL TABS ═══ */
.project-tab-bar { display:flex; gap:4px; flex-wrap:wrap; border-bottom:2px solid #e2e8f0; margin-bottom:20px; }
.project-tab {
  appearance:none; border:none; background:transparent; cursor:pointer;
  font-family:inherit; font-size:14px; font-weight:700; color:var(--navy, #1a2744);
  padding:12px 20px; border-radius:10px 10px 0 0; margin-bottom:-2px;
  border-bottom:3px solid transparent; transition:color .15s ease, border-color .15s ease, background .15s ease;
}
.project-tab:hover { background:#f1f5f9; }
.project-tab.active { color:#e97c2e; border-bottom-color:#e97c2e; }
.project-tab-panel { display:none; }
.project-tab-panel.active { display:block; animation:tabFade .18s ease; }
@keyframes tabFade { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ═══ MODAL-LG ═══ */
.modal-lg { max-width: 800px; }

/* ═══ BTN SUCCESS/DANGER ═══ */
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #48bb78; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: .85; }

/* ═══ BADGE WARNING ═══ */
.badge-warning { background: #fffff0; color: #975a16; }

/* ═══ FORM CONTROL ═══ */
.form-control { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,130,206,.12); }

/* ═══ NOTES & SCHEDULE TABLES ═══ */
.notes-table { width: 100%; border-collapse: collapse; }
.notes-table th { text-align: left; padding: 8px 10px; background: var(--bg-subtle); font-size: 12px; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.notes-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.notes-table textarea.inline-input { resize: vertical; font-size: 13px; line-height: 1.5; }
.disabled-row { opacity: 0.4; }
.disabled-row input, .disabled-row textarea, .disabled-row select { pointer-events: none; }
.text-red { color: var(--red) !important; }
.mb-2 { margin-bottom: 16px; }
.mt-2 { margin-top: 16px; }
h3 { font-size: 15px; font-weight: 600; color: var(--text); }

/* Stage select dropdown */
.stage-select {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  appearance: auto;
  min-width: 150px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.stage-select:focus { outline: none; border-color: #e8841a; }
.stage-select.stage-tender-request { background: #ebf5fb; color: #2980b9; border-color: #bee3f8; }
.stage-select.stage-budgetary { background: #fef9e7; color: #d69e2e; border-color: #feebc8; }
.stage-select.stage-tender-submitted { background: #e8f8f5; color: #38a169; border-color: #c6f6d5; }
.stage-select.stage-won-by-client { background: #e8f8f5; color: #22543d; border-color: #38a169; }
.stage-select.stage-lost-by-client { background: #fef2f2; color: #e53e3e; border-color: #feb2b2; }

/* Financials grid */
.financials-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
}
.fin-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  border: 1px solid #e2e8f0;
}
.fin-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #718096;
  margin-bottom: 8px;
  font-weight: 600;
}
.fin-value {
  font-size: 22px;
  font-weight: 700;
  color: #1a2744;
}
.fin-editable {
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  border-radius: 6px;
  padding: 2px 6px;
}
.fin-editable:hover {
  background: #e2e8f0;
}
.fin-edit-icon {
  font-size: 12px;
  margin-left: 4px;
  opacity: 0.4;
}
.fin-editable:hover .fin-edit-icon {
  opacity: 1;
}
.fin-gp {
  font-weight: 800;
}
@media (max-width: 768px) {
  .financials-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1200px) {
  .project-command-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .project-layout-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .project-command-main { flex-direction: column; }
  .project-header-actions { justify-content: flex-start; }
  .project-command-grid { grid-template-columns: 1fr; }
  .project-title-row h2 { font-size: 24px; }
  .project-financials-compact { grid-template-columns: 1fr; }
}

/* Lost quote rows fade into background */
.quote-lost-row {
  opacity: 0.4;
  background: #f7f7f7 !important;
}
.quote-lost-row:hover {
  opacity: 0.7;
}

/* Won by Fencepac badge - gold/premium */
.badge-won-fp {
  background: linear-gradient(135deg, #f6e05e, #d69e2e) !important;
  color: #744210 !important;
  font-weight: 700;
}

/* Stage select colors for new stages */
.stage-select.stage-won-by-fencepac { background: #fefcbf; color: #744210; border-color: #f6e05e; }
.stage-select.stage-lost { background: #fef2f2; color: #e53e3e; border-color: #feb2b2; }
.stage-select.stage-lost-by-fencepac { background: #fef2f2; color: #e53e3e; border-color: #feb2b2; }
.stat-box { background:#f7fafc; border:1px solid #e2e8f0; border-radius:8px; padding:10px 12px; text-align:center; }
.stat-box .fw-600 { font-size:16px; margin-top:2px; }

/* Communications log (Follow-Up tab) */
.comm-timeline { display:flex; flex-direction:column; gap:12px; }
.comm-item { border:1px solid #e2e8f0; border-left:4px solid #cbd5e1; border-radius:8px; padding:12px 14px; background:#fff; }
.comm-item.comm-incoming { border-left-color:#3182ce; background:#f7fbff; }
.comm-item.comm-outgoing { border-left-color:#38a169; background:#f7fdf9; }
.comm-item.comm-internal { border-left-color:#a0aec0; background:#fafafa; }
.comm-item-head { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.comm-type { font-weight:600; font-size:14px; }
.comm-dir { font-size:11px; font-weight:600; padding:2px 8px; border-radius:10px; }
.comm-dir-in { background:#bee3f8; color:#2c5282; }
.comm-dir-out { background:#c6f6d5; color:#276749; }
.comm-dir-int { background:#e2e8f0; color:#4a5568; }
.comm-src { font-size:10px; text-transform:uppercase; letter-spacing:.04em; background:#faf089; color:#744210; padding:2px 6px; border-radius:4px; }
.comm-when { margin-left:auto; }
.comm-actions { display:flex; gap:4px; }
.comm-subject { margin-top:6px; }
.comm-who { margin-top:2px; }
.comm-body { margin-top:6px; line-height:1.5; color:#2d3748; }
.comm-meta { margin-top:6px; }
.form-grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* Division multi-select checkboxes (estimator/admin people) */
.division-checkboxes { display:flex; flex-wrap:wrap; gap:8px; }
.division-check { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border:1px solid #e2e8f0; border-radius:8px; background:#f8fafc; font-size:13px; cursor:pointer; }
.division-check input { margin:0; }
