@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800&family=Roboto:wght@400;700&display=swap');

:root{
  --ink:#1a1a1a;
  --gold-text:#c9a227;
  --gold-deep:#a9821e;
  --gold-border:#c9a227;
  --gold-light:#e8c874;
  --gray-block:#eeeeee;
  --gray-stripe:#f3f3f3;
  --gray-border:#bfbfbf;
  --blue-fill:#dce6f7;
  --blue-fill-2:#e4e9f9;
  --blue-border:#4f81bd;
  --tan-total:#dbbf7a;
  --cream-box:#f3eee0;
  --black:#000000;

  --app-bg:#f4f5f7;
  --panel-bg:#ffffff;
  --panel-border:#e4e2da;
  --text-main:#2a2a2a;
  --text-muted:#767267;
  --shell-accent:#c9a227;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:'Segoe UI', Calibri, Arial, sans-serif;
  background:var(--app-bg);
  color:var(--text-main);
  min-height:100vh;
}

/* ============ LOCK SCREEN ============ */
.app-locked{display:none;}

.lock-screen{
  position:fixed;
  inset:0;
  z-index:1000;
  background:radial-gradient(circle at 50% 20%, #1c1a14, #0c0b08 70%);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.lock-card{
  width:100%;
  max-width:380px;
  background:#fffefb;
  border-radius:16px;
  padding:34px 32px 28px;
  text-align:center;
  box-shadow:0 24px 60px rgba(0,0,0,.45);
  border:1px solid rgba(201,162,39,.35);
}
.lock-logo img{width:56px;height:auto;margin-bottom:10px;}
.lock-title{
  font-family:'Playfair Display',Georgia,serif;
  font-weight:800;
  font-size:19px;
  color:#1a1a1a;
}
.lock-sub{
  font-size:10.5px;
  letter-spacing:.6px;
  color:var(--text-muted);
  margin-top:2px;
  margin-bottom:22px;
}
#lockForm label{
  font-size:12px;
  font-weight:600;
  color:#4a4740;
  margin-bottom:6px;
  text-align:left;
}
#lockForm input[type=password]{
  width:100%;
  padding:11px 12px;
  border:1px solid #d9d5c8;
  border-radius:8px;
  font-size:14px;
  margin-bottom:8px;
  background:#fff;
  text-align:center;
  letter-spacing:2px;
}
#lockForm input[type=password]:focus{
  outline:none;
  border-color:var(--gold-border);
  box-shadow:0 0 0 3px rgba(201,162,39,.15);
}
.lock-error{
  color:#b23b3b;
  font-size:12px;
  font-weight:600;
  margin:-2px 0 10px;
}
.lock-btn{
  width:100%;
  background:linear-gradient(135deg,#e7c766,#c9a227 60%,#a9821e);
  color:#191400;
  border:none;
  padding:12px 16px;
  border-radius:9px;
  font-weight:800;
  font-size:14px;
  cursor:pointer;
  box-shadow:0 4px 14px rgba(169,130,30,.35);
}
.lock-btn:hover{filter:brightness(1.05);}
.lock-btn:active{transform:translateY(1px);}
.lock-remember{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  margin-top:16px;
  font-size:12px;
  font-weight:500;
  color:#65614f;
  cursor:pointer;
}
.lock-remember input{width:14px;height:14px;cursor:pointer;}

/* ============ APP SHELL ============ */
.topbar{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 28px;
  background:#111111;
  color:#fff;
  border-bottom:3px solid var(--gold-border);
}
.topbar .brand-mark{
  width:36px;height:36px;
  background:linear-gradient(145deg,#f3d98a,#c9962f 55%,#8a6414);
  border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  font-family:'Playfair Display',serif;
  font-weight:800;
  color:#1a1400;
  font-size:16px;
  letter-spacing:-1px;
}
.topbar h1{
  font-size:18px;
  margin:0;
  font-weight:700;
  letter-spacing:.3px;
}
.topbar .sub{
  font-size:11.5px;
  color:#cfc7ad;
  margin-top:1px;
  letter-spacing:.5px;
}
.topbar .spacer{flex:1;}
.topbar .badge{
  font-size:11px;
  color:#111;
  background:var(--gold-border);
  padding:4px 10px;
  border-radius:20px;
  font-weight:700;
  letter-spacing:.4px;
}

.shell{
  max-width:1500px;
  margin:0 auto;
  padding:22px 24px 60px;
}

/* ============ TEMPLATE PICKER ============ */
.step-label{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:1.2px;
  color:var(--text-muted);
  font-weight:700;
  margin:0 0 10px 2px;
}
.template-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin-bottom:26px;
}
@media (max-width:1100px){
  .template-grid{grid-template-columns:repeat(2,1fr);}
}
.template-card{
  background:var(--panel-bg);
  border:1.5px solid var(--panel-border);
  border-radius:12px;
  padding:16px 16px 14px;
  cursor:pointer;
  text-align:left;
  transition:box-shadow .15s ease, border-color .15s ease, transform .15s ease;
  display:flex;
  flex-direction:column;
  gap:8px;
  position:relative;
  overflow:hidden;
}
.template-card:hover{
  transform:translateY(-2px);
  box-shadow:0 8px 22px rgba(0,0,0,.08);
  border-color:var(--gold-border);
}
.template-card.active{
  border-color:var(--gold-border);
  box-shadow:0 0 0 2px var(--gold-border) inset, 0 10px 24px rgba(0,0,0,.10);
  background:#fffdf5;
}
.template-card .tc-icon{
  width:38px;height:38px;
  border-radius:9px;
  background:#111;
  color:var(--gold-border);
  display:flex;align-items:center;justify-content:center;
  font-weight:800;
  font-size:14px;
  font-family:'Playfair Display',serif;
}
.template-card .tc-title{
  font-weight:700;
  font-size:14.5px;
  color:var(--text-main);
}
.template-card .tc-desc{
  font-size:12px;
  color:var(--text-muted);
  line-height:1.4;
}
.template-card .tc-check{
  position:absolute;
  top:12px;right:12px;
  width:20px;height:20px;
  border-radius:50%;
  background:var(--gold-border);
  color:#111;
  font-size:12px;
  display:none;
  align-items:center;justify-content:center;
  font-weight:900;
}
.template-card.active .tc-check{display:flex;}

/* ============ WORKSPACE ============ */
.workspace{
  display:none;
  grid-template-columns:minmax(360px,440px) 1fr;
  gap:20px;
  align-items:start;
}
.workspace.visible{display:grid;}

.panel{
  background:var(--panel-bg);
  border:1px solid var(--panel-border);
  border-radius:12px;
  overflow:hidden;
}
.panel-head{
  padding:14px 18px;
  border-bottom:1px solid var(--panel-border);
  display:flex;align-items:center;justify-content:space-between;
  background:#fbfaf6;
}
.panel-head h2{
  font-size:14px;
  margin:0;
  font-weight:700;
  color:var(--text-main);
}
.panel-body{
  padding:18px;
  max-height:calc(100vh - 170px);
  overflow-y:auto;
}

.field-group{margin-bottom:18px;}
.field-group legend{
  font-size:11.5px;
  text-transform:uppercase;
  letter-spacing:.9px;
  font-weight:700;
  color:var(--gold-deep);
  margin-bottom:8px;
  padding:0;
  border:0;
}
.field-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:10px;
}
.field-row.single{grid-template-columns:1fr;}
label{
  display:block;
  font-size:12px;
  font-weight:600;
  color:#4a4740;
  margin-bottom:4px;
}
input[type=text],input[type=number],input[type=date],textarea{
  width:100%;
  padding:8px 10px;
  border:1px solid #d9d5c8;
  border-radius:7px;
  font-size:13px;
  font-family:inherit;
  background:#fffefb;
  color:#1a1a1a;
}
input:focus,textarea:focus{
  outline:none;
  border-color:var(--gold-border);
  box-shadow:0 0 0 3px rgba(201,162,39,.15);
}
textarea{resize:vertical;min-height:54px;}

.line-items-editor{
  border:1px solid #e5e1d3;
  border-radius:9px;
  overflow:hidden;
  margin-bottom:8px;
}
.line-items-editor .li-head{
  display:grid;
  background:#111;
  color:var(--gold-border);
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.4px;
}
.line-items-editor .li-head > div, .li-row > div{
  padding:7px 8px;
}
.li-row{
  display:grid;
  align-items:center;
  border-top:1px solid #eee;
}
.li-row:nth-child(even){background:#fafaf8;}
.li-row input{border:1px solid #ddd8c8;padding:5px 7px;font-size:12.5px;}
.li-row .li-del{
  background:none;border:none;color:#b23b3b;cursor:pointer;font-size:15px;
  justify-self:center;
}
.btn-add-row{
  display:inline-flex;align-items:center;gap:6px;
  background:#111;color:var(--gold-border);
  border:none;padding:8px 14px;border-radius:7px;
  font-size:12.5px;font-weight:700;cursor:pointer;
  margin-top:4px;
}
.btn-add-row:hover{background:#242424;}

.btn-row{display:flex;gap:10px;margin-top:6px;}
.btn-secondary{
  background:#fff;border:1.5px solid #d9d5c8;color:#444;
  padding:9px 14px;border-radius:8px;font-size:12.5px;font-weight:600;cursor:pointer;
}
.btn-secondary:hover{border-color:var(--gold-border);color:var(--gold-deep);}

/* ============ PREVIEW PANEL ============ */
.preview-panel .panel-body{
  background:#e9e8e2;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:26px 20px 40px;
  max-height:calc(100vh - 170px);
  overflow:auto;
}
.download-bar{
  display:flex;
  gap:10px;
  margin-bottom:18px;
  width:100%;
  max-width:820px;
  justify-content:flex-end;
}
.btn-download{
  background:linear-gradient(135deg,#e7c766,#c9a227 60%,#a9821e);
  color:#191400;
  border:none;
  padding:11px 20px;
  border-radius:9px;
  font-weight:800;
  font-size:13.5px;
  cursor:pointer;
  display:flex;align-items:center;gap:8px;
  box-shadow:0 4px 14px rgba(169,130,30,.35);
}
.btn-download:hover{filter:brightness(1.05);}
.btn-download:active{transform:translateY(1px);}

.sheet-wrap{
  background:#fff;
  box-shadow:0 10px 40px rgba(0,0,0,.22);
}

/* ============ THE DOCUMENT (A4 @ 96dpi = 794 x 1123px) ============ */
.doc{
  width:794px;
  min-height:1123px;
  background:#ffffff;
  position:relative;
  padding:24px 24px 0;
  font-family:Calibri,'Segoe UI',Candara,Arial,sans-serif;
  color:#000;
}
.doc-inner-border{
  border:1.6px solid var(--gold-border);
  min-height:1055px;
  display:flex;
  flex-direction:column;
}

.doc-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  padding:18px 20px 14px;
}
.doc-brand{display:flex;gap:12px;align-items:flex-start;}
.doc-logo{width:58px;height:auto;flex-shrink:0;margin-top:2px;}
.doc-company-name{
  font-family:'Playfair Display',Georgia,serif;
  font-weight:800;
  font-size:22px;
  line-height:1.12;
  color:#111;
}
.doc-company-name.stacked span{display:block;}
.doc-divider{height:11px;margin:6px 0 5px;display:block;}
.doc-tagline{
  font-size:9px;
  letter-spacing:.2px;
  color:#111;
  line-height:1.35;
  font-weight:400;
}

.doc-badge-col{display:flex;flex-direction:column;align-items:flex-end;gap:8px;min-width:190px;}
.doc-badge-tag{
  background:#000;
  clip-path:polygon(16% 0, 100% 0, 100% 100%, 0 100%);
  padding:9px 20px 9px 28px;
  height:34px;
  box-sizing:content-box;
  display:flex;align-items:center;justify-content:center;
  white-space:nowrap;
}
.doc-badge-tag .badge-text{
  color:var(--gold-text);
  font-family:Arial,'Arial Black',sans-serif;
  font-weight:800;
  font-size:19px;
  letter-spacing:1.2px;
}
.doc-meta-group{display:flex;flex-direction:column;gap:0;min-width:170px;}
.doc[data-template="licence"] .doc-meta-group{border:1px solid var(--gold-border);}
.doc-meta-row{
  display:flex;align-items:center;gap:7px;
  background:#f2f2f2;
  padding:5px 10px;
  min-width:170px;
}
.doc-meta-row img{width:14px;height:auto;}
.doc-meta-row .lbl{font-size:10.5px;font-weight:700;color:#000;}
.doc-meta-row .val{font-size:9.5px;text-decoration:underline;color:#000;margin-left:auto;}

.doc-divider-thin{height:2px;background:var(--gold-border);margin:0 20px;}

.doc-title{
  text-align:center;
  font-weight:700;
  font-size:15px;
  padding:16px 20px 4px;
  color:#000;
}
.doc-subtitle{text-align:center;font-size:10.5px;margin-top:2px;color:#000;}

.doc-body{padding:10px 20px 0;flex:1;display:flex;flex-direction:column;}

/* info tables (billed to / services detail / payee) */
.info-tables{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:22px;
  margin-bottom:16px;
}
.info-table{border:1px solid var(--gray-border);}
.info-table .it-head{
  background:#000;
  color:var(--gold-text);
  font-weight:700;
  font-size:11px;
  text-align:center;
  padding:6px 8px;
}
.info-table .it-row{
  display:flex;
  background:var(--gray-block);
  border-top:1px solid #fff;
  min-height:22px;
}
.info-table .it-row:first-child{border-top:none;}
.info-table .it-label{
  width:44%;
  font-size:9px;
  padding:5px 8px;
  color:#000;
  font-weight:400;
  display:flex;align-items:center;
}
.info-table .it-value{
  width:56%;
  font-size:9.5px;
  padding:5px 8px;
  color:#000;
  border-left:1px solid #ccc;
  display:flex;align-items:center;
  word-break:break-word;
}

/* items table */
.items-table{width:100%;border-collapse:collapse;margin-bottom:0;}
.items-table thead th{
  background:#000;
  color:var(--gold-text);
  font-weight:700;
  font-size:11px;
  padding:8px 10px;
  text-align:left;
}
.items-table thead th.num{text-align:right;}
.items-table tbody td{
  font-size:10px;
  padding:6px 10px;
  border-bottom:1px solid #e6e6e6;
  color:#000;
}
.items-table tbody tr:nth-child(even){background:var(--gray-stripe);}
.items-table td.num{text-align:right;font-variant-numeric:tabular-nums;}
.items-table td.desc-cell{width:52%;}
.items-table .row-del{
  background:none;border:none;color:#b23b3b;cursor:pointer;font-size:13px;
}
.items-total-row{
  display:flex;justify-content:flex-end;gap:26px;
  padding:9px 10px;
  font-weight:700;
  font-size:10.5px;
  font-family:Roboto,Arial,sans-serif;
  border-top:1px solid #ccc;
}
.items-total-row .tot-label{color:#000;}
.items-total-row .tot-val{min-width:70px;text-align:right;}

.doc-terms{margin-top:auto;}
.doc-terms .tc-head{
  background:#000;color:var(--gold-text);
  text-align:center;font-weight:700;font-size:11px;
  padding:6px 8px;margin-top:18px;
}
.doc-terms ol{
  list-style:none;counter-reset:term;
  padding:10px 0 0;margin:0;font-size:9.5px;font-weight:700;line-height:1.85;
}
.doc-terms ol li{counter-increment:term;}
.doc-terms ol li::before{content:counter(term)". ";}
.doc-signature{font-size:9.5px;font-weight:700;margin:16px 0 10px;}

.doc-footer{margin-top:16px;}
.doc-footer img{width:100%;display:block;}

/* ---- Receipt / Invoice specifics ---- */
.doc[data-template="receipt"] .doc-company-name{font-size:20px;}
.instructions-box{
  background:var(--cream-box);
  padding:16px 20px 20px;
  text-align:center;
  margin-top:14px;
}
.instructions-box .ib-head{
  background:#000;color:var(--gold-text);
  font-weight:700;font-size:11px;text-align:center;
  padding:6px 8px;margin:-16px -20px 14px;
}
.instructions-box .ib-line1{font-weight:700;font-size:9.5px;margin-bottom:10px;}
.instructions-box .ib-line2{font-weight:700;font-size:9.5px;}

/* ---- Licence / Combined Quotation specifics ---- */
.licence-frame{
  border:1.4px solid var(--blue-border);
  margin-top:8px;
}
.licence-top{
  display:grid;grid-template-columns:1fr 1fr;
}
.licence-cell{border-bottom:1px solid var(--blue-border);}
.licence-cell:first-child{border-right:1px solid var(--blue-border);}
.licence-label{
  background:var(--blue-fill);
  font-size:9.5px;font-weight:700;padding:5px 10px;
}
.licence-value{
  background:var(--blue-fill-2);
  min-height:30px;font-size:9.5px;padding:6px 10px;
}
.licence-customer{border-top:1px solid var(--blue-border);}

.licence-title{text-align:center;padding:14px 10px 2px;font-weight:700;font-size:15px;}
.licence-subtitle-wrap{text-align:center;padding-bottom:8px;}
.licence-subtitle-wrap input{
  text-align:center;border:none;background:transparent;font-size:10.5px;
  width:60%;margin:0 auto;
}

.visa-tables{display:grid;grid-template-columns:1fr 1fr;gap:0;border-top:1px solid var(--gold-border);}
.visa-col{border-right:1px solid var(--gold-border);}
.visa-col:last-child{border-right:none;}
.visa-head{background:#000;color:var(--gold-text);text-align:center;font-weight:700;font-size:10.5px;padding:6px;}
.visa-subhead{display:flex;border-bottom:1px solid var(--gray-border);}
.visa-subhead div{font-size:9px;font-weight:700;padding:5px 8px;}
.visa-subhead .vs-desc{width:60%;}
.visa-subhead .vs-price{width:40%;text-align:right;}
.visa-rows{width:100%;border-collapse:collapse;background:var(--gray-block);}
.visa-rows td{font-size:9.5px;padding:5px 8px;border:1px solid #000;}
.visa-rows td.vprice{text-align:right;width:40%;}
.visa-rows td.vdesc{width:60%;}
.visa-total{
  display:flex;justify-content:space-between;
  background:var(--tan-total);
  font-weight:700;font-size:9.5px;padding:6px 8px;
}

.licence-notes{
  min-height:40px;background:var(--blue-fill-2);
  border:1.4px solid var(--blue-border);
  margin-top:10px;padding:6px 10px;font-size:9.5px;
}
.licence-sign{
  display:flex;justify-content:flex-end;align-items:center;gap:8px;
  margin-top:8px;font-size:9px;
}
.licence-sign .sig-box{
  width:130px;height:20px;background:var(--blue-fill-2);
  border:1px solid var(--blue-border);
}
.licence-thanks{
  text-align:center;
  font-family:Georgia,'Times New Roman',serif;
  font-style:italic;font-weight:700;
  color:var(--gold-deep);
  font-size:13px;margin:18px 0 8px;
}

/* utility for editable inline preview fields (kept for potential future use) */
.hidden{display:none !important;}

/* print isolation helper */
#pdf-render-root{position:absolute;left:-99999px;top:0;}

footer.app-footer{
  text-align:center;
  color:var(--text-muted);
  font-size:11.5px;
  padding:30px 0 10px;
}
