/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #185FA5;
  --blue-light: #E6F1FB;
  --blue-dark:  #0C447C;
  --green:      #3B6D11;
  --green-light:#EAF3DE;
  --amber:      #854F0B;
  --amber-light:#FAEEDA;
  --red:        #A32D2D;
  --red-light:  #FCEBEB;
  --gray-50:    #F8F8F7;
  --gray-100:   #F1EFEA;
  --gray-200:   #E0DED7;
  --gray-400:   #9A9890;
  --gray-600:   #5F5E58;
  --gray-900:   #1C1C1A;
  --border:     rgba(0,0,0,0.1);
  --border-md:  rgba(0,0,0,0.15);
  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-w:  220px;
}

html, body { height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--gray-900); background: var(--gray-100); line-height: 1.5; }

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

/* ─── App Shell ─────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform 0.2s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px; height: 32px;
  background: var(--blue);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

.brand-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.brand-sub  { font-size: 11px; color: var(--gray-400); }

.nav { padding: 12px 8px; flex: 1; }
.nav-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px 4px;
  margin-bottom: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--gray-600);
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.nav-item:hover  { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }

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

/* ─── Main Content ──────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date  { font-size: 12px; color: var(--gray-400); }
.page-title   { font-size: 16px; font-weight: 600; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--gray-600); padding: 6px;
  border-radius: var(--radius-sm);
  display: none;
}
.sidebar-toggle:hover { background: var(--gray-100); }

.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px; font-family: var(--font);
  cursor: pointer;
  border: 1px solid var(--border-md);
  background: white; color: var(--gray-900);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-100); }
.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-success { background: var(--green); color: white; border-color: var(--green); }
.btn-success:hover { background: #2A5009; }
.btn-danger  { background: var(--red-light); color: var(--red); border-color: #F09595; }
.btn-danger:hover  { background: #F7C1C1; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body  { padding: 18px; }

/* ─── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--gray-400); margin-bottom: 6px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--gray-900); }
.stat-sub   { font-size: 11px; color: var(--gray-400); margin-top: 3px; }

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── Tables ────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 10px 18px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover td { background: var(--gray-50); }

.empty-state { text-align: center; color: var(--gray-400); padding: 24px !important; font-size: 13px; }

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-blue   { background: var(--blue-light);  color: var(--blue); }
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-amber  { background: var(--amber-light); color: var(--amber); }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-gray   { background: var(--gray-100);    color: var(--gray-600); }

/* ─── Avatar ────────────────────────────────────────────────── */
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.av-blue   { background: var(--blue-light);  color: var(--blue); }
.av-teal   { background: #E1F5EE; color: #0F6E56; }
.av-purple { background: #EEEDFE; color: #534AB7; }
.av-coral  { background: #FAECE7; color: #993C1D; }

.person-cell { display: flex; align-items: center; gap: 10px; }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label  { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-full   { grid-column: 1 / -1; }

input[type=text], input[type=email], input[type=number], input[type=date],
input[type=tel], select, textarea {
  padding: 8px 11px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-md);
  font-size: 13px; font-family: var(--font);
  background: white; color: var(--gray-900);
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24,95,165,0.12);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select { cursor: pointer; }

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 640px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.modal-wide { width: 880px; }
.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--gray-400);
  padding: 2px 8px; border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
.modal-body   { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: 0; background: white; z-index: 1;
}

/* ─── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header-left h2 { font-size: 20px; font-weight: 600; }
.page-header-left p  { font-size: 13px; color: var(--gray-400); margin-top: 2px; }
.page-header-right   { display: flex; gap: 8px; align-items: center; }

/* ─── Pipeline Board ────────────────────────────────────────── */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(200px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.pipeline-col {
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 300px;
}
.pipeline-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pipeline-col-title { font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.07em; }
.pipeline-col-count { font-size: 11px; color: var(--gray-400); }
.deal-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s;
}
.deal-card:hover { border-color: var(--blue); box-shadow: var(--shadow-sm); }
.deal-name    { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.deal-company { font-size: 12px; color: var(--gray-400); margin-bottom: 8px; }
.deal-value   { font-size: 14px; font-weight: 600; color: var(--blue); }
.deal-meta    { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.deal-date    { font-size: 11px; color: var(--gray-400); }

/* ─── Product / Inventory Cards ─────────────────────────────── */
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.product-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.product-card:hover { border-color: var(--blue); box-shadow: var(--shadow-sm); }
.product-img {
  width: 100%; height: 160px;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-img-placeholder { color: var(--gray-400); }
.img-count { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.5); color: white; font-size: 11px; padding: 2px 7px; border-radius: 20px; }
.product-body { padding: 14px; }
.product-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.product-short { font-size: 12px; color: var(--gray-400); margin-bottom: 10px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-footer { display: flex; align-items: center; justify-content: space-between; }
.product-price { font-size: 15px; font-weight: 600; color: var(--blue); }
.product-unit  { font-size: 11px; color: var(--gray-400); font-weight: 400; }

/* ─── Proposal Preview ──────────────────────────────────────── */
.proposal-cover {
  background: var(--blue-dark); color: white;
  padding: 48px 48px 40px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.proposal-section { padding: 36px 48px; border-bottom: 1px solid var(--border); }
.proposal-section:last-child { border-bottom: none; }

/* ─── Line Items ────────────────────────────────────────────── */
.li-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.li-table th { padding: 9px 14px; background: var(--gray-50); font-size: 11px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; text-align: left; }
.li-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.li-table tr:last-child td { border-bottom: none; }
.li-table input { border: none; background: transparent; font-size: 13px; font-family: var(--font); width: 100%; }
.li-table input:focus { background: var(--gray-50); border-radius: 4px; padding: 2px 4px; outline: none; }
.totals-section { display: flex; justify-content: flex-end; padding: 16px 0 0; gap: 0; }
.totals-col { display: flex; flex-direction: column; gap: 8px; min-width: 260px; }
.tot-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.tot-label { color: var(--gray-400); }
.tot-value { font-weight: 600; }
.tot-grand { border-top: 1px solid var(--border-md); padding-top: 10px; margin-top: 4px; }
.tot-grand .tot-label { font-weight: 600; color: var(--gray-900); font-size: 14px; }
.tot-grand .tot-value { font-size: 18px; color: var(--blue); }

/* ─── Signature canvas ──────────────────────────────────────── */
.sig-canvas {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius-md);
  display: block; cursor: crosshair;
  touch-action: none; width: 100%; height: 110px;
  background: white;
}
.sig-done {
  background: var(--green-light); border: 1px solid #97C459;
  border-radius: var(--radius-md); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
}

/* ─── Category tabs ─────────────────────────────────────────── */
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.cat-tab {
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-md);
  background: white; color: var(--gray-600);
  transition: all 0.12s;
}
.cat-tab:hover  { background: var(--gray-100); }
.cat-tab.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ─── Dropdown (line item picker) ───────────────────────────── */
.dropdown-wrap { position: relative; flex: 1; }
.dropdown-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white; border: 1px solid var(--border-md);
  border-radius: var(--radius-md); z-index: 50;
  max-height: 260px; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.dropdown-list.hidden { display: none; }
.dd-item {
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.dd-item:last-child { border-bottom: none; }
.dd-item:hover { background: var(--gray-50); }
.dd-thumb { width: 36px; height: 36px; border-radius: var(--radius-sm); overflow: hidden; background: var(--gray-100); flex-shrink: 0; }
.dd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dd-info { display: flex; gap: 10px; align-items: center; }
.dd-name { font-weight: 600; font-size: 13px; }
.dd-sub  { font-size: 11px; color: var(--gray-400); }
.dd-price { color: var(--blue); font-weight: 600; font-size: 13px; flex-shrink: 0; }

/* ─── Toast notification ────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--gray-900); color: white;
  padding: 12px 20px; border-radius: var(--radius-md);
  font-size: 13px; z-index: 9999;
  animation: slideup 0.2s ease;
  max-width: 320px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes slideup { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Proposal tabs ─────────────────────────────────────────── */
.prop-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 22px; background: white; }
.prop-tab {
  padding: 12px 16px; font-size: 13px; cursor: pointer;
  color: var(--gray-400); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.12s;
}
.prop-tab:hover { color: var(--gray-900); }
.prop-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ─── AI Panel ──────────────────────────────────────────────── */
.ai-panel {
  background: linear-gradient(135deg, var(--blue-light) 0%, #EEEDFE 100%);
  border: 1px solid #B5D4F4;
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px;
}
.ai-panel-title { font-size: 13px; font-weight: 600; color: var(--blue); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.ai-panel-desc  { font-size: 12px; color: var(--blue); opacity: 0.8; margin-bottom: 12px; }
.ai-input-row   { display: flex; gap: 8px; }
.ai-input-row input { flex: 1; border-color: #B5D4F4; }
.dot-pulse { display: flex; gap: 4px; align-items: center; }
.dot-pulse span { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: dp 1.2s infinite; }
.dot-pulse span:nth-child(2) { animation-delay: 0.2s; }
.dot-pulse span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dp { 0%,80%,100%{opacity:0.2;transform:scale(0.8)} 40%{opacity:1;transform:scale(1)} }

/* ─── Link share box ────────────────────────────────────────── */
.share-link-box {
  background: var(--gray-50); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.share-link-url { font-size: 12px; color: var(--blue); word-break: break-all; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .two-col-grid { grid-template-columns: 1fr; }
  .pipeline-board { grid-template-columns: repeat(5, 200px); }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .content-area { padding: 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ─── Print styles (PDF generation) ────────────────────────── */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  .proposal-wrap { box-shadow: none; border: none; max-width: 100%; margin: 0; }
  .proposal-cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { margin: 0; size: A4; }
}
