:root{
  --text:#111;
  --muted:#666;
  --line:#e8e8e8;
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: Arial, Helvetica, sans-serif;
  background:#f5f6f7;
  color:var(--text);
}

.toolbar{
  position:sticky;
  top:0;
  z-index:9999;
  background:#fff;
  border-bottom:1px solid var(--line);
  padding:10px 14px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.btn{
  border:1px solid var(--line);
  background:#fff;
  padding:9px 12px;
  border-radius:10px;
  cursor:pointer;
  font-weight:700;
}

.btn:hover{ background:#fafafa; }

.btn.primary{
  background:#111;
  color:#fff;
  border-color:#111;
}

.btn.good{
  background:#1f7a1f;
  color:#fff;
  border-color:#1f7a1f;
}

.btn.warn{
  background:#b94a00;
  color:#fff;
  border-color:#b94a00;
}

.hint{
  color:var(--muted);
  font-size:13px;
  flex:1;
  text-align:center;
}

.page{
  max-width:900px;
  margin:14px auto;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  padding:24px;
  position:relative;
  overflow:hidden;
  z-index:1;
}

.watermark{
  position:fixed;
  top:45%;
  left:50%;
  transform:translate(-50%, -50%) rotate(-18deg);
  pointer-events:none !important;
  user-select:none;
  font-size:90px;
  font-weight:900;
  letter-spacing:6px;
  color:rgba(0,0,0,0.08);
  text-transform:uppercase;
  white-space:nowrap;
  z-index:0;
}

.top{
  display:flex;
  justify-content:space-between;
  gap:14px;
  border-bottom:1px solid var(--line);
  padding-bottom:14px;
  position:relative;
  z-index:1;
}

.leftWrap{
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.logoLeft{
  height:68px;
  object-fit:contain;
  pointer-events:none;
}

.logoRight{
  height:60px;
  object-fit:contain;
  pointer-events:none;
}

.left h1{
  margin:0;
  font-size:28px;
  letter-spacing:1px;
}

.left .sub{
  margin-top:6px;
  color:var(--muted);
  font-size:14px;
  line-height:1.45;
}

.right{
  text-align:right;
  min-width:320px;
}

.rightTop{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:10px;
  margin-bottom:6px;
}

.right .title{
  font-size:34px;
  font-weight:900;
  margin:0;
}

.meta{
  display:grid;
  grid-template-columns:1fr auto;
  gap:6px 12px;
  font-size:14px;
  color:var(--muted);
}

.meta b{
  color:var(--text);
  font-weight:800;
}

.pill{
  display:inline-block;
  margin-top:10px;
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius:999px;
  font-size:14px;
}

.grid{
  display:grid;
  grid-template-columns:1.2fr 1fr;
  gap:14px;
  margin:16px 0;
  position:relative;
  z-index:1;
}

.box{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  position:relative;
  z-index:1;
}

.box h3{
  margin:0 0 10px 0;
  font-size:13px;
  color:var(--muted);
  letter-spacing:.6px;
  text-transform:uppercase;
}

.val{
  font-size:14px;
  line-height:1.55;
}

.mini{
  font-size:12px;
  color:var(--muted);
}

table{
  width:100%;
  border-collapse:collapse;
  margin-top:6px;
  position:relative;
  z-index:1;
}

thead th{
  text-align:left;
  font-size:13px;
  color:var(--muted);
  padding:10px;
  background:#fbfbfb;
  border-bottom:1px solid var(--line);
}

tbody td{
  padding:10px;
  border-bottom:1px solid var(--line);
  font-size:14px;
  vertical-align:top;
}

.num{ text-align:right; white-space:nowrap; }
.qty{ text-align:center; width:90px; }
.desc{ width:55%; }
.actions-col{ width:70px; text-align:right; }

.bottom{
  display:grid;
  grid-template-columns:1.2fr 0.8fr;
  gap:14px;
  margin-top:14px;
  position:relative;
  z-index:1;
}

.bottom > .box{
  padding:7px 10px;
}

.bottom > .box h3{
  margin:0 0 6px 0;
}

.bottom > .box .val{
  line-height:1.25;
}

.totals{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  position:relative;
  z-index:1;
}

.trow{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin:8px 0;
  font-size:14px;
  color:var(--muted);
}

.trow b{ color:var(--text); }

.grand{
  border-top:1px dashed var(--line);
  padding-top:10px;
  margin-top:10px;
  font-size:16px;
  font-weight:900;
  color:#000;
}

[contenteditable="true"]{
  outline:none;
  border-radius:6px;
}

[contenteditable="true"]:hover{ background:#fff7d6; }
[contenteditable="true"]:focus{ background:#fff2b8; }

.logosLeft{
  display:flex;
  align-items:center;
  gap:14px;
  position:relative;
}

.logo-aigen-front{
  position:relative;
  z-index:2;
}

.logo-konsen-back{
  position:relative;
  z-index:1;
  background:transparent;
  height:72px;
  margin-left:0;
}

.invoiceTitle{
  font-size:32px;
  font-weight:900;
  margin-bottom:6px;
}

.signature{
  display:flex;
  justify-content:flex-end;
  margin-top:40px;
}

.signature .box-sign{
  text-align:center;
  min-width:220px;
}

.signature .name{
  margin-top:60px;
  font-weight:700;
}

.signature .role{
  font-size:13px;
  color:var(--muted);
}

.page::before,
.page::after,
.estimate-page::before,
.estimate-page::after{
  pointer-events:none !important;
}

@media print{
  body{ background:#fff; }

  .page{
    border:none;
    border-radius:0;
    margin:0;
  }

  [contenteditable="true"]:hover,
  [contenteditable="true"]:focus{
    background:transparent;
  }

  th.actions-col,
  td.actions-col,
  .no-print,
  .toolbar{
    display:none !important;
  }
}