:root{
  --gold:#ff9f1c;
  --glass:rgba(255,255,255,.06);
  --border:rgba(255,255,255,.12);
  --ink:#1b1e24;
  --ink-soft:#5f6572;
  --line:#d8dde6;
  --paper:#ffffff;
  --paper-soft:#f7f9fc;
}

.invoice-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.75);
  display:none;
  justify-content:center;
  align-items:center;
  z-index:999;
}
.invoice-modal.show{ display:flex; }

.invoice-box{
  background:var(--paper);
  color:var(--ink);
  width:min(960px,92vw);
  max-height:90vh;
  overflow:auto;
  padding:28px 30px;
  border-radius:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
}

.invoice-header{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  margin-bottom:10px;
}
.invoice-header button{
  width:34px;
  height:34px;
  border-radius:50%;
  background:#fff4e5;
  border:1px solid #ffd8a8;
  color:#a05800;
  font-size:20px;
  line-height:1;
  cursor:pointer;
}

.section{ margin-top:22px; }
.section h4{
  margin:0 0 12px;
  padding:0 0 8px;
  font-size:14px;
  font-weight:700;
  letter-spacing:.02em;
  border-bottom:1px solid var(--line);
}

label{
  font-size:12px;
  color:var(--ink-soft);
  display:block;
  margin-bottom:6px;
  font-weight:600;
}
.section input,
.section textarea{
  width:100%;
  padding:10px 12px;
  margin-bottom:10px;
  border:1px solid var(--line);
  font-size:13px;
  border-radius:8px;
  background:var(--paper-soft);
  color:var(--ink);
}
.section input:focus,
.section textarea:focus{
  outline:none;
  border-color:#f0ae54;
  box-shadow:0 0 0 3px rgba(255,159,28,.16);
  background:#fff;
}

.grid3{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }

.type-switch{ display:flex; gap:20px; }
.type-switch label{ display:flex; align-items:center; gap:6px; margin-bottom:0; }

.quote-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:20px;
  border:1px solid var(--line);
  background:linear-gradient(135deg,#fffaf2,#ffffff);
  border-radius:12px;
  padding:14px 16px;
}
.quote-logo{
  width:125px;
  height:auto;
  display:block;
  margin-bottom:0;
}
.company-meta{
  text-align:right;
  font-size:12px;
  line-height:1.55;
  color:#333842;
}

.items-table-wrap{
  width:100%;
  overflow-x:auto;
}

#itemsTable{
  width:100%;
  min-width:820px;
  border-collapse:separate;
  border-spacing:0;
  margin-top:10px;
}
#itemsTable th,
#itemsTable td{
  border:0;
  border-bottom:1px solid #e3e7ef;
  padding:8px 6px;
  font-size:12px;
  vertical-align:top;
}
#itemsTable th{
  background:#f8fafc;
  color:#434a58;
  font-weight:700;
  border-top:1px solid #e3e7ef;
  border-bottom:1px solid #d7dde8;
}
#itemsTable input{
  width:100% !important;
  min-width:0 !important;
  margin:0 !important;
  padding:7px 8px !important;
  border:1px solid #d7dce6 !important;
  border-radius:6px !important;
  background:#fff !important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

#itemsTable .itm-item{ min-width:200px !important; }
#itemsTable .itm-type{ min-width:200px !important; }
#itemsTable .itm-desc,
#itemsTable .itm-brand{ min-width:220px !important; }
#itemsTable .itm-size{ min-width:110px !important; }
#itemsTable .itm-qty,
#itemsTable .itm-rate,
#itemsTable .itm-amt{ min-width:90px !important; }

.add-item{
  margin-top:10px;
  padding:8px 12px;
  cursor:pointer;
  border-radius:8px;
  border:1px solid #cfd6e3;
  background:#fff;
}

.total-box{ width:320px; margin-top:10px; margin-left:auto; }
.total-box label{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
  font-size:13px;
}
.total-box input{
  width:130px;
  text-align:right;
  border:1px solid var(--line) !important;
  border-radius:6px !important;
  background:#fff !important;
}
.grand{ font-weight:700; border-top:1px solid #ddd; padding-top:6px; }

.quote-footer{
  margin-top:12px;
  border-top:1px solid var(--line);
  padding-top:12px;
  font-size:12px;
  line-height:1.5;
  color:#3f4654;
}

.invoice-actions{ display:flex; gap:10px; margin-top:18px; }
.save,.print{
  color:#fff;
  padding:11px 18px;
  border:none;
  cursor:pointer;
  border-radius:10px;
  font-weight:700;
}
.save{ background:linear-gradient(135deg,#ffb347,#ff8b00); color:#1f1406; }
.print{ background:linear-gradient(135deg,#307adf,#1558b7); }

.quote-wrapper{ padding:0; overflow:hidden; }
.quote-header{
  display:grid;
  grid-template-columns:1.6fr 1.1fr 1.8fr 1.3fr 1fr 1.2fr;
  padding:14px 20px;
  font-size:13px;
  color:#ffcc80;
  border-bottom:1px solid var(--border);
  align-items:center;
}
.quote-body{ display:flex; flex-direction:column; }
.quote-row{
  display:grid;
  grid-template-columns:1.6fr 1.1fr 1.8fr 1.3fr 1fr 1.2fr;
  padding:16px 20px;
  font-size:14px;
  align-items:center;
  border-bottom:1px solid rgba(255,255,255,.06);
}
.quote-row .amount{ text-align:right; font-weight:700; color:var(--gold); }
.quote-actions{ display:flex; justify-content:flex-end; gap:10px; }
.quote-actions button{
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.15);
  color:#ffcc80;
  padding:6px 8px;
  border-radius:8px;
  cursor:pointer;
}
.quote-actions button:hover{ background:var(--gold); color:#000; }

.empty-state{ text-align:center; padding:60px 20px; opacity:.6; display:none; }
.empty-state i{ font-size:40px; color:var(--gold); margin-bottom:10px; }

body[data-quote-layout="spec-sheet"] .invoice-box{
  width:min(980px,94vw);
  padding:26px 28px 24px;
  border-radius:20px;
  background:
    radial-gradient(circle at top right, rgba(201,176,144,.18), transparent 28%),
    linear-gradient(180deg, #fffdf9 0%, #ffffff 100%);
  border:1px solid rgba(165,127,85,.18);
  box-shadow:0 24px 60px rgba(15,23,42,.16);
}

body[data-quote-layout="spec-sheet"] .invoice-header button{
  background:#fff;
}

body[data-quote-layout="spec-sheet"] .material-sheet-top{
  justify-content:center;
  border:none;
  border-radius:0;
  padding:8px 16px 2px;
  background:#fff;
}

body[data-quote-layout="spec-sheet"] .material-sheet-logo{
  width:150px;
  filter:drop-shadow(0 12px 20px rgba(120,86,45,.12));
}

body[data-quote-layout="spec-sheet"] .material-details-section,
body[data-quote-layout="spec-sheet"] .material-items-section,
body[data-quote-layout="spec-sheet"] .material-notes-section,
body[data-quote-layout="spec-sheet"] .material-sheet-footer{
  margin-top:14px;
}

body[data-quote-layout="spec-sheet"] .section h4{
  font-size:13px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:#7f5d36;
  border-bottom:1px solid rgba(166,132,91,.22);
  padding-bottom:10px;
}

body[data-quote-layout="spec-sheet"] .material-details-grid{
  gap:12px;
}

body[data-quote-layout="spec-sheet"] .material-total-box{
  display:none;
}

body[data-quote-layout="spec-sheet"] #quoteItemTitle{
  font-size:14px;
  font-weight:700;
  background:#fffdfa;
  border-radius:12px !important;
  border:1px solid rgba(166,132,91,.18) !important;
  box-shadow:0 8px 18px rgba(166,132,91,.08);
}

body[data-quote-layout="spec-sheet"] .material-details-section input,
body[data-quote-layout="spec-sheet"] .material-details-section textarea,
body[data-quote-layout="spec-sheet"] .material-notes-section textarea{
  background:#fff !important;
  border:1px solid rgba(166,132,91,.16) !important;
  border-radius:12px !important;
  box-shadow:0 10px 24px rgba(15,23,42,.05);
}

body[data-quote-layout="spec-sheet"] .material-details-section textarea,
body[data-quote-layout="spec-sheet"] .material-notes-section textarea{
  line-height:1.65;
}

body[data-quote-layout="spec-sheet"] #itemsTable{
  min-width:100%;
  border-collapse:collapse;
  margin-top:12px;
}

body[data-quote-layout="spec-sheet"] #itemsTable th,
body[data-quote-layout="spec-sheet"] #itemsTable td{
  border:1px solid #1f1f1f;
  padding:9px 10px;
  background:#fff;
}

body[data-quote-layout="spec-sheet"] #itemsTable th{
  background:linear-gradient(180deg,#fcf7ef 0%, #f8efe3 100%);
  color:#111;
  text-transform:uppercase;
  letter-spacing:.04em;
  font-size:11px;
}

body[data-quote-layout="spec-sheet"] #itemsTable input{
  border:none !important;
  background:transparent !important;
  border-radius:0 !important;
  padding:2px 0 !important;
  font-size:13px !important;
  min-width:0 !important;
  box-shadow:none !important;
}

body[data-quote-layout="spec-sheet"] #itemsTable td:last-child,
body[data-quote-layout="spec-sheet"] #itemsTable th:last-child{
  width:54px;
  text-align:center;
}

body[data-quote-layout="spec-sheet"] #itemsTable tbody tr{
  transition:background .18s ease, transform .18s ease;
}

body[data-quote-layout="spec-sheet"] #itemsTable tbody tr:hover{
  background:#fffaf2;
}

body[data-quote-layout="spec-sheet"] .add-item{
  margin-top:12px;
  border-radius:999px;
  padding:10px 16px;
  border:1px solid rgba(127,93,54,.35);
  font-weight:700;
  background:linear-gradient(180deg,#ffffff 0%,#fff5e7 100%);
  box-shadow:0 12px 24px rgba(127,93,54,.12);
}

body[data-quote-layout="spec-sheet"] .material-notes-section textarea{
  min-height:124px;
  line-height:1.65;
}

body[data-quote-layout="spec-sheet"] .material-sheet-footer{
  border:none;
  border-top:1px solid #cfcfcf;
  padding:14px 0 0;
  background:#fff;
  color:#4b5563;
}

body[data-quote-layout="spec-sheet"] .invoice-actions{
  margin-top:22px;
}

body[data-quote-layout="spec-sheet"] .save,
body[data-quote-layout="spec-sheet"] .print{
  border-radius:999px;
  padding:12px 18px;
  box-shadow:0 14px 28px rgba(15,23,42,.12);
}

@media print{
  @page{ size:A4; margin:14mm; }
  body{ background:#fff !important; color:#111 !important; font-family:Arial,Helvetica,sans-serif; }
  body *{ visibility:hidden !important; }
  .invoice-modal,.invoice-modal *{ visibility:visible !important; }
  .invoice-modal{ position:absolute; inset:0; background:none !important; display:block !important; }
  .invoice-box{ box-shadow:none !important; border:none !important; max-height:none !important; overflow:visible !important; width:100% !important; padding:0 !important; border-radius:0 !important; }

  .invoice-header{ display:none !important; }

  .invoice-header button,
  .invoice-actions,
  .add-item,
  #itemsTable tbody button,
  .quote-type-section{ display:none !important; }

  .quote-logo{ width:132px !important; margin-bottom:4px !important; }

  .section h4{ background:none !important; border:0 !important; border-bottom:1px solid #ccc !important; padding:0 0 4px 0 !important; }
  .section input,.section textarea{ border:none !important; border-bottom:1px solid #ddd !important; border-radius:0 !important; padding:4px 0 !important; background:transparent !important; }
  .items-table-wrap{ overflow:visible !important; }
  #itemsTable th,#itemsTable td{
    border:0 !important;
    border-bottom:1px solid #8e8e8e !important;
    font-size:11px !important;
    padding:4px 6px !important;
    background:#fff !important;
  }
  #itemsTable th{
    font-weight:700 !important;
    color:#111 !important;
    border-top:1px solid #7a7a7a !important;
    border-bottom:1px solid #7a7a7a !important;
  }
  #itemsTable input{
    width:100% !important;
    border:none !important;
    background:transparent !important;
    box-shadow:none !important;
    padding:0 !important;
    margin:0 !important;
    font-size:11px !important;
    line-height:1.25 !important;
  }
  .total-box input{
    border:none !important;
    background:transparent !important;
    box-shadow:none !important;
    padding:0 !important;
  }
  .type-switch input{
    transform:scale(.9);
  }
  .quote-top{
    border:1px solid #ddd !important;
    background:#fff !important;
    border-radius:8px !important;
    padding:10px 12px !important;
  }
  .company-meta{ color:#111 !important; }
  tr{ page-break-inside:avoid; }

  body[data-quote-layout="spec-sheet"] .invoice-box{
    padding:0 !important;
    background:#fff !important;
    border:none !important;
    box-shadow:none !important;
  }

  body[data-quote-layout="spec-sheet"] .material-sheet-top{
    border:none !important;
    border-radius:0 !important;
    padding:4px 0 0 !important;
  }

  body[data-quote-layout="spec-sheet"] #itemsTable th,
  body[data-quote-layout="spec-sheet"] #itemsTable td{
    border:0 !important;
    border-bottom:1px solid #9a9a9a !important;
    padding:4px 6px !important;
    font-size:10.5px !important;
  }

  body[data-quote-layout="spec-sheet"] #itemsTable th:last-child,
  body[data-quote-layout="spec-sheet"] #itemsTable td:last-child{
    display:none !important;
  }

  body[data-quote-layout="spec-sheet"] #itemsTable input{
    font-size:10.5px !important;
  }

  body[data-quote-layout="spec-sheet"] .material-sheet-footer{
    border:none !important;
    border-top:1px solid #bdbdbd !important;
    padding:10px 0 0 !important;
    background:#fff !important;
  }

  body[data-quote-layout="spec-sheet"] .quote-top{
    border:none !important;
    background:#fff !important;
    padding:0 0 8px !important;
  }

  body[data-quote-layout="spec-sheet"] .material-details-section input,
  body[data-quote-layout="spec-sheet"] .material-details-section textarea,
  body[data-quote-layout="spec-sheet"] .material-notes-section textarea{
    background:transparent !important;
    box-shadow:none !important;
    border:0 !important;
    border-bottom:1px solid #c7c7c7 !important;
    border-radius:0 !important;
    padding:4px 0 !important;
  }
}

@media(max-width:700px){
  .quote-header{ display:none; }
  .quote-row{ grid-template-columns:1fr; gap:8px; }
  .quote-row .amount{ text-align:left; }
  .quote-actions{ justify-content:flex-start; }
  .total-box{ width:100%; }
  .grid3{ grid-template-columns:1fr; }
  .quote-top{ flex-direction:column; }
  .company-meta{ text-align:left; }
}

@media (max-width: 520px){
  .invoice-modal{
    align-items:flex-start;
    padding:10px;
  }

  .invoice-box{
    width:100%;
    max-height:calc(100vh - 20px);
    padding:16px 14px;
    border-radius:12px;
  }

  .type-switch{
    flex-direction:column;
    gap:10px;
  }

  .invoice-actions{
    flex-direction:column;
  }

  .save,.print{
    width:100%;
  }
}
