  :root{
    --ink:#12203a;
    --ink-soft:#5b6b85;
    --line:#e1e6ee;
    --paper:#ffffff;
    --canvas:#eef1f6;
    --brand:#2451a6;
    --brand-dark:#173a80;
    --accent:#f2a33e;
    --field-bg:#f7f9fc;
    --radius:10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }
  *{box-sizing:border-box;}
  body{
    margin:0;
    background:var(--canvas);
    color:var(--ink);
    padding:28px;
  }
  .app{
    max-width:1180px;
    margin:0 auto;
    display:grid;
    grid-template-columns: 400px 1fr;
    gap:24px;
    align-items:start;
  }
  @media (max-width: 880px){
    .app{grid-template-columns:1fr;}
  }

  /* ---- Panel (form) ---- */
  .panel{
    background:var(--paper);
    border:1px solid var(--line);
    border-radius:16px;
    padding:22px;
    position:sticky;
    top:20px;
  }
  .brand-row{
    display:flex;
    align-items:center;
    gap:10px;
    margin-bottom:18px;
  }
  .brand-mark{
    width:34px;height:34px;border-radius:9px;
    background:linear-gradient(135deg,var(--brand),var(--brand-dark));
    display:flex;align-items:center;justify-content:center;
    color:white;font-weight:800;font-size:15px;
    flex-shrink:0;
  }
  .brand-row h1{
    font-size:16px;
    margin:0;
    letter-spacing:0.2px;
  }
  .brand-row p{
    margin:1px 0 0;
    font-size:11.5px;
    color:var(--ink-soft);
  }

  .field-group{margin-bottom:16px;}
  .field-group label{
    display:block;
    font-size:11.5px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:0.5px;
    color:var(--ink-soft);
    margin-bottom:6px;
  }
  input[type=text], input[type=tel], select{
    width:100%;
    padding:10px 11px;
    border:1px solid var(--line);
    border-radius:8px;
    background:var(--field-bg);
    color:var(--ink);
    font-size:13.5px;
    font-family:inherit;
    outline:none;
    transition:border-color .15s;
  }
  input:focus, select:focus{
    border-color:var(--brand);
    background:white;
  }

  .logo-upload-row{
    display:flex;
    align-items:center;
    gap:10px;
  }
  .logo-preview{
    width:74px;
    height:54px;
    border:1px dashed var(--line);
    border-radius:8px;
    background:var(--field-bg);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:9.5px;
    color:var(--ink-soft);
    text-align:center;
    padding:4px;
    flex-shrink:0;
    overflow:hidden;
  }
  .logo-preview img{
    max-width:100%;
    max-height:100%;
    object-fit:contain;
  }
  .logo-upload-btns{
    display:flex;
    flex-direction:column;
    gap:6px;
    flex:1;
  }
  .logo-pick-btn{
    padding:8px 12px;
    font-size:12.5px;
    text-align:center;
    cursor:pointer;
  }
  .logo-upload-btns .btn{padding:8px 12px;font-size:12.5px;}

  .items-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:8px;
  }
  .items-head label{margin:0;}
  .add-btn{
    border:none;
    background:var(--brand);
    color:white;
    font-size:12px;
    font-weight:700;
    padding:6px 11px;
    border-radius:7px;
    cursor:pointer;
  }
  .add-btn:hover{background:var(--brand-dark);}

  .item-row{
    display:grid;
    grid-template-columns: 1fr 52px 78px 22px;
    gap:6px;
    margin-bottom:8px;
    align-items:center;
  }
  .item-row input, .item-row select{padding:8px 9px;font-size:12.5px;}
  .item-total-mini{
    font-size:11px;
    color:var(--ink-soft);
    text-align:right;
    padding-right:2px;
  }
  .remove-item{
    border:none;
    background:transparent;
    color:#c4433f;
    font-size:17px;
    cursor:pointer;
    line-height:1;
    padding:0;
  }
  .remove-item:disabled{opacity:0.25;cursor:not-allowed;}

  .subtotal-line{
    display:flex;
    justify-content:space-between;
    padding-top:12px;
    margin-top:6px;
    border-top:1px dashed var(--line);
    font-size:13.5px;
    font-weight:700;
  }

  .payment-fields{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
  }

  .actions{
    margin-top:20px;
    display:flex;
    flex-direction:column;
    gap:8px;
  }
  .btn{
    border:none;
    border-radius:9px;
    padding:12px 14px;
    font-size:13.5px;
    font-weight:700;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
  }
  .btn-primary{background:var(--ink);color:white;}
  .btn-primary:hover{background:#0b1526;}
  .btn-secondary{background:var(--field-bg);color:var(--ink);border:1px solid var(--line);}
  .btn-secondary:hover{background:#eef1f6;}
  .btn-ghost{
    background:transparent;
    color:var(--ink-soft);
    border:1px dashed var(--line);
    cursor:not-allowed;
  }
  .download-row{display:flex;gap:8px;}
  .download-row .btn{flex:1;}

  .manual-noinv-toggle{
    display:flex;
    align-items:center;
    justify-content:space-between;
    width:100%;
    background:transparent;
    border:none;
    color:var(--ink-soft);
    font-size:12px;
    font-weight:600;
    padding:8px 2px;
    cursor:pointer;
    font-family:inherit;
  }
  .manual-noinv-toggle:hover{color:var(--ink);}
  .manual-noinv-toggle .chevron{
    transition:transform .18s;
    flex-shrink:0;
  }
  .manual-noinv-toggle.open .chevron{transform:rotate(180deg);}

  .manual-noinv-panel{
    display:grid;
    grid-template-columns:1fr auto;
    gap:8px;
    max-height:0;
    opacity:0;
    overflow:hidden;
    margin-top:0;
    transition:max-height .2s ease, opacity .18s ease, margin-top .2s ease;
  }
  .manual-noinv-panel.open{
    max-height:60px;
    opacity:1;
    margin-top:6px;
  }
  .manual-noinv-panel input{
    padding:9px 10px;
    font-size:13px;
    min-width:0;
  }
  .manual-noinv-panel button{
    padding:9px 12px;
    font-size:12.5px;
    white-space:nowrap;
  }

  .hint{
    font-size:11px;
    color:var(--ink-soft);
    margin-top:4px;
    line-height:1.5;
  }

  /* ---- Preview / invoice ---- */
  .preview-wrap{
    display:flex;
    justify-content:center;
  }
  #invoice{
    width:640px;
    background:var(--paper);
    padding:48px 44px 40px;
    box-shadow:0 4px 24px rgba(18,32,58,0.08);
    border-radius:4px;
  }
  .inv-top{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    padding-bottom:20px;
    border-bottom:2px solid var(--ink);
    margin-bottom:22px;
  }
  .inv-title{
    font-size:38px;
    font-weight:900;
    letter-spacing:0.5px;
    margin:0;
  }
  .inv-brandmark{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    max-width:220px;
    max-height:64px;
  }
  .inv-brandmark img{
    max-width:220px;
    max-height:64px;
    object-fit:contain;
    display:none;
  }
  .inv-brandmark #p-logo-placeholder{
    font-size:11px;
    color:var(--ink-soft);
    font-weight:600;
    border:1px dashed var(--line);
    border-radius:8px;
    padding:10px 14px;
  }
  .inv-meta{
    display:grid;
    grid-template-columns: 110px 1fr;
    row-gap:6px;
    font-size:13px;
    margin-bottom:24px;
  }
  .inv-meta .k{color:var(--ink-soft);}
  .inv-meta .v{font-weight:600;}

  table.inv-table{
    width:100%;
    border-collapse:collapse;
    margin-bottom:0;
    table-layout:fixed;
  }
  table.inv-table thead th{
    background:var(--brand);
    color:white;
    font-size:11.5px;
    text-transform:uppercase;
    letter-spacing:0.4px;
    padding:10px 12px;
    text-align:left;
    font-weight:700;
  }
  table.inv-table thead th.num-col{width:44px;text-align:center;}
  table.inv-table thead th.jml-col{width:56px;text-align:center;}
  table.inv-table thead th.harga-col{width:100px;text-align:right;}
  table.inv-table thead th.total-col{width:110px;text-align:right;}
  table.inv-table tbody td{
    padding:11px 12px;
    font-size:13px;
    border-bottom:1px solid var(--line);
  }
  table.inv-table tbody td.desk-col{
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
    line-height:1.35;
    overflow-wrap:break-word;
  }
  table.inv-table tbody td.num-col{text-align:center;color:var(--ink-soft);}
  table.inv-table tbody td.jml-col{text-align:center;}
  table.inv-table tbody td.harga-col{text-align:right;}
  table.inv-table tbody td.total-col{text-align:right;font-weight:600;}
  table.inv-table tbody tr.empty-row td{color:transparent;}

  .subtotal-box{
    display:flex;
    justify-content:flex-end;
    margin-top:0;
  }
  .subtotal-box .inner{
    display:flex;
    width:280px;
  }
  .subtotal-box .lbl{
    background:var(--brand);
    color:white;
    font-weight:700;
    font-size:13px;
    padding:12px 16px;
    flex:1;
  }
  .subtotal-box .amt{
    background:var(--ink);
    color:white;
    font-weight:800;
    font-size:14px;
    padding:12px 16px;
    text-align:right;
    width:140px;
  }

  .pay-info{
    margin-top:34px;
  }
  .pay-info h3{
    font-size:13.5px;
    margin:0 0 10px;
  }
  .pay-row{
    display:flex;
    gap:10px;
    font-size:13px;
    margin-bottom:4px;
  }
  .pay-row .plabel{font-weight:700;width:100px;}

  .footer-note{
    margin-top:30px;
    font-size:10.5px;
    color:var(--ink-soft);
    text-align:center;
  }

  .loading-overlay{
    display:none;
    position:fixed;inset:0;
    background:rgba(18,32,58,0.4);
    align-items:center;justify-content:center;
    z-index:50;
    color:white;font-size:14px;font-weight:600;
  }

  /* ---- Password gate ---- */
  .gate-overlay{
    position:fixed;
    inset:0;
    background:rgba(13,27,52,0.28);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:100;
    padding:20px;
  }
  .gate-box{
    background:var(--paper);
    border-radius:16px;
    padding:32px 30px;
    width:100%;
    max-width:340px;
    text-align:center;
    box-shadow:0 20px 50px rgba(0,0,0,0.35);
  }
  .gate-box .gate-mark{
    width:48px;height:48px;
    border-radius:12px;
    background:linear-gradient(135deg,var(--brand),var(--brand-dark));
    display:flex;align-items:center;justify-content:center;
    color:white;font-weight:800;font-size:19px;
    margin:0 auto 14px;
  }
  .gate-box h2{
    font-size:16px;
    margin:0 0 4px;
  }
  .gate-box p{
    font-size:12px;
    color:var(--ink-soft);
    margin:0 0 18px;
  }
  .gate-box input{
    width:100%;
    padding:11px 12px;
    border:1px solid var(--line);
    border-radius:8px;
    background:var(--field-bg);
    font-size:14px;
    text-align:center;
    letter-spacing:2px;
    outline:none;
    margin-bottom:10px;
  }
  .gate-box input:focus{border-color:var(--brand);background:white;}
  .gate-box button{
    width:100%;
    border:none;
    background:var(--ink);
    color:white;
    padding:11px 12px;
    border-radius:8px;
    font-size:13.5px;
    font-weight:700;
    cursor:pointer;
  }
  .gate-box button:hover{background:#0b1526;}
  .gate-error{
    font-size:12px;
    color:#c4433f;
    font-weight:600;
    margin-top:10px;
    min-height:16px;
  }
  body.locked{overflow:hidden;}
  body.locked .app{
    filter:blur(10px) brightness(0.85);
    pointer-events:none;
    user-select:none;
  }
