/* ==========================================================================
   1. VARIABEL & DASAR (RESET & BASE STYLES)
   ========================================================================== */
* {
  box-sizing: border-box;
}

:root {
  --ink: #233044;
  --muted: #738095;
  --line: #e5e9f0;
  --accent: #2357a5;
  --bg: #f4f6fa;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Arial, Helvetica, sans-serif;
}

footer {
  text-align: center;
  color: #98a2b3;
  font-size: 12px;
  padding: 20px;
}

/* ==========================================================================
   2. NAVIGASI UTAMA & LAYOUT SIDEBAR
   ========================================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 235px;
  background: #17253b;
  color: #fff;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-size: 20px;
  letter-spacing: 1px;
}

.brand b {
  color: #8db8ff;
}

.brand-block {
  text-align: center;
}

.brand-block img {
  display: block;
  width: 105px;
  height: auto;
  max-height: 105px;
  object-fit: contain;
  margin: 0 auto 8px;
}

.brand-name {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  margin-bottom: 3px;
}

.small {
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.sidebar .muted {
  color: #a7b4c7;
}

nav {
  display: grid;
  gap: 7px;
  margin-top: 35px;
}

nav a {
  color: #cbd5e4;
  text-decoration: none;
  padding: 11px 13px;
  border-radius: 9px;
}

nav a:hover,
nav a.active {
  background: #2a3c58;
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  color: #91a1b8;
  font-size: 12px;
}

/* ==========================================================================
   3. AREA UTAMA & KOMPONEN UI (STATS, TABLES, FORMS)
   ========================================================================== */
.main {
  margin-left: 235px;
  padding: 28px;
  max-width: 1600px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 27px;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill,
.status {
  background: #e9f1ff;
  color: #24539a;
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 12px;
}

.status.paid {
  background: #e7f7ed;
  color: #18743a;
}

.status.unpaid {
  background: #fff4df;
  color: #946200;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 21px;
  box-shadow: 0 3px 12px #14213b08;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 23px;
  margin-top: 8px;
}

.panel {
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 17px;
  margin: 0 0 17px;
}

.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
}

.section-head {
  margin: 25px 0 13px;
}

.btn {
  border: 1px solid #d5dce7;
  background: #fff;
  color: #26354b;
  padding: 10px 14px;
  border-radius: 8px;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn:hover {
  filter: brightness(0.97);
}

.small-btn {
  padding: 6px 8px;
  font-size: 11px;
}

/* Form & Input */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.form-grid label,
.block-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
}

.form-grid input,
.form-grid textarea,
.form-grid select,
.block-label textarea,
.searchbar input {
  width: 100%;
  border: 1px solid #d8dfeb;
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: 14px Arial;
}

.form-grid textarea,
.block-label textarea {
  resize: vertical;
}

.span2 {
  grid-column: span 2;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 9px;
  margin-top: 4px;
}

.notice {
  padding: 11px 13px;
  border-radius: 8px;
  background: #edf6ff;
  color: #24558d;
  margin-bottom: 17px;
  font-size: 13px;
}

.searchbar {
  display: flex;
  gap: 8px;
  margin-bottom: 17px;
}

.searchbar input {
  max-width: 440px;
}

.status-form {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.status-form select {
  max-width: 135px;
  padding: 6px 7px;
  border: 1px solid #d8dfeb;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
}

.block-label {
  margin-bottom: 18px;
}

/* Tabel */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  background: #f7f9fc;
  color: #59677c;
  font-weight: 600;
}

td,
th {
  padding: 12px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.text-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.table-scroll {
  overflow-x: auto;
}

.items-table {
  min-width: 1000px;
}

.items-table input,
.items-table select,
.items-table textarea {
  width: 100%;
  min-width: 70px;
  padding: 7px;
  border: 1px solid #d8dfeb;
  border-radius: 5px;
  font: 12px Arial;
}

.items-table td {
  padding: 7px;
}

.items-table th {
  white-space: nowrap;
}

.remove-row {
  border: 0;
  background: #fff0f0;
  color: #b42318;
  border-radius: 5px;
  font-size: 20px;
  cursor: pointer;
}

.totals-box {
  margin: 20px 0 20px auto;
  max-width: 380px;
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.totals-box .grand {
  font-size: 18px;
  border-bottom: 2px solid var(--ink);
}

/* ==========================================================================
   4. TEMPLATE INVOICE & WATERMARK LUNAS
   ========================================================================== */
.print-body {
  background: #edf0f5;
  padding: 25px;
}

.print-actions {
  max-width: 210mm;
  margin: 0 auto 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.invoice-paper {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 17mm 17mm 15mm;
  position: relative;
  color: #242424;
  font: 11px/1.45 Arial, Helvetica, sans-serif;
  box-shadow: 0 3px 20px #00000012;
  overflow: hidden;
  isolation: isolate;
}

.print-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #164f83;
  font-size: 18px;
}

.print-brand img {
  width: 62px;
  height: 62px;
  object-fit: contain;
}

.print-payment-status {
  text-align: right;
  font-size: 11px;
  margin: -4px 0 14px;
  color: #333;
}

.invoice-title {
  font-size: 28px;
  font-weight: 700;
  text-align: right;
  margin-bottom: 12px;
}

.invoice-meta {
  width: 56%;
  margin-left: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 25px;
}

.invoice-meta div {
  display: grid;
  grid-template-columns: 42% 58%;
  gap: 10px;
}

.invoice-meta span {
  color: #555;
  text-align: right;
}

.invoice-meta b {
  font-weight: 500;
  text-align: right;
}

.bill-label {
  text-align: right;
  font-weight: bold;
  margin: 0 0 8px;
}

.party-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
  margin-bottom: 24px;
  min-height: 85px;
}

.issuer,
.customer {
  white-space: normal;
}

.customer {
  text-align: left;
}

.issuer strong,
.customer strong {
  font-size: 12px;
}

.issuer-logo {
  margin: 0 0 5px;
}

.issuer-logo img {
  display: block;
  width: 100px;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.issuer-name {
  display: inline-block;
  font-size: 13px !important;
  color: #17365d;
}

.product-heading {
  font-size: 15px;
  font-weight: bold;
  margin: 10px 0 8px;
}

.print-table {
  table-layout: fixed;
  font-size: 10px;
}

.print-table th {
  background: #f0f2f5 !important;
  color: #222;
  padding: 8px 5px;
  border-bottom: 1px solid #bfc5ce;
}

.print-table td {
  padding: 10px 5px;
  border-bottom: 1px solid #e3e5e8;
  overflow-wrap: anywhere;
}

.print-table th:nth-child(1) { width: 34%; }
.print-table th:nth-child(2) { width: 7%; }
.print-table th:nth-child(3) { width: 8%; }
.print-table th:nth-child(4) { width: 14%; }
.print-table th:nth-child(5) { width: 8%; }
.print-table th:nth-child(6) { width: 8%; }
.print-table th:nth-child(7) { width: 21%; }

.num {
  text-align: right;
  white-space: nowrap;
}

.description {
  margin-top: 4px;
  white-space: pre-line;
}

.summary {
  width: 58%;
  margin: 15px 0 0 auto;
  font-size: 11px;
}

.summary div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 5px 0;
}

.summary span {
  text-align: right;
}

.summary b {
  min-width: 125px;
  text-align: right;
  font-weight: 500;
}

.summary .total {
  border-top: 1px solid #bfc5ce;
  border-bottom: 1px solid #bfc5ce;
  font-size: 13px;
  font-weight: bold;
}

.summary .total b,
.summary .amount-due b {
  font-weight: bold;
}

.summary .amount-due {
  font-size: 12px;
  font-weight: bold;
  margin-top: 3px;
}

.notes {
  margin-top: 28px;
  white-space: normal;
}

.notes strong {
  display: block;
  margin-bottom: 8px;
}

.notes div {
  white-space: pre-line;
}

.signature {
  margin: 45px 0 0 auto;
  width: 42%;
  text-align: center;
  color: #555;
  min-height: 30px;
}

.signature div {
  border-top: 1px solid #aaa;
  padding-top: 6px;
}

/* Watermark Lunas */
.invoice-paper > *:not(.paid-watermark) {
  position: relative;
  z-index: 1;
}

.paid-watermark,
.invoice-paper .paid-watermark {
  position: absolute !important;
  z-index: 50 !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) rotate(-30deg) !important;
  font-family: Arial, Helvetica, sans-serif;
  
  /* PERUBAHAN ADA DI SINI (Contoh diperbesar ke rentang 80px - 140px) */
  font-size: clamp(90px, 22mm, 240px) !important; 
    line-height: 1 !important;
  font-weight: 900 !important;
  letter-spacing: 5mm !important; /* Disesuaikan sedikit agar jarak huruf lebih luas */
  color: rgba(13, 133, 66, 0.17) !important;
  border: 1.5mm solid rgba(13, 133, 66, 0.17) !important;
  padding: 4mm 10mm !important;
  white-space: nowrap !important;
  pointer-events: none !important;
  mix-blend-mode: multiply;
  max-width: 90%;
  box-sizing: border-box;
}
  
  
/* ==========================================================================
   5. HALAMAN LOGIN
   ========================================================================== */
.login-body {
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 34px 18px;
  background: linear-gradient(135deg, #101e35 0%, #1c3b63 48%, #eaf0f8 48%, #f5f7fb 100%);
}

.login-glow {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.login-glow-one {
  width: 360px;
  height: 360px;
  left: -130px;
  top: -120px;
  background: #477fc855;
}

.login-glow-two {
  width: 280px;
  height: 280px;
  right: -90px;
  bottom: -100px;
  background: #2b67a522;
}

.login-card {
  width: min(100%, 440px);
  padding: 30px 38px 25px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #ffffffb8;
  border-radius: 22px;
  box-shadow: 0 28px 80px #07152b45;
  position: relative;
}

.login-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #728198;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
}

.login-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25a66a;
  box-shadow: 0 0 0 4px #25a66a1c;
}

.login-brand {
  text-align: center;
  margin: 18px 0 24px;
}

.login-logo-wrap {
  width: 104px;
  height: 104px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(145deg, #f3f8ff, #fff);
  box-shadow: 0 7px 22px #183b6814;
  border: 1px solid #eaf0f8;
}

.login-logo-wrap img,
.login-brand img {
  width: 91px;
  height: 91px;
  object-fit: contain;
}

.login-brand h1 {
  font-size: 29px;
  letter-spacing: 0.3px;
  margin: 0;
  color: #17365d;
}

.login-brand p {
  margin: 4px 0 0;
  color: #8793a5;
  font-size: 12px;
}

.login-welcome {
  border-top: 1px solid #edf1f6;
  padding-top: 20px;
  margin-bottom: 18px;
}

.login-welcome h2 {
  font-size: 19px;
  margin: 0 0 4px;
  color: #1b2c43;
}

.login-welcome p {
  margin: 0;
  color: #7a8799;
  font-size: 12px;
  line-height: 1.6;
}

.login-form label,
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #34445b;
  margin-bottom: 7px;
}

.login-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #dce4ef;
  border-radius: 11px;
  background: #fbfcfe;
  padding: 0 13px;
  transition: 0.2s;
}

.login-input-wrap:focus-within {
  border-color: #3977c5;
  box-shadow: 0 0 0 3px #3977c51a;
  background: #fff;
}

.login-user-icon {
  font-size: 21px;
  color: #7b8ba2;
}

.login-card .login-input-wrap input,
.login-card input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 14px 10px;
  margin: 0;
  font: 14px Arial;
  color: #26354b;
}

.login-button {
  width: 100%;
  padding: 13px 16px;
  margin-top: 17px;
  border-radius: 11px;
  font-weight: 700;
  box-shadow: 0 7px 16px #2357a533;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-button span {
  font-size: 19px;
  line-height: 12px;
}

.login-hint {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  margin: 17px 0 0;
  color: #8793a5;
  font-size: 11px;
  text-align: center;
}

.login-footer {
  border-top: 1px solid #edf1f6;
  margin-top: 22px;
  padding-top: 15px;
  text-align: center;
  color: #a0aaba;
  font-size: 10px;
}

.login-error {
  margin-bottom: 15px;
  background: #fff0f0;
  color: #a12626;
  padding: 10px;
  border-radius: 8px;
}

/* ==========================================================================
   6. ATURAN CETAK (@PAGE & @MEDIA PRINT)
   ========================================================================== */
@page {
  size: A4;
  margin: 0;
}

@media print {
  body.print-body {
    background: #fff;
    padding: 0;
  }

  .print-actions {
    display: none !important;
  }

  .invoice-paper {
    box-shadow: none;
    margin: 0;
    width: 210mm;
    min-height: 297mm;
    padding: 17mm 17mm 15mm;
    page-break-after: avoid;
  }

  .print-table th {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .main,
  body:not(.print-body) {
    background: #fff;
  }

  .login-body {
    background: #fff;
  }

  .invoice-paper .paid-watermark {
    font-size: clamp(55px, 15mm, 90px) !important;
    color: rgba(13, 133, 66, 0.20) !important;
    border-color: rgba(13, 133, 66, 0.20) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .issuer-logo img {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ==========================================================================
   7. RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 15px;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 15px;
  }

  .sidebar-foot {
    display: none;
  }

  .main {
    margin: 0;
    padding: 15px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span2 {
    grid-column: auto;
  }

  .invoice-paper {
    width: 100%;
    min-height: 0;
    padding: 20px;
  }

  .print-body {
    padding: 0;
  }

  .party-row {
    gap: 15px;
  }

  .brand-block {
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .brand-block img {
    width: 54px;
    height: 54px;
    margin: 0;
  }

  .brand-name {
    font-size: 20px;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 25px 22px;
  }

  .login-body {
    background: linear-gradient(155deg, #142944 0%, #244c78 34%, #f2f5fa 34%, #f2f5fa 100%);
  }
}

/* Aksi tabel: tombol Edit dan tautan cetak tetap rapi di layar kecil */
.action-buttons { display:flex; align-items:center; gap:8px; flex-wrap:wrap; min-width:125px; }
.action-buttons .text-link { white-space:nowrap; }
.action-buttons .btn { white-space:nowrap; }
@media (max-width:520px) {
  .searchbar { flex-wrap:wrap; }
  .searchbar input { max-width:none; flex:1 1 100%; }
  .form-actions { flex-wrap:wrap; }
}
