:root {
  --red: #b3122d; --red-dark: #8e0e23; --ink: #23272d; --steel: #5b6470;
  --concrete: #eceef0; --line: #d3d7dc; --navy: #1f4e79; --ok: #1d6b3a;
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--concrete); }
a { color: var(--navy); }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { font-stretch: 112%; font-weight: 800; font-size: 1.75rem; line-height: 1.1; margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
small { color: var(--steel); font-weight: 400; font-size: .85em; }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; font: inherit; font-weight: 700;
  background: var(--red); color: #fff; border: 2px solid var(--red); border-radius: 3px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn[disabled] { opacity: .6; cursor: progress; }
.danger { color: var(--red) !important; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 600; font-size: .93rem; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #b9bfc6; border-radius: 3px; padding: 8px 10px; width: 100%; }
input:disabled { background: var(--concrete); color: var(--steel); }
textarea { resize: vertical; }
.msg { min-height: 1.4em; margin: 12px 0 0; font-weight: 600; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--red); }
.note { background: #fff; border-left: 4px solid var(--navy); padding: 10px 14px; margin: 0 0 16px; max-width: 70ch; }
.loading { color: var(--steel); }

/* Account page */
.bar { display: flex; justify-content: space-between; align-items: center; padding: 12px clamp(16px, 4vw, 40px); background: #fff; border-bottom: 3px solid var(--red); }
.bar-brand img { display: block; width: 120px; height: auto; }
.bar-link { color: var(--ink); font-weight: 600; }
.acc { display: grid; place-items: start center; padding: clamp(24px, 6vw, 72px) 16px; }
.panel { width: min(440px, 100%); background: #fff; padding: 28px; border-top: 4px solid var(--ink); }
.panel h1 { margin-bottom: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: -28px -28px 22px; }
.tabs button { font: inherit; font-weight: 700; padding: 14px; border: 0; background: var(--concrete); color: var(--steel); cursor: pointer; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: inset 0 3px 0 var(--red); }

/* Workspace */
.ws { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.ws-side { background: var(--ink); color: #c9ced4; padding: 18px 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.ws-logo { width: 150px; margin: 0 18px 18px; background: #fff; padding: 6px; border-radius: 3px; }
.ws-nav { display: grid; }
.ws-nav a { color: #dfe3e7; text-decoration: none; padding: 10px 20px; font-weight: 600; border-left: 4px solid transparent; }
.ws-nav a:hover { background: #2f343b; }
.ws-nav a.on { border-left-color: var(--red); background: #2f343b; color: #fff; }
.ws-me { margin-top: auto; padding: 16px 20px; display: grid; gap: 4px; font-size: .9rem; }
.ws-me .linkish { color: #fff; justify-self: start; }
.ws-main { padding: 24px clamp(16px, 3vw, 36px) 48px; min-width: 0; outline: none; }
.ws-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ws-sum { display: flex; gap: 0; background: #fff; margin-bottom: 14px; flex-wrap: wrap; }
.ws-sum p { margin: 0; padding: 12px 20px; border-right: 1px solid var(--line); color: var(--steel); }
.ws-sum span { display: block; color: var(--ink); font-weight: 800; font-size: 1.25rem; font-stretch: 110%; }
.ws-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.ws-tools input { max-width: 420px; } .ws-tools select { max-width: 200px; }
.tbl-wrap { overflow-x: auto; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .82rem; color: var(--steel); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .acts { white-space: nowrap; } .tbl .acts > * + * { margin-left: 12px; }
.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--concrete); color: var(--steel); }
.pill.sent { background: #e3ecf5; color: var(--navy); }
.pill.accepted, .pill.paid, .pill.done, .pill.quoted { background: #e2f1e7; color: var(--ok); }
.pill.declined, .pill.overdue, .pill.new { background: #f8e1e5; color: var(--red); }
.empty { background: #fff; padding: 40px; text-align: center; } .empty p { color: var(--steel); }

/* Editor */
.ed-grid { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ed fieldset { border: 0; background: #fff; padding: 16px 18px 18px; margin: 0; display: grid; gap: 12px; }
.ed legend { font-weight: 800; font-stretch: 110%; padding: 0; float: left; width: 100%; margin-bottom: 4px; }
.ed.narrow { max-width: 900px; }
.g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: .8rem; color: var(--steel); padding: 0 4px 6px; }
.items td { padding: 3px 4px; }
.items td:nth-child(2) { width: 74px; } .items td:nth-child(3) { width: 110px; }
.items .lt { width: 100px; text-align: right; white-space: nowrap; }
.items .ra { width: 90px; white-space: nowrap; }
.items .r { text-align: right; }
.ico { width: 26px; height: 30px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; border-radius: 3px; }
.tot { align-items: end; } .tot p { grid-column: span 2; text-align: right; margin: 0; }
.preview-wrap { position: sticky; top: 16px; overflow: hidden; }
.preview { transform-origin: top left; width: 210mm; }
.preview .sheet { box-shadow: 0 2px 14px rgba(35, 39, 45, .18); margin: 0; }

/* Enquiries */
.enq { display: grid; gap: 12px; }
.enq article { background: #fff; padding: 16px 18px; border-left: 4px solid var(--red); }
.enq article.done, .enq article.quoted { border-left-color: var(--line); }
.enq header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.enq time { margin-left: auto; color: var(--steel); font-size: .88rem; }
.enq-msg { white-space: pre-wrap; max-width: 75ch; }
.enq-c a { margin-right: 14px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 12px 18px; border-left: 4px solid var(--ok); z-index: 50; font-weight: 600; }
.toast.err { border-left-color: var(--red); }

@media (max-width: 1100px) { .ed-grid { grid-template-columns: 1fr; } .preview-wrap { position: static; } }
@media (max-width: 760px) {
  .ws { grid-template-columns: 1fr; }
  .ws-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .ws-logo { width: 90px; margin: 0 10px 0 0; }
  .ws-nav { display: flex; flex-wrap: wrap; } .ws-nav a { padding: 8px 10px; border-left: 0; border-bottom: 3px solid transparent; }
  .ws-nav a.on { border-bottom-color: var(--red); }
  .ws-me { margin: 0 0 0 auto; padding: 6px 10px; }
  .g3 { grid-template-columns: 1fr; } .tot p { grid-column: auto; }
  .ed-grid { grid-template-columns: 1fr; }
}

/* Printing a quote/invoice: only the sheet goes to paper */
#print-root { display: none; }
@media print {
  body.printing { background: #fff; }
  body.printing #screen, body.printing .toast { display: none !important; }
  body.printing #print-root { display: block; }
}
