/* SolidCAD CRM - app styles */
:root {
  --navy: #1d3a6b;
  --navy-2: #274b85;
  --orange: #e8731e;
  --orange-2: #cf6214;
  --blue: #2c5fa8;
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7686;
  --line: #e1e6ef;
  --ok: #1f8a4c;
  --ok-bg: #e5f5ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn-bg: #fff4e5;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); line-height: 1.25; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.r { text-align: right; }
.big { font-size: 18px; }
.error-text { color: var(--err); }

/* Layout */
.side { position: fixed; inset: 0 auto 0 0; width: 210px; background: var(--navy); color: #fff; display: flex; flex-direction: column; z-index: 10; }
.brand { display: block; padding: 20px 20px 16px; color: #fff; border-bottom: 3px solid var(--orange); }
.brand:hover { text-decoration: none; }
.brand span { font-weight: 800; font-size: 20px; letter-spacing: 1.5px; }
.brand small { margin-left: 6px; color: var(--orange); font-weight: 700; letter-spacing: 1px; }
.side nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.side nav a { display: block; padding: 10px 20px; color: #d6def0; border-left: 3px solid transparent; font-weight: 500; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--orange); }
.side-user { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; gap: 2px; }
.side-user a { color: #fff; }
.side-user a.muted { color: #9fb0cf; font-size: 12.5px; }
.main { margin-left: 210px; padding: 0 28px 48px; min-height: 100vh; }
.main-full { margin-left: 0; }
.topbar { padding: 22px 0 12px; }
.topbar h1 { margin: 0; font-size: 22px; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card-flush { padding: 0; overflow-x: auto; }
.card-flush .pad { padding: 16px 20px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card, .grid-2 > div > .card:last-child { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.grid-lead { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; margin: 0; }
.narrow { max-width: 460px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f8fc; text-decoration: none; border-color: #cdd5e3; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-2); border-color: var(--orange-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.icon-btn { width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 5px; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.icon-btn:hover { color: var(--navy); border-color: #cdd5e3; }
.icon-btn.danger:hover { color: var(--err); border-color: var(--err); }
.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.actions-row .right, form.right { margin-left: auto; }
form.inline { display: inline; margin: 0; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; color: #374151; font-size: 13px; }
label small { font-weight: 400; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); padding: 8px 10px; border: 1px solid #cfd6e3; border-radius: 6px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(44,95,168,.25); border-color: var(--blue); }
input[type=checkbox] { width: auto; margin: 0; accent-color: var(--orange); }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 14px; }
label.check input { margin-top: 3px; }
.inline-check { display: inline-flex; margin-right: 14px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #374151; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid h2 { margin: 6px 0 0; }
.span-2 { grid-column: 1 / -1; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.form-row-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); z-index: 5; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack h2 { margin: 4px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; }
.filters input[type=search] { flex: 1 1 240px; width: auto; }
.filters select, .filters input[type=text] { width: auto; flex: 0 1 160px; }
.search-inline input { width: 260px; }
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.note-form-row { display: flex; gap: 8px; align-items: center; }
.note-form-row select, .note-form-row input { width: auto; flex: 1; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe5cf; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f5c2bd; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfd; font-weight: 600; }
.table th.r, .table td.r { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table-hover tbody tr:hover, .table-hover tr[data-href]:hover { background: #f8fafd; cursor: pointer; }
.table.small td { padding: 8px 10px; }
.row-muted td { opacity: .55; }

/* Badges & tags */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef1f6; color: #4b5563; white-space: nowrap; }
.b-new { background: #e8effb; color: var(--blue); }
.b-contacted { background: #efe9fb; color: #6b46c1; }
.b-qualified { background: #e3f4f6; color: #0f7b8a; }
.b-quoted, .b-sent, .b-sending { background: #fff1e5; color: #b6540f; }
.b-won, .b-accepted, .b-paid, .b-invoiced { background: var(--ok-bg); color: var(--ok); }
.b-lost, .b-declined, .b-failed, .b-overdue { background: var(--err-bg); color: var(--err); }
.b-expired, .b-void, .b-skipped, .b-draft, .b-paused { background: #eef1f6; color: #6b7686; }
.b-partial, .b-pending { background: #fff8db; color: #8a6300; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; margin: 2px 2px 0 0; border-radius: 4px; background: #eef2f9; color: var(--navy-2); }
.tag-muted { background: #f1f1f1; color: #888; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a:hover { color: var(--navy); text-decoration: none; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--orange); }
.tabs small { color: #9aa3b2; font-weight: 500; margin-left: 3px; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 10px 0; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--navy); }
a.stat:hover { text-decoration: none; border-color: #cdd5e3; border-top-color: var(--orange); }
.stat span { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.stat b { font-size: 22px; color: var(--navy); }
.stat small { color: var(--muted); }
.stat-alert { border-top-color: var(--err); }
.stat-alert b { color: var(--err); }
.pipeline { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pipe { display: flex; flex-direction: column; align-items: center; padding: 12px 6px; border-radius: 6px; background: #f6f8fc; color: var(--text); }
.pipe:hover { text-decoration: none; background: #eef2f9; }
.pipe b { font-size: 22px; color: var(--navy); }
.pipe span { font-size: 12px; color: var(--muted); font-weight: 600; }
.pipeline-bar { display: flex; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.pipe-step { flex: 1; border: 0; border-right: 1px solid var(--line); background: #fff; padding: 9px 4px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.pipe-step:last-child { border-right: 0; }
.pipe-step:hover { background: #f6f8fc; color: var(--navy); }
.pipe-step.on { background: var(--navy); color: #fff; }
.pipe-step.on.pipe-won { background: var(--ok); }
.pipe-step.on.pipe-lost { background: var(--err); }

/* Lead page */
.details { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.details dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.details.small { grid-template-columns: 100px 1fr; margin-top: 12px; }
.notes { margin-top: 14px; padding: 10px 12px; background: var(--warn-bg); border-radius: 6px; white-space: normal; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: #c5cedd; }
.timeline li.t-note::before { background: var(--blue); }
.timeline li.t-call::before { background: #0f7b8a; }
.timeline li.t-meeting::before { background: #6b46c1; }
.timeline li.t-email::before { background: var(--orange); }
.timeline small { color: var(--muted); }
.t-type { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-right: 4px; }
.t-system .t-type { display: none; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.errors { color: var(--err); }

/* Document editor */
.item { border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 6px; padding: 12px; margin-bottom: 12px; background: #fcfdff; display: flex; flex-direction: column; gap: 8px; }
.item-main { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.item-title { flex: 1 1 280px; font-weight: 600; }
label.mini { font-size: 11.5px; color: var(--muted); gap: 2px; }
label.mini input { width: 110px; }
label.mini .item-qty { width: 64px; }
label.mini.check { flex-direction: row; align-items: center; padding-bottom: 9px; color: var(--text); font-size: 13px; }
.item-total { min-width: 110px; text-align: right; font-weight: 700; color: var(--navy); padding-bottom: 8px; }
.item-tools { display: flex; gap: 4px; padding-bottom: 4px; }
.item details summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; }
.item-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.totals { margin: 14px 0 0 auto; border-collapse: collapse; min-width: 280px; }
.totals th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 16px 4px 0; }
.totals td { text-align: right; padding: 4px 0; font-weight: 600; }
.totals .grand th, .totals .grand td { font-size: 17px; color: var(--navy); border-top: 2px solid var(--navy); padding-top: 8px; }
#add-service { width: auto; max-width: 320px; }

/* Document view */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.doc-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.doc-side .card { margin-bottom: 14px; }
.status-form { display: flex; gap: 6px; margin: 10px 0; }
.logo-preview { margin: 10px 0; padding: 10px; background: #f6f8fc; border-radius: 6px; display: inline-block; }
.logo-preview img { max-height: 60px; display: block; }

/* Campaigns */
.preview-frame { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 6px; background: #eef1f6; }
.preview-frame.tall { height: 640px; }
.campaign-form .form-actions { grid-column: 1 / -1; }

/* Login / install */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, #13284c 100%); }
.login-card { background: #fff; padding: 32px; border-radius: 10px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card.wide { max-width: 560px; }
.login-card h1 { font-size: 20px; margin: 0; }
.login-card h2 { font-size: 15px; margin: 8px 0 0; }
.login-brand { font-weight: 800; font-size: 22px; letter-spacing: 2px; color: var(--navy); border-bottom: 3px solid var(--orange); padding-bottom: 10px; }
.login-brand img { max-height: 48px; }

/* Responsive */
@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { border-bottom: 0; padding: 12px 16px; }
  .side nav { display: flex; overflow-x: auto; padding: 0; flex: 1 1 100%; order: 3; border-top: 1px solid rgba(255,255,255,.12); }
  .side nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 12px; white-space: nowrap; }
  .side nav a.on { border-bottom-color: var(--orange); }
  .side-user { flex-direction: row; gap: 12px; border-top: 0; margin-left: auto; padding: 12px 16px; }
  .main { margin-left: 0; padding: 0 16px 40px; }
  .grid-2, .grid-lead, .form-grid, .item-details { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(3, 1fr); }
  .pipeline-bar { flex-wrap: wrap; }
  .pipe-step { flex: 1 1 33%; border-bottom: 1px solid var(--line); }
  .search-inline input { width: 100%; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .form-row-3 label:first-child { grid-column: 1 / -1; }
}

/* Print: only the document */
@media print {
  body { background: #fff; }
  .no-print, .side, .topbar, .flash, .actions-row { display: none !important; }
  .main { margin: 0; padding: 0; }
  .doc-layout { display: block; }
  .doc-wrap { border: 0; border-radius: 0; }
}

/* Workspace refresh: shared CRM screens; document print styles remain separate. */
@media screen {
  :root { --navy:#19365e; --navy-2:#284e80; --bg:#f5f7fb; --line:#e7ecf3; --radius:12px; }
  body { font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif; }
  .side { width:228px; background:linear-gradient(180deg,#142b4b,#1d3a6b); }
  .brand { padding:25px 22px 20px; border-bottom:0; }
  .brand span { font-size:19px; }
  .brand small { display:inline-block; background:rgba(232,115,30,.15); padding:3px 6px; border-radius:5px; font-size:10px; }
  .workspace-label { padding:6px 24px 12px; font-size:10px; letter-spacing:1.7px; color:#99abc7; }
  .side nav { padding:0 12px; }
  .side nav a { margin:3px 0; padding:11px 14px; border-left:0; border-radius:8px; font-size:13px; }
  .side nav a.on { box-shadow:inset 3px 0 var(--orange); background:rgba(255,255,255,.12); }
  .side-user { padding:20px 24px; }
  .main { margin-left:228px; padding:0 32px 48px; }
  .main-full { margin-left:0; }
  .topbar { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:26px 0 24px; }
  .topbar h1 { font-size:26px; letter-spacing:-.7px; overflow-wrap:anywhere; }
  .page-eyebrow { margin:0 0 6px; font-size:11px; color:var(--muted); }
  .topbar-profile { display:flex; gap:10px; align-items:center; color:var(--text); font-size:12px; white-space:nowrap; }
  .topbar-profile small { display:block; color:var(--muted); font-size:11px; }
  .avatar { display:flex; align-items:center; justify-content:center; width:36px; height:36px; border-radius:50%; background:#e7edf7; color:var(--navy); font-weight:700; }
  .card { box-shadow:0 2px 8px rgba(24,44,78,.025); padding:22px; }
  .btn { border-radius:8px; font-weight:500; padding:9px 15px; }
  .btn-primary { box-shadow:0 2px 4px rgba(232,115,30,.13); }
  .btn-sm { padding:5px 10px; }
  .stat { border-top:0; padding:19px 20px; position:relative; }
  .stat b { font-size:26px; letter-spacing:-.5px; margin:5px 0; }
  .stat-alert { background:#fff8f7; border-color:#f4dbd7; }
  .table th { padding:12px 14px; font-size:10px; letter-spacing:.8px; }
  .table td { padding:13px 14px; }
  input,select,textarea { border-radius:8px; padding:10px 12px; }
  .project-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(270px,1fr)); gap:18px; }
  .project-card { display:block; background:#fff; border:1px solid var(--line); border-radius:14px; padding:22px; color:var(--text); transition:box-shadow .15s; }
  .project-card:hover { text-decoration:none; box-shadow:0 6px 24px rgba(24,44,78,.08); }
  .project-code { font-size:11px; color:var(--muted); letter-spacing:.6px; }
  .project-card h2 { font-size:18px; margin:20px 0 6px; overflow-wrap:anywhere; }
  .project-card p { margin:0 0 24px; }
  .project-progress { height:6px; background:#edf1f7; border-radius:6px; overflow:hidden; margin:16px 0 10px; }
  .project-progress span { display:block; height:100%; background:var(--orange); }
  .project-meta { display:flex; gap:8px; justify-content:space-between; flex-wrap:wrap; font-size:12px; color:var(--muted); margin-top:10px; }
  .project-summary { display:flex; gap:14px; align-items:center; flex-wrap:wrap; margin:0 0 18px; }
  .project-form { margin-top:18px; }
  .project-history { margin-top:14px; border-top:1px solid var(--line); padding-top:14px; }
  summary { color:var(--navy); }
  .version-row,.member-row,.delivery-file { display:flex; justify-content:space-between; align-items:center; gap:16px; flex-wrap:wrap; padding:14px 0; }
  .version-row { border-bottom:1px solid var(--line); }
  .version-row p { margin:4px 0; }
  .file-hash { font-family:monospace; overflow-wrap:anywhere; color:var(--muted); }
  .project-body { overflow-wrap:anywhere; }
  .task-status-form { display:flex; gap:8px; flex-wrap:wrap; }
  .task-status-form select { width:auto; max-width:100%; }
  .delivery-selection { padding:12px; border-bottom:1px solid var(--line); }
  .client-delivery { max-width:850px; margin:0 auto; }
  .delivery-brand { background:var(--navy); color:#fff; padding:24px; border-bottom:4px solid var(--orange); font-weight:700; letter-spacing:1px; border-radius:12px 12px 0 0; }
  .delivery-brand span { color:#f6a765; font-size:11px; margin-left:16px; }
  .client-delivery h1 { font-size:25px; overflow-wrap:anywhere; }
  @media(max-width:860px) {
    .side { width:auto; }
    .brand { padding:14px 16px; }
    .workspace-label { display:none; }
    .side nav { padding:0 8px; }
    .side nav a { margin:0; border-radius:0; padding:10px 12px; }
    .side nav a.on { box-shadow:inset 0 -3px var(--orange); }
    .main { margin-left:0; padding:0 16px 40px; }
    .side-user { padding:12px 16px; }
    .topbar h1 { font-size:23px; }
    .topbar-profile { display:none; }
  }
  @media(max-width:480px) { .project-grid{grid-template-columns:1fr} .card{padding:16px} .stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px} .stat{padding:14px 12px} .stat b{font-size:21px} .card-head{flex-wrap:wrap} .form-actions{flex-wrap:wrap} }
}
