/* ============ DrawLine Prototype — theme: purple sidebar SaaS ============ */
:root {
  --purple: #5b43c9;
  --purple-deep: #4a2fb0;
  --purple-soft: #efecfb;
  --coral: #f97066;
  --coral-dark: #e35a4f;
  --ink: #221d4e;
  --muted: #8a88a3;
  --bg: #f4f5fb;
  --card: #ffffff;
  --line: #ececf4;
  --green: #22b07d;
  --teal: #27a3a0;
  --amber: #f0a12f;
  --red: #e5484d;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(38, 27, 105, 0.07);
  --font: "Poppins", "Inter", -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px; flex: 0 0 228px;
  background: linear-gradient(180deg, #5d44cf 0%, #4a2fb0 100%);
  color: #fff; padding: 26px 16px; display: flex; flex-direction: column;
  border-radius: 0 28px 28px 0; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0 8px 22px; }
.brand .brand-logo { background: #eceef4; border-radius: 14px; padding: 10px 14px; }
.brand .brand-logo img { width: 100%; display: block; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  color: rgba(255,255,255,.78); text-decoration: none; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; transition: all .15s;
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: #fff; color: var(--purple); font-weight: 600; }

/* hover flyout sub-nav */
.nav .nav-group { position: relative; }
.nav .group-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  color: rgba(255,255,255,.78); border-radius: 12px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.nav .group-head svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav .nav-group:hover .group-head, .nav .group-head.active-group { background: rgba(255,255,255,.12); color: #fff; }
.nav .chev { margin-left: auto; font-size: 15px; opacity: .7; }
.nav .nav-group:hover .chev { opacity: 1; }
/* invisible bridge so the pointer can cross the gap to the flyout */
.nav .nav-group::after { content: ""; position: absolute; left: 100%; top: 0; width: 22px; height: 100%; }
.nav .sub-flyout {
  position: absolute; left: calc(100% + 14px); top: -10px; z-index: 40;
  background: #fff; border-radius: 14px; box-shadow: 0 16px 44px rgba(38,27,105,.22);
  min-width: 205px; padding: 8px; display: none; flex-direction: column; gap: 2px;
}
.nav .nav-group:hover .sub-flyout { display: flex; }
.nav .sub-flyout .fly-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 700; padding: 7px 12px 5px;
}
.nav .sub-flyout a { color: var(--ink); padding: 9px 12px; border-radius: 9px; font-size: 13px; text-decoration: none; display: flex; align-items: center; }
.nav .sub-flyout a:hover { background: var(--purple-soft); color: var(--purple); }
.nav .sub-flyout a.active { background: var(--purple-soft); color: var(--purple); font-weight: 600; }

.side-card {
  margin-top: auto; background: rgba(255,255,255,.12); border-radius: 16px;
  padding: 14px; text-align: center; font-size: 11.5px; color: rgba(255,255,255,.85);
}
.side-card .logo-card {
  background: #fff; border-radius: 10px; padding: 8px 10px; margin-top: 8px;
}
.side-card img { width: 100%; display: block; }
.side-card .hint { margin-top: 8px; opacity: .65; line-height: 1.4; }

.main { flex: 1; padding: 26px 32px 40px; min-width: 0; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.topbar h1 { font-size: 24px; font-weight: 700; }
.search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 12px; padding: 9px 14px;
  box-shadow: var(--shadow); width: 240px; color: var(--muted);
}
.search input { border: 0; outline: 0; font-family: inherit; font-size: 13px; width: 100%; background: transparent; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,#7b63e8,#5b43c9);
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .name { font-weight: 600; font-size: 13px; }
.user-chip .role { font-size: 11px; color: var(--muted); }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 20px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: -10px; margin-bottom: 14px; }
.grid { display: grid; gap: 20px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.span-2-1 { grid-template-columns: 2fr 1fr; }

/* KPI cards */
.kpi .kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 6px 0 8px; }
.kpi .icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--purple-soft);
  display: grid; place-items: center; color: var(--purple); font-size: 18px;
}
.delta { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px; }
.delta.up { color: var(--green); background: rgba(34,176,125,.1); }
.delta.down { color: var(--red); background: rgba(229,72,77,.1); }
.kpi .link { font-size: 12px; color: var(--purple); font-weight: 600; cursor: pointer; margin-left: 10px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; font-size: 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafaff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Pills & buttons ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.pill.draft { background: #f0f0f6; color: var(--muted); }
.pill.pending { background: #fff4e0; color: var(--amber); }
.pill.approved { background: #e3f7ef; color: var(--green); }
.pill.submitted { background: #e6f7f6; color: var(--teal); }
.pill.synced { background: var(--purple-soft); color: var(--purple); }
.pill.rejected { background: #fdecec; color: var(--red); }
.pill.bidding { background: #e6f7f6; color: var(--teal); }
.pill.won { background: #e3f7ef; color: var(--green); }
.pill.invited { background: #fff4e0; color: var(--amber); }
.pill.conflict { background: #fdecec; color: var(--red); }
.pill.ok { background: #e3f7ef; color: var(--green); }

.btn {
  border: 0; border-radius: 12px; padding: 10px 18px; font-family: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
}
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 4px 12px rgba(249,112,102,.35); }
.btn-primary:hover { background: var(--coral-dark); transform: translateY(-1px); }
.btn-purple { background: var(--purple); color: #fff; }
.btn-purple:hover { background: var(--purple-deep); }
.btn-ghost { background: var(--purple-soft); color: var(--purple); }
.btn-ghost:hover { background: #e2ddf8; }
.btn-line { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-line:hover { border-color: var(--purple); color: var(--purple); }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn-row { display: flex; gap: 10px; align-items: center; }

/* ---------- Takeoff ---------- */
.takeoff-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.plan-sheet {
  background: #fdfdfe; border: 1px solid var(--line); border-radius: 14px;
  position: relative; overflow: hidden; min-height: 420px;
}
.plan-toolbar { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fff; border-radius: 14px 14px 0 0; flex-wrap: wrap; }
.tool { border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.tool.active { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.plan-canvas { position: relative; height: 380px; cursor: crosshair;
  background-image:
    linear-gradient(#f0f0f8 1px, transparent 1px),
    linear-gradient(90deg, #f0f0f8 1px, transparent 1px);
  background-size: 24px 24px;
}
.count-marker { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--coral); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; transform: translate(-50%,-50%); box-shadow: 0 2px 6px rgba(249,112,102,.5); animation: pop .18s ease; }
.count-marker.ai { background: var(--teal); box-shadow: 0 2px 6px rgba(39,163,160,.5); }
.measure-line { position: absolute; height: 2px; background: var(--purple); transform-origin: left center; }
@keyframes pop { from { transform: translate(-50%,-50%) scale(0); } to { transform: translate(-50%,-50%) scale(1); } }
.side-panel { display: flex; flex-direction: column; gap: 14px; }
.assembly { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; }
.assembly .tag { background: var(--purple-soft); color: var(--purple); border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.measurement-list div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 12.5px; border-bottom: 1px dashed var(--line); }
.measurement-list div:last-child { border-bottom: 0; }

/* ---------- G703 grid ---------- */
.g703 th { font-size: 10.5px; padding: 8px 8px; }
.g703 td { padding: 8px; font-size: 12.5px; }
.g703 input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 9px;
  font-family: inherit; font-size: 12.5px; text-align: right; outline: 0; font-variant-numeric: tabular-nums;
}
.g703 input:focus { border-color: var(--purple); }
.g703 tr.co-row td { background: #fffaf3; }
.g703 tfoot td { font-weight: 700; border-top: 2px solid var(--ink); background: #fbfbfd; }
.g703 .computed { color: var(--ink); }
.g703 .carry { color: var(--muted); }

/* ---------- G702/G703 doc preview ---------- */
.doc {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 34px 38px;
  font-family: Georgia, "Times New Roman", serif; color: #111; max-width: 860px; margin: 0 auto;
}
.doc h2 { font-size: 17px; text-align: center; letter-spacing: 1px; }
.doc .doc-sub { text-align: center; font-size: 11px; color: #555; margin-bottom: 18px; }
.doc .doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 30px; font-size: 12px; margin-bottom: 16px; }
.doc .doc-meta div { display: flex; justify-content: space-between; border-bottom: 1px dotted #ccc; padding: 4px 0; }
.doc table { font-size: 11.5px; }
.doc th, .doc td { border: 1px solid #bbb; padding: 6px 8px; }
.doc .totline { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; padding: 8px 0; border-top: 2px solid #111; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(24,16,66,.45); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); }
.modal { background: #fff; border-radius: 20px; padding: 26px; width: 520px; max-width: 92vw; max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(24,16,66,.3); }
.modal.wide { width: 900px; }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: 13px; outline: 0;
}
.field input:focus, .field select:focus { border-color: var(--purple); }

/* ---------- Sync page ---------- */
.qbo-card { display: flex; align-items: center; gap: 18px; }
.qbo-badge { width: 52px; height: 52px; border-radius: 14px; background: #e7f6ec; display: grid; place-items: center; font-weight: 800; color: #1d9e57; font-size: 20px; }
.log-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; align-items: center; }
.log-item:last-child { border-bottom: 0; }
.log-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.log-dot.ok { background: var(--green); } .log-dot.warn { background: var(--amber); } .log-dot.err { background: var(--red); }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 24px; left: 260px; display: flex; flex-direction: column; gap: 10px; z-index: 99; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow); animation: slidein .25s ease; display: flex; gap: 10px; align-items: center; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.flow-strip { display: flex; align-items: center; gap: 0; margin-bottom: 20px; flex-wrap: wrap; }
.flow-step { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.flow-step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--purple-soft); color: var(--purple); display: grid; place-items: center; font-size: 11px; }
.flow-step.done .n { background: var(--green); color: #fff; }
.flow-step.now .n { background: var(--purple); color: #fff; }
.flow-step.now { color: var(--purple); }
.flow-arrow { width: 34px; height: 1.5px; background: var(--line); margin: 0 10px; }
.badge-num { background: var(--coral); color: #fff; font-size: 10px; border-radius: 8px; padding: 1px 6px; margin-left: 6px; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.timeline .tl { position: relative; padding-bottom: 16px; font-size: 12.5px; }
.timeline .tl::before { content: ""; position: absolute; left: -19.5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--purple); }
.timeline .tl .t { color: var(--muted); font-size: 11px; }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2,1fr); } .takeoff-wrap, .grid.span-2-1 { grid-template-columns: 1fr; } }

/* ---------- takeoff area tool ---------- */
.area-box { position: absolute; border: 2px solid var(--teal); background: rgba(39,163,160,.14); border-radius: 4px; pointer-events: none; }

/* ---------- billing page ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.plan-tier { border: 1.5px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan-tier.current { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
.plan-tier .price { font-size: 24px; font-weight: 700; }
.plan-tier .per { font-size: 12px; color: var(--muted); font-weight: 400; }
.plan-tier ul { list-style: none; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; margin: 4px 0 10px; }
.plan-tier ul li::before { content: "✓  "; color: var(--green); font-weight: 700; }

/* ---------- new estimate modal line rows ---------- */
.est-line-row { display: grid; grid-template-columns: 74px 1fr 64px 64px 84px 64px 30px; gap: 8px; margin-bottom: 8px; align-items: center; }
.est-line-row input, .est-line-row select { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 9px; font-family: inherit; font-size: 12px; outline: 0; width: 100%; }
.est-line-row input:focus, .est-line-row select:focus { border-color: var(--purple); }
.del-line { border: 0; background: none; color: var(--red); cursor: pointer; font-size: 15px; }

/* ---------- chat assistant ---------- */
.chat-fab {
  position: fixed; bottom: 26px; right: 26px; width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--coral); color: #fff; font-size: 24px; cursor: pointer; z-index: 70;
  box-shadow: 0 8px 24px rgba(249,112,102,.45); transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-panel {
  position: fixed; bottom: 96px; right: 26px; width: 380px; max-width: calc(100vw - 40px);
  height: 540px; max-height: calc(100vh - 140px); background: #fff; border-radius: 20px;
  box-shadow: 0 24px 70px rgba(38,27,105,.28); z-index: 70; display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; animation: chatup .22s ease; }
@keyframes chatup { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.chat-head { background: linear-gradient(135deg, #5d44cf, #4a2fb0); color: #fff; padding: 16px; display: flex; align-items: center; gap: 12px; }
.chat-avatar { width: 36px; height: 36px; border-radius: 12px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 17px; }
.chat-title { font-weight: 700; font-size: 14px; }
.chat-sub { font-size: 11px; opacity: .75; }
.chat-close { margin-left: auto; background: rgba(255,255,255,.15); border: 0; color: #fff; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fafaff; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.55; }
.chat-msg.bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.chat-msg.me { background: var(--purple); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg ol, .chat-msg ul { margin: 6px 0 0 18px; }
.chat-msg li { margin: 3px 0; }
.chat-msg .go { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 6px 12px; border-radius: 8px; background: var(--purple-soft); color: var(--purple); font-weight: 600; font-size: 12px; border: 0; cursor: pointer; }
.chat-msg .go:hover { background: #e2ddf8; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }
.chat-chips button { border: 1.5px solid var(--purple-soft); background: #fff; color: var(--purple); border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; }
.chat-chips button:hover { background: var(--purple-soft); }
.chat-typing { align-self: flex-start; color: var(--muted); font-size: 12px; padding: 4px 8px; font-style: italic; }
.chat-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-foot input { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 13px; outline: 0; }
.chat-foot input:focus { border-color: var(--purple); }
.chat-powered { text-align: center; font-size: 10px; color: var(--muted); padding: 6px; background: #fafaff; }
