/* ============================================================
   DISKMAN Quoting System — styles
   Brand: navy #1e3a5f · teal #0d8a9c · aqua #7fdde8 (from
   diskmandotnet logo + existing proposal PDFs)
   ============================================================ */

:root {
  --navy: #1e3a5f;
  --teal: #0d8a9c;
  --teal-dark: #0b7181;
  --aqua: #7fdde8;
  --aqua-light: #d8f5f9;
  --cyan: #29bcc9;
  --ink: #22303f;
  --grey: #64748b;
  --line: #dbe4ec;
  --bg: #f1f5f8;
  --white: #ffffff;
  --radius: 10px;
  --font: 'Poppins', 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win, even over display rules below
   (e.g. .modal { display:flex } would otherwise force modals visible). */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

/* ================= Toolbar ================= */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  background: var(--white);
  border-bottom: 3px solid var(--cyan);
  padding: 10px 22px;
  flex-wrap: wrap;
}
.toolbar-logo { height: 34px; }
.toolbar h1 { font-size: 17px; font-weight: 700; color: var(--navy); letter-spacing: .5px; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.divider { width: 1px; height: 24px; background: var(--line); }

.btn {
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--navy);
  padding: 8px 14px; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--cyan); background: var(--aqua-light); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.add { margin-top: 10px; border-style: dashed; color: var(--teal); }
.btn.danger-row { border: none; background: none; color: #c0392b; font-size: 17px; cursor: pointer; padding: 4px 8px; }
.btn.danger-row:hover { color: #e74c3c; }
.file-btn { display: inline-block; }

#savedQuotes {
  font-family: var(--font); font-size: 13.5px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--white);
  color: var(--navy); max-width: 220px;
}

/* ================= Builder layout ================= */
.builder-main { max-width: 1060px; margin: 26px auto 80px; padding: 0 20px; display: grid; gap: 22px; }

.card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(30,58,95,.06);
  padding: 22px 24px;
}
.card h2 {
  font-size: 15px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: .8px;
  background: var(--teal);
  margin: -22px -24px 18px; padding: 11px 24px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card h2 .optional { font-weight: 400; text-transform: none; opacity: .85; font-size: 13px; }
.hint { font-size: 12.5px; color: var(--grey); margin: -8px 0 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); }
label input[type=text], label input[type=date], label input[type=number] {
  display: block; width: 100%; margin-top: 5px;
  font-family: var(--font); font-size: 14px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fbfdfe;
}
textarea {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink); line-height: 1.55;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fbfdfe;
  resize: vertical;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--aqua); border-color: var(--cyan); }

.inline { display: flex; gap: 10px; align-items: center; margin-top: 5px; }
.inline input[type=text] { margin-top: 0; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; font-size: 12px; color: var(--grey); white-space: nowrap; }

.logo-upload { margin-top: 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#clientLogoPreview { max-height: 60px; max-width: 220px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }

/* Timeline rows + scope sections */
.tl-row, .scope-row { display: flex; gap: 10px; margin-bottom: 8px; align-items: flex-start; }
.tl-row input { flex: 1; font-family: var(--font); font-size: 14px; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fbfdfe; }
.tl-row input:first-child { flex: 0 0 220px; font-weight: 600; }
.scope-row { flex-direction: column; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfdfe; }
.scope-row .scope-head { display: flex; gap: 10px; width: 100%; }
.scope-row input { flex: 1; font-family: var(--font); font-size: 14px; font-weight: 600; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; }
.scope-row textarea { margin-top: 8px; background: #fff; }

/* ================= Line items ================= */
.item-row {
  border: 1px solid var(--line); border-left: 4px solid var(--cyan);
  border-radius: 8px; background: #fbfdfe;
  padding: 12px 14px; margin-bottom: 12px;
}
.item-row .row-top { display: flex; gap: 10px; align-items: center; }
.item-row select.picker {
  flex: 1; font-family: var(--font); font-size: 13.5px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--white); color: var(--navy);
  min-width: 0;
}
.item-row .row-fields { display: grid; grid-template-columns: 1fr 170px 130px; gap: 10px; margin-top: 10px; }
@media (max-width: 720px) { .item-row .row-fields { grid-template-columns: 1fr; } }
.item-row input[type=text], .item-row input[type=number], .item-row select.term {
  font-family: var(--font); font-size: 14px; width: 100%;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff;
}
.item-row input.iname { font-weight: 600; }
.item-row textarea { margin-top: 10px; background: #fff; }
.item-row .lbl { font-size: 11px; font-weight: 600; color: var(--grey); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 3px; }

.subtotal { margin-top: 12px; text-align: right; font-weight: 700; color: var(--navy); font-size: 14.5px; }
.subtotal .rec { font-weight: 500; color: var(--grey); font-size: 13px; display: block; }

/* ================= Preview bar ================= */
.preview-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  background: var(--navy); color: #fff; padding: 10px 22px;
}
.preview-hint { font-size: 13px; opacity: .85; flex: 1; }
.preview-bar .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.preview-bar .btn.ghost:hover { background: rgba(255,255,255,.12); }

/* ================= Proposal document (screen preview) ================= */
#doc { display: flex; flex-direction: column; align-items: center; padding: 30px 12px 60px; gap: 24px; }

.sheet {
  width: 210mm; height: 296mm; background: #fff;
  box-shadow: 0 3px 18px rgba(30,58,95,.18);
  padding: 14mm 14mm 26mm;
  position: relative;
  display: flex; flex-direction: column;
}
.sheet-body { flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* Sheet header */
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8mm; }
.sheet-head .head-left .doc-type {
  font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--navy);
  text-transform: uppercase; letter-spacing: 1px;
}
.sheet-head .head-left .doc-type span { color: var(--teal); display: block; }
.sheet-head .issue { font-size: 11px; font-weight: 700; color: var(--teal-dark); letter-spacing: .8px; text-transform: uppercase; margin-top: 6px; }
.sheet-head .proj-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.head-right { text-align: right; }
.head-right img.dm-logo { width: 62mm; }
.head-right .client-logo { max-height: 18mm; max-width: 55mm; margin-top: 4mm; }
.head-right .client-line { font-size: 11.5px; color: var(--grey); margin-top: 2mm; }

/* Page 1 two-column layout */
.p1-cols { display: grid; grid-template-columns: 1fr 72mm; gap: 9mm; height: 100%; }
.p1-left, .p1-right { overflow: hidden; min-height: 0; }
p.closing-p { font-size: 12.2px; margin-bottom: 3mm; text-align: justify; }
.p1-left h3, .doc-h3 {
  font-size: 16px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 4mm;
  border-bottom: 3px solid var(--aqua); display: inline-block; padding-bottom: 2px;
}
.p1-left p { font-size: 12.2px; margin-bottom: 3.2mm; text-align: justify; }

/* Aqua info panels (Project details / Timeline details) */
.panel { border-radius: 3mm; overflow: hidden; margin-bottom: 6mm; }
.panel .panel-title {
  background: var(--teal); color: #fff; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; font-size: 13px; padding: 3.2mm 4mm;
}
.panel .panel-body { background: var(--aqua); padding: 2mm 0; }
.panel .prow { display: grid; grid-template-columns: 34mm 1fr; gap: 3mm; padding: 1.6mm 4mm; font-size: 10.8px; align-items: baseline; }
.panel .prow + .prow { border-top: 1px solid rgba(255,255,255,.55); }
.panel .prow b { color: var(--navy); font-weight: 700; }
.panel .pnote { font-size: 9px; padding: 0 4mm 2mm; color: var(--navy); }

/* Notes box */
.notes-box { font-size: 10.6px; }
.notes-box h4 { font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 1.5mm; }
.notes-box ul { padding-left: 4.5mm; }
.notes-box li { margin-bottom: 1.4mm; }

/* Scope detail sections */
.scope-detail { margin-bottom: 5mm; }
.scope-detail h4 { font-size: 13px; font-weight: 700; color: var(--teal-dark); margin-bottom: 1.5mm; }
.scope-detail p { font-size: 12.2px; margin-bottom: 2.5mm; text-align: justify; }

/* Item tables */
.items-table { width: 100%; border-collapse: collapse; margin: 3mm 0 2mm; font-size: 11.4px; }
.items-table th {
  background: var(--teal); color: #fff; text-align: left; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; font-size: 10.5px;
  padding: 2.6mm 3mm;
}
.items-table th.price, .items-table td.price { text-align: right; white-space: nowrap; width: 30mm; }
.items-table td { padding: 2.4mm 3mm; vertical-align: top; border-bottom: 1px solid var(--line); }
.items-table tr:nth-child(even) td { background: var(--aqua-light); }
.items-table td .iname { font-weight: 700; color: var(--navy); display: block; }
.items-table td .idesc { color: var(--ink); font-size: 10.8px; }
.items-table tfoot td { font-weight: 700; color: var(--navy); border-bottom: none; background: none !important; padding-top: 2.5mm; }
.items-table tfoot .rec-line td { font-weight: 500; color: var(--grey); font-size: 10.5px; padding-top: 0.5mm; }

.section-note { font-size: 10.5px; color: var(--grey); margin-bottom: 5mm; }

/* Investment */
.investment {
  background: var(--aqua); border-radius: 3mm; padding: 5mm 6mm; margin: 4mm 0 6mm;
}
.investment .inv-title { font-size: 14px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2mm; }
.investment .inv-price { font-size: 22px; font-weight: 800; color: var(--navy); }
.investment .inv-price small { font-size: 12px; font-weight: 600; }
.investment .inv-extra { font-size: 11px; color: var(--navy); margin-top: 1.5mm; }

.closing p { font-size: 12.2px; margin-bottom: 3mm; text-align: justify; }
.signoff { margin-top: 5mm; font-size: 12.2px; }
.signoff .name { font-weight: 700; color: var(--navy); }
.signoff .role { font-size: 11px; color: var(--grey); }

/* Sheet footer */
.sheet-foot {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--navy); color: #fff;
  font-size: 9.6px; letter-spacing: .3px;
  padding: 3.4mm 14mm;
  display: flex; flex-wrap: wrap; gap: 2mm 6mm; justify-content: center;
}
.sheet-foot b { color: var(--aqua); font-weight: 600; }

.continued { font-size: 10px; color: var(--grey); text-align: right; margin-top: auto; padding-top: 4mm; font-style: italic; }

/* ================= Auth (login / setup) ================= */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--teal) 100%);
  padding: 20px;
}
.auth-card {
  background: var(--white); border-radius: 14px; padding: 38px 40px;
  width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  text-align: center;
}
.auth-logo { width: 240px; max-width: 100%; margin-bottom: 18px; }
.auth-card h1 { font-size: 19px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--grey); margin-bottom: 20px; }
.auth-card form { text-align: left; display: grid; gap: 14px; }
.auth-card label input { margin-top: 5px; width: 100%; font-family: var(--font); font-size: 15px; border: 1.5px solid var(--line); border-radius: 8px; padding: 11px 13px; }
.auth-error { color: #c0392b; font-size: 13px; min-height: 18px; margin: 0; }
.btn.wide { width: 100%; padding: 12px; font-size: 15px; }

/* ================= Toolbar extras ================= */
.current-quote { font-size: 13px; color: var(--grey); font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= Modals ================= */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 35, 55, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px 40px;
  overflow-y: auto;
}
.modal-card {
  background: var(--white); border-radius: 14px; width: 100%; max-width: 720px;
  box-shadow: 0 12px 50px rgba(0,0,0,.35); padding: 22px 24px;
}
.modal-card.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.modal-head h3 { font-size: 16px; font-weight: 700; color: var(--navy); flex-shrink: 0; }
.modal-head input[type=search] {
  flex: 1; font-family: var(--font); font-size: 14px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fbfdfe;
}
.modal-card form { display: grid; gap: 12px; }
.modal-card form label input { margin-top: 5px; width: 100%; font-family: var(--font); font-size: 14px; border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* ================= Dashboard ================= */
.dash-main { max-width: 1060px; margin: 26px auto 80px; padding: 0 20px; }
.dash-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.dash-head h2 { font-size: 20px; font-weight: 700; color: var(--navy); flex-shrink: 0; }
.dash-head input[type=search] {
  flex: 1; min-width: 180px; font-family: var(--font); font-size: 14px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 13px; background: var(--white);
}
.btn.big { padding: 11px 20px; font-size: 14.5px; }
.dash-list .quote-row { background: var(--white); box-shadow: 0 1px 4px rgba(30,58,95,.06); }
.big-hint { font-size: 14.5px; text-align: center; padding: 40px 0; }
.draft-notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff8e1; border: 1px solid #f0d060; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px; font-size: 13.5px; color: #6b5900;
}
.draft-notice span { flex: 1; }

/* ================= Catalogue editor ================= */
.cat-hint { margin: 0 0 6px; }
.cat-group { margin-bottom: 22px; }
.cat-group-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.cat-group-head input {
  flex: 1; font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--navy);
  border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fbfdfe;
}
.cat-items { display: grid; gap: 12px; }
.cat-item {
  border: 1px solid var(--line); border-left: 4px solid var(--cyan); border-radius: 8px;
  background: #fbfdfe; padding: 12px 14px;
}
.cat-item-top { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.cat-item-top input { flex: 1; font-family: var(--font); font-size: 14px; font-weight: 600; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; }
.cat-item textarea { background: #fff; margin-bottom: 8px; }
.cat-variants { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cat-variants .lbl { font-size: 11px; font-weight: 600; color: var(--grey); text-transform: uppercase; letter-spacing: .5px; width: 100%; }
.cat-variant { display: flex; gap: 6px; align-items: center; }
.cat-variant select, .cat-variant input {
  font-family: var(--font); font-size: 13.5px;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.cat-variant input { width: 110px; }
.btn.add.small { margin-top: 0; padding: 7px 12px; font-size: 12.5px; }

/* Quotes list */
.quotes-list { max-height: 60vh; overflow-y: auto; display: grid; gap: 8px; }
.quote-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: #fbfdfe;
}
.quote-row.current { border-color: var(--cyan); background: var(--aqua-light); }
.q-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.q-name { font-weight: 700; color: var(--navy); font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { font-size: 12px; color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn.danger { color: #c0392b; }
.btn.danger:hover { border-color: #c0392b; background: #fdf0ee; }

/* ================= Print ================= */
@page { size: A4; margin: 0; }

@media print {
  body { background: #fff; }
  #builder, .preview-bar, .modal { display: none !important; }
  #preview[hidden] { display: block !important; } /* safety: printing from builder */
  #doc { display: block; padding: 0; }
  .sheet {
    width: 210mm; min-height: auto; height: 296mm;
    box-shadow: none; margin: 0;
    page-break-after: always;
    overflow: hidden;
  }
  .sheet:last-child { page-break-after: auto; }
  .panel .panel-title, .panel .panel-body, .items-table th, .items-table tr:nth-child(even) td,
  .investment, .sheet-foot {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
