/* ===== CUCP Quoting Tool — styles ===== */
/* Brand pulled from cucp.com.au: primary #0073AE, accent #C1CD23, Roboto + Roboto Slab */
:root {
  --blue: #0073AE;
  --blue-dark: #005d8d;
  --lime: #C1CD23;
  --lime-dark: #9fa91b;
  --grey: #54595F;
  --text: #3a3d42;
  --muted: #7A7A7A;
  --line: #e3e6ea;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ok: #2e7d32;
  --warn: #c47f00;
  --danger: #c0392b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --font: "Roboto", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  --font-head: "Roboto Slab", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--grey); font-weight: 600; margin: 0 0 .5em; }
a { color: var(--blue); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }

/* ----- Buttons ----- */
.btn {
  font-family: var(--font); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 9px 16px; cursor: pointer; background: #eceff1; color: var(--grey);
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: #e1e5e8; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-accent { background: var(--lime); color: #243010; font-weight: 600; }
.btn-accent:hover { background: var(--lime-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: #fff; }
.btn-danger { background: transparent; color: var(--danger); border-color: #f0c8c2; }
.btn-danger:hover { background: #fbecea; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ----- Loading screen ----- */
#screen-loading {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  padding: 20px;
}

/* ----- App shell ----- */
.app-header {
  background: var(--blue); color: #fff; display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 30;
}
.app-header img.brand { height: 38px; }
.app-header .company { font-weight: 600; font-size: 15px; }
.app-header .company small { display: block; font-weight: 400; opacity: .8; font-size: 11.5px; letter-spacing: .5px; }
.app-header .spacer { flex: 1; }
.app-header .total-pill {
  background: rgba(255,255,255,.15); border-radius: 20px; padding: 6px 16px; font-weight: 600;
}
.app-header .total-pill small { opacity: .8; font-weight: 400; }
.app-header nav { display: flex; gap: 6px; }
.app-header nav button {
  background: transparent; border: none; color: #fff; font-family: var(--font); font-size: 13.5px;
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer; opacity: .9;
}
.app-header nav button:hover { background: rgba(255,255,255,.15); opacity: 1; }

.layout { max-width: 1240px; margin: 22px auto; padding: 0 18px; display: grid; grid-template-columns: 420px 1fr; gap: 22px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .step { background: var(--lime); color: #243010; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; font-family: var(--font); }

/* ----- Form ----- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--grey); margin-bottom: 4px; }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--font); font-size: 14px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,115,174,.12); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.field .err { font-size: 11.5px; color: var(--danger); margin-top: 3px; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 0 0 13px; }
fieldset legend { font-size: 12px; font-weight: 700; color: var(--blue); padding: 0 6px; text-transform: uppercase; letter-spacing: .5px; }

/* ----- Live price box ----- */
.price-box { background: #eef6fb; border: 1px solid #cfe6f3; border-radius: 8px; padding: 12px 14px; margin: 6px 0 14px; }
.price-box .pb-cost { font-size: 26px; font-weight: 700; color: var(--blue); font-family: var(--font-head); }
.price-box .pb-line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--grey); padding: 1px 0; }
.price-box .poa { color: var(--warn); font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eceff1; color: var(--grey); }
.badge.poa { background: #fff4e0; color: var(--warn); }
.badge.ok { background: #e6f4ea; color: #1a7f37; }
.badge.warn { background: #fff4e0; color: var(--warn); }
.badge.err { background: #fdecea; color: #c62828; }

/* ----- Line items table ----- */
table.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.lines th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 2px solid var(--line); padding: 8px 8px; }
table.lines td { border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
table.lines td.num, table.lines th.num { text-align: right; white-space: nowrap; }
table.lines .desc-main { font-weight: 600; color: var(--grey); }
table.lines .desc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
table.lines input.margin { width: 64px; text-align: right; padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }
table.lines input.sell-override { width: 82px; text-align: right; padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; background: transparent; }
table.lines input.sell-override:not(:placeholder-shown) { border-color: var(--blue); background: #f0f6ff; color: var(--blue); font-weight: 600; }
table.lines tr.has-override .desc-main::after { content: " ✎"; font-size: 11px; color: var(--blue); font-weight: 400; }
.totals { margin-top: 14px; border-top: 2px solid var(--line); padding-top: 12px; }
.totals .t-row { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .t-grand { font-size: 19px; font-weight: 700; color: var(--blue); font-family: var(--font-head); }
.totals .t-discount { color: #1a7f37; font-weight: 600; }
.discount-group { display: flex; gap: 6px; align-items: center; }
.discount-group input { flex: 1; min-width: 0; }
.disc-type-btn { padding: 5px 10px; min-width: 38px; font-weight: 700; font-size: 13px; }
.empty-lines { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ----- Quotes list / modal ----- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17,17,17,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 100%; max-width: 560px; padding: 24px 26px; }
.modal-wide { max-width: 760px; }
/* ----- Admin panel ----- */
.admin-user-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.aur-info { flex: 1; min-width: 180px; }
.aur-name { font-weight: 600; color: var(--grey); }
.pm-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pm-row-overall { background: #f8fafc; margin: 0 -4px; padding: 7px 4px; border-radius: 5px; border: none; }
.pm-label { flex: 1; min-width: 160px; color: var(--grey); }
.pm-input-wrap { display: flex; align-items: center; gap: 6px; }
.pm-input { width: 80px; text-align: right; padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }
.pm-input:not(:placeholder-shown) { border-color: var(--blue); background: #f0f6ff; }
.pm-section { padding: 8px 0 4px; color: var(--muted); }
.admin-edit-meta { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.modal h2 { font-size: 18px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.quote-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.quote-row .q-main { flex: 1; }
.quote-row .q-main b { color: var(--grey); }

/* ----- Admin dashboard ----- */
#screen-admin .app-header { background: var(--blue-dark); }
.admin-dash-layout { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 18px; max-width: 1200px; margin: 24px auto; padding: 0 20px; }
.admin-dash-orders { grid-column: 1 / -1; }
.admin-dash-internal { grid-column: 1; }
.admin-dash-stats { grid-column: 2; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dash-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--line); }
.dash-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table .right { text-align: right; }
.dash-table .nowrap { white-space: nowrap; }
.stat-row { display: flex; align-items: baseline; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat-row:last-child { border-bottom: none; }
.stat-val { font-size: 28px; font-weight: 700; font-family: var(--font-head); color: var(--blue); line-height: 1; }

.line-location { font-size: 11.5px; font-weight: 600; color: var(--blue); background: #e8f3fb; border-radius: 3px; padding: 1px 5px; display: inline-block; margin-bottom: 3px; }
.order-detail-row td { background: #f8fafc; }
.order-detail-cell { padding: 8px 16px 10px !important; }
.admin-dash-activity { grid-column: 1 / -1; }

/* ----- Internal mode bar ----- */
.internal-mode-bar {
  background: #1a3a5c; color: #cde4f5; font-size: 13.5px;
  display: flex; align-items: center; gap: 14px; padding: 8px 20px;
}
.internal-mode-bar span { flex: 1; }

/* ----- Quote notes ----- */
.quote-notes-list { max-height: 200px; overflow-y: auto; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: #fafbfc; }
.quote-note { padding: 6px 0; border-bottom: 1px solid var(--line); }
.quote-note:last-child { border-bottom: none; }
.quote-note-meta { margin-bottom: 2px; }
.quote-note-body { font-size: 13.5px; white-space: pre-wrap; color: var(--grey); }
.quote-notes-input { display: flex; gap: 8px; align-items: flex-end; }
.quote-notes-input textarea { flex: 1; min-width: 0; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--grey); color: #fff; padding: 12px 22px; border-radius: 24px; box-shadow: var(--shadow); z-index: 80; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }

.actions-bar { display: flex; flex-wrap: wrap; gap: 10px; }

/* accessories dropdown */
details.dropdown { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
details.dropdown > summary { list-style: none; cursor: pointer; padding: 9px 10px; font-size: 14px; color: var(--text); position: relative; }
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown > summary::after { content: "▾"; position: absolute; right: 12px; color: var(--muted); }
details.dropdown[open] > summary::after { content: "▴"; }
.dropdown-body { max-height: 220px; overflow: auto; border-top: 1px solid var(--line); padding: 6px 10px; }
label.acc-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
label.acc-item input { width: auto; }

/* install defaults grid */
.install-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.install-grid .field { margin-bottom: 4px; }

/* line action buttons */
td.lineacts { white-space: nowrap; }
td.lineacts .btn { padding: 4px 7px; margin-left: 2px; }
#logo-preview img { border: 1px solid var(--line); border-radius: 4px; padding: 3px; background: #fff; }

/* swatch chips */
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.22); background-size: cover; background-position: center; vertical-align: middle; flex: 0 0 auto; }
.sw-none { background: repeating-linear-gradient(45deg,#eceff1,#eceff1 4px,#fafbfc 4px,#fafbfc 8px); }
.sw-row { display: flex; gap: 8px; align-items: center; }
.sw-row select { flex: 1; min-width: 0; }
.sw-line { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 11px; color: #555; }
.sw-line .sw { width: 15px; height: 15px; margin-right: 4px; }
.search-input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; font-family: var(--font); font-size: 14px; }
#dual-blackout-note { color: var(--blue); font-weight: 500; margin-bottom: 8px; }

/* ===== Mobile ===== */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .app-header { flex-wrap: wrap; padding: 8px 12px; gap: 8px 12px; }
  .app-header img.brand { height: 30px; }
  .app-header .company { font-size: 13px; }
  .app-header .total-pill { font-size: 13px; padding: 5px 12px; }
  .app-header nav { order: 3; width: 100%; justify-content: space-between; gap: 4px; }
  .app-header nav button { flex: 1; font-size: 12.5px; padding: 8px 6px; }
  .layout { padding: 0 10px; margin: 12px auto; gap: 12px; }
  .card { padding: 14px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .install-grid { grid-template-columns: 1fr; }
  #lines-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.lines { font-size: 12px; min-width: 540px; }
  .modal { padding: 18px 16px; }
  .modal-backdrop { padding: 16px 8px; }
  /* 16px inputs prevent iOS auto-zoom */
  .field input, .field select, .field textarea, .search-input { font-size: 16px; }
  .admin-dash-layout { grid-template-columns: 1fr !important; }
}
#lines-wrap { overflow-x: auto; }

/* ===== Print / PDF ===== */
@media print {
  body { background: #fff; font-size: 12px; }
  .app-header, .no-print, #form-card, .actions-bar, .app-header nav { display: none !important; }
  .layout { display: block; max-width: none; margin: 0; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; margin: 0; }
  #print-area { display: block !important; }
}
#print-area { display: none; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--blue); padding-bottom: 12px; margin-bottom: 16px; }
.print-head .ph-cust h2 { font-size: 20px; margin-bottom: 2px; }
.print-head .ph-meta { text-align: right; font-size: 12.5px; }
.print-head .ph-meta .qno { font-size: 17px; font-weight: 700; color: var(--blue); font-family: var(--font-head); }
table.print-lines { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
table.print-lines th { background: #f0f4f7; text-align: left; padding: 7px 9px; border-bottom: 2px solid var(--blue); font-size: 11px; text-transform: uppercase; }
table.print-lines td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.print-lines td.num { text-align: right; white-space: nowrap; }
.print-foot { margin-top: 18px; font-size: 12px; color: var(--muted); }
.print-foot .terms { margin-top: 8px; font-style: italic; }
