:root {
  --bg: #f8f9fb;
  --white: #fff;
  --text: #1a2332;
  --muted: #5f6b7a;
  --border: #e2e5ea;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --cw-tag: #7c3aed;
  --cw-tag-light: #f5f3ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 4px rgba(0,0,0,.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing:border-box; margin:0; }
body { -webkit-font-smoothing:antialiased; }
button,input,textarea { font:inherit; }
button { cursor:pointer; border:0; }
input,textarea { outline:none; width:100%; }

.shell { max-width:720px; margin:0 auto; padding:12px 16px; display:grid; gap:10px; }

.topbar {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 18px; background:var(--white); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow); gap:8px; flex-wrap:wrap;
}
.topbar .brand { font-weight:700; font-size:14px; color:var(--text); }
.topbar .brand span { color:var(--accent); }

.pills { display:flex; gap:6px; }
.pill {
  display:inline-flex; align-items:center; gap:5px;
  padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600;
}
.pill.on { background:var(--green-light); color:var(--green); }
.pill.off { background:var(--red-light); color:var(--red); }
.dot { width:6px; height:6px; border-radius:50%; }
.dot.on { background:var(--green); }
.dot.off { background:var(--red); }

.card {
  background:var(--white); border:1px solid var(--border);
  border-radius:var(--radius); padding:16px; box-shadow:var(--shadow);
}

.search-row { display:flex; gap:8px; align-items:center; }
.search-row input {
  flex:1; min-width:0; padding:10px 14px; border:1px solid var(--border);
  border-radius:var(--radius-sm); background:var(--bg); color:var(--text);
}
.search-row input:focus { border-color:var(--accent); background:var(--white); }
.search-row .btn { flex-shrink:0; }

.btn {
  display:inline-flex; align-items:center; gap:5px;
  padding:10px 18px; border-radius:var(--radius-sm); font-weight:600; font-size:13px;
  transition: all .15s; white-space:nowrap;
}
.btn.primary { background:var(--accent); color:#fff; }
.btn.primary:hover { background:#1d4ed8; }
.btn.ghost { background:var(--white); border:1px solid var(--border); color:var(--text); }
.btn.ghost:hover { background:var(--bg); border-color:var(--accent); }
.btn.danger { background:var(--white); border:1px solid #fecaca; color:var(--red); font-size:12px; padding:6px 12px; }
.btn.sm { font-size:12px; padding:6px 12px; }
.btn:disabled { opacity:.4; cursor:not-allowed; }

.chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.chip {
  display:inline-flex; align-items:center; gap:4px;
  padding:3px 10px; border-radius:20px; font-size:12px;
  border:1px solid var(--border); background:var(--white); color:var(--text);
}
.chip.muted { color:var(--muted); border-style:dashed; }
.chip.cw {
  background:var(--cw-tag-light); border-color:var(--cw-tag);
  color:var(--cw-tag); font-weight:600;
}

.message {
  padding:8px 12px; border-radius:var(--radius-sm); font-size:12px; margin-top:8px;
}
.message.warn { background:var(--amber-light); color:var(--amber); }
.message.error { background:var(--red-light); color:var(--red); }
.message.success { background:var(--green-light); color:var(--green); }
.message.hidden { display:none; }

.section-title {
  font-size:11px; font-weight:800; text-transform:uppercase;
  letter-spacing:.08em; color:var(--muted); margin:4px 0 8px;
}
.grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }

.partner-name { font-size:18px; font-weight:750; letter-spacing:-.02em; }
.partner-id { font-size:13px; color:var(--muted); font-weight:400; }
.partner-meta { font-size:13px; color:var(--muted); margin:4px 0 10px; display:grid; gap:2px; }
.partner-meta strong { color:var(--text); }
.actions { display:flex; gap:6px; flex-wrap:wrap; }

.opp-card {
  background:var(--white); border:1px solid var(--border);
  border-radius:var(--radius); padding:14px; box-shadow:var(--shadow);
  display:grid; gap:8px;
}
.opp-card .opp-title { font-weight:700; font-size:13px; }
.opp-card .opp-stage {
  font-size:11px; font-weight:600; color:var(--accent);
  background:var(--accent-light); padding:2px 8px; border-radius:12px; width:max-content;
}
.opp-card .opp-meta { font-size:12px; color:var(--muted); display:flex; gap:10px; flex-wrap:wrap; }
.opp-card .opp-actions { display:flex; gap:6px; flex-wrap:wrap; }

.record-item {
  border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:12px; background:var(--bg);
}
.record-item .rec-title { font-weight:700; font-size:13px; }
.record-item .rec-meta { font-size:12px; color:var(--muted); margin-top:3px; }
.rec-title .tag {
  font-size:10px; font-weight:800; padding:1px 6px; border-radius:8px;
  margin-left:6px; vertical-align:middle;
}
.rec-title .tag.cw { background:var(--cw-tag-light); color:var(--cw-tag); }

.overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.3); z-index:1000;
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.overlay.hidden { display:none; }
.overlay-card {
  background:var(--white); border-radius:14px; padding:24px; width:100%; max-width:440px;
  box-shadow:0 20px 60px rgba(0,0,0,.12); display:grid; gap:14px;
}
.overlay-card h3 { font-size:16px; letter-spacing:-.02em; }
.field { display:grid; gap:4px; }
.field label { font-size:12px; font-weight:600; color:var(--muted); }
.field input, .field textarea {
  width:100%; padding:9px 12px; border:1px solid var(--border);
  border-radius:var(--radius-sm); background:var(--bg); color:var(--text);
}
.field input:focus, .field textarea:focus { border-color:var(--accent); background:var(--white); }
.field textarea { resize:vertical; min-height:60px; }
.flex-row { display:flex; gap:10px; }
.flex-end { display:flex; gap:8px; justify-content:flex-end; }
.empty { color:var(--muted); font-size:13px; }
.hidden { display:none; }

/* ---- Quotation / Product Search ---- */

.product-grid {
  display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr));
  gap:8px; padding-top:8px; max-height:360px; overflow-y:auto;
}

.prod-card {
  display:flex; gap:10px; align-items:flex-start; padding:8px;
  border:1px solid var(--border); border-radius:var(--radius-sm);
  background:var(--white); cursor:pointer; transition:box-shadow .15s;
}
.prod-card:hover { box-shadow:var(--shadow); }
.prod-card img { width:56px; height:56px; object-fit:cover; border-radius:6px; flex-shrink:0; }
.prod-noimg {
  width:56px; height:56px; border-radius:6px; flex-shrink:0;
  background:var(--bg); display:flex; align-items:center; justify-content:center;
  font-size:10px; color:var(--muted);
}
.prod-info { flex:1; min-width:0; }
.prod-name { font-weight:600; font-size:13px; line-height:1.3; }
.prod-meta { font-size:11px; color:var(--muted); margin-top:2px; }

/* ---- Lines Table ---- */

.table-wrap { overflow-x:auto; }
.lines-table { width:100%; border-collapse:collapse; font-size:13px; }
.lines-table th {
  text-align:left; padding:6px 8px; font-size:11px; font-weight:600;
  color:var(--muted); border-bottom:1px solid var(--border); white-space:nowrap;
}
.lines-table td { padding:6px 8px; border-bottom:1px solid var(--border); }
.lines-table .num { text-align:right; font-variant-numeric:tabular-nums; }
.prod-label { font-weight:600; font-size:13px; }
.prod-code { font-size:11px; color:var(--muted); }
.qty-inp, .price-inp {
  width:80px; padding:4px 6px; border:1px solid var(--border);
  border-radius:4px; text-align:right; font-size:13px;
}

/* ---- Totals ---- */

.totals { margin-top:12px; border-top:1px solid var(--border); padding-top:8px; }
.total-row {
  display:flex; justify-content:space-between; padding:3px 0; font-size:13px;
}
.total-row.muted { color:var(--muted); }
.total-final { font-weight:700; font-size:15px; padding-top:6px; border-top:1px solid var(--border); margin-top:4px; }

/* ---- Quotation list ---- */

.quot-card { margin-bottom:8px; }
.quot-name { font-weight:700; font-size:14px; }
.quot-total { font-weight:700; font-size:16px; color:var(--accent); margin-top:2px; }

/* ---- Success button ---- */

.btn.success {
  background:var(--green); color:#fff; font-weight:500; border-radius:var(--radius-sm);
  padding:8px 14px; font-size:13px;
}
.btn.success:hover { opacity:.9; }

@media (max-width:600px) {
  .grid { grid-template-columns:1fr; }
  .search-row { flex-direction:column; align-items:stretch; }
  .overlay-card { padding:18px; }
  .product-grid { grid-template-columns:1fr; }
}
