:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #25364f;
  --brand-2: #e58c27;
  --brand-soft: #fff3e4;
  --good: #127c56;
  --bad: #b42318;
  --warn: #9a6700;
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  background: linear-gradient(180deg, #172235 0%, #263850 100%);
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; background: var(--brand-2); display: grid; place-items: center; font-weight: 900; font-size: 22px; box-shadow: 0 12px 24px rgba(229, 140, 39, .25); }
.brand h1 { font-size: 19px; line-height: 1.1; margin: 0; }
.brand p { margin: 3px 0 0; color: rgba(255,255,255,.72); font-size: 12px; }
.nav { display: grid; gap: 8px; }
.nav button {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.76);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav button:hover, .nav button.active { background: rgba(255,255,255,.11); color: #fff; }
.nav small { color: rgba(255,255,255,.55); }
.sidebar-card { margin-top: 22px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 14px; background: rgba(255,255,255,.07); }
.sidebar-card p { margin: 0; color: rgba(255,255,255,.72); font-size: 13px; }
.main { padding: 28px; max-width: 1500px; width: 100%; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { color: var(--brand-2); text-transform: uppercase; font-weight: 800; letter-spacing: .08em; font-size: 12px; margin: 0 0 6px; }
h2 { font-size: 30px; line-height: 1.12; margin: 0; }
.lead { color: var(--muted); margin: 9px 0 0; max-width: 860px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 13px;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(17,24,39,.04);
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.dark { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { background: #fff5f5; color: var(--bad); border-color: #fecaca; }
.btn.good { background: #ecfdf5; color: var(--good); border-color: #bbf7d0; }
.btn.small { padding: 7px 10px; border-radius: 10px; font-size: 13px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.tight { padding: 12px; }
.stat { min-height: 122px; display: flex; flex-direction: column; justify-content: space-between; }
.stat .num { font-size: 34px; font-weight: 900; }
.stat .label { color: var(--muted); }
.stat.accent { background: linear-gradient(135deg, var(--brand) 0%, #334d70 100%); color: white; }
.stat.accent .label { color: rgba(255,255,255,.74); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h3 { margin: 0; font-size: 18px; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.table-wrap { width: 100%; overflow: auto; border-radius: 14px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: #475569; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.badge.Draft { background: #f1f5f9; color: #334155; }
.badge.Locked { background: #fff7ed; color: #9a3412; }
.badge.Sent { background: #eff6ff; color: #1d4ed8; }
.badge.Accepted { background: #ecfdf5; color: #047857; }
.badge.Declined { background: #fef2f2; color: #b91c1c; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 800; }
.pill.off { background: #fef2f2; color: #991b1b; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; grid-column: span 6; }
.field.full { grid-column: 1 / -1; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
label { color: #374151; font-size: 13px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d6dbe3;
  border-radius: 12px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(229, 140, 39, .18); border-color: var(--brand-2); }
.help { color: var(--muted); font-size: 12px; margin: 0; }
.check-list { display: grid; gap: 9px; max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 6px; border-radius: 9px; }
.check-row:hover { background: #f8fafc; }
.check-row input { width: auto; }
.quote-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) 420px; gap: 18px; align-items: start; }
.sticky { position: sticky; top: 20px; }
.total-box { background: linear-gradient(135deg, #172235, #2f4665); color: #fff; border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.total-box p { margin: 0; color: rgba(255,255,255,.72); }
.total-box strong { display: block; font-size: 34px; margin-top: 3px; }
.breakdown { display: grid; gap: 8px; }
.breakdown-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 8px 0; font-size: 14px; }
.breakdown-row:last-child { border-bottom: 0; }
.breakdown-row strong { text-align: right; }
.muted { color: var(--muted); }
.inline-note { padding: 12px 14px; background: var(--brand-soft); border: 1px solid #fed7aa; border-radius: 14px; color: #7c2d12; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.62); display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 22px; width: min(920px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.toast { position: fixed; bottom: 22px; right: 22px; z-index: 80; display: none; background: #111827; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); max-width: 380px; }
.toast.show { display: block; }
.customer-page { background: #fff; min-height: 100vh; padding: 38px 18px; }
.customer-quote { max-width: 900px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.customer-head { background: linear-gradient(135deg, #172235, #2f4665); color: #fff; padding: 28px; display: flex; justify-content: space-between; gap: 20px; }
.customer-head h1 { margin: 0 0 7px; font-size: 28px; }
.customer-head p { margin: 0; color: rgba(255,255,255,.75); }
.customer-body { padding: 28px; }
.quote-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; margin-bottom: 22px; }
.info-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.info-box h4 { margin: 0 0 8px; color: #334155; }
.big-total { text-align: right; font-size: 32px; font-weight: 900; color: var(--brand); }
.print-only { display: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f8fafc; }
.photo img { width: 100%; height: 100px; object-fit: cover; display: block; }
.photo small { display: block; padding: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-form { margin-bottom: 18px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 16px; background: #f8fafc; }
.linklike { color: #1d4ed8; word-break: break-all; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .quote-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .main { padding: 18px; }
  .topbar { flex-direction: column; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .field, .field.third, .field.quarter { grid-column: 1 / -1; }
  .customer-head, .quote-meta { grid-template-columns: 1fr; display: grid; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .actions, .no-print, .toast, .btn { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; max-width: none; }
  .customer-page { padding: 0; }
  .customer-quote { box-shadow: none; border: 0; border-radius: 0; }
  .customer-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
}
