:root {
  --bg: #f6f3ee;
  --dark: #070707;
  --text: #151515;
  --muted: #777;
  --line: #e4ddd2;
  --card: #fff;
  --soft: #f0ebe3;
  --danger: #c0392b;
  --success: #16794c;
  --warning: #c88600;
  --blue: #1f6feb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 290px;
  background: #000;
  color: #fff;
  min-height: 100vh;
  padding: 26px;
  position: fixed;
  left: 0;
  top: 0;
}

.sidebar-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 34px;
}

.sidebar-brand h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 32px;
  font-weight: 400;
}

.sidebar-brand p {
  color: #bbb;
  margin: 7px 0 0;
}

.sidebar-brand img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-top: -8px;
}

.nav {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: #ddd;
  text-align: left;
  padding: 13px 14px;
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: bold;
}

.nav:hover,
.nav.active {
  background: #fff;
  color: #111;
}

.main {
  margin-left: 290px;
  width: calc(100% - 290px);
  padding: 28px;
}

.page { display: none; }
.page.active { display: block; }

.topbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px 22px;
  margin-bottom: 24px;
  box-shadow: 0 14px 40px rgba(0,0,0,.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 { margin: 0; font-size: 26px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(0,0,0,.04);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

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

.card h3 {
  margin: 8px 0 0;
  font-size: 28px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--dark);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

.btn.light { background: var(--soft); color: var(--dark); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.blue { background: var(--blue); }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.span-2 { grid-column: 1 / -1; }

.form-group {
  display: grid;
  gap: 8px;
}

label {
  font-weight: bold;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  font-family: inherit;
  background: #fff;
}

textarea { min-height: 90px; }

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}

th {
  background: #111;
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: bold;
  font-size: 12px;
}

.badge.dp { background: #fff1c8; color: #9b6500; }
.badge.lunas { background: #dff8e9; color: #16794c; }
.badge.selesai { background: #dfeaff; color: #1f56b3; }
.badge.batal { background: #ffe0da; color: #c0392b; }

.alert {
  padding: 14px 16px;
  border-radius: 16px;
  margin-bottom: 18px;
  font-weight: bold;
}

.alert.warning {
  background: #fff3cd;
  color: #8a6200;
}

.legend {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.legend span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: bold;
}

.dot {
  width: 11px;
  height: 11px;
  display: inline-block;
  border-radius: 99px;
  margin-right: 6px;
}

.dot.dp { background: #c88600; }
.dot.lunas { background: #16794c; }
.dot.selesai { background: #1f6feb; }
.dot.batal { background: #c0392b; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.day-name {
  text-align: center;
  font-weight: bold;
  color: var(--muted);
}

.date-box {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  background: #fff;
}

.date-box.dp { border-color: #c88600; background: #fff6db; }
.date-box.lunas { border-color: #16794c; background: #e9fbf0; }
.date-box.selesai { border-color: #1f6feb; background: #eaf2ff; }
.date-box.batal { border-color: #c0392b; background: #ffe9e5; opacity: .72; }

.date-number { font-weight: bold; }
.date-client { margin-top: 8px; font-size: 12px; line-height: 1.35; }

.invoice {
  width: 900px;
  max-width: 100%;
  background: #fff;
  margin: auto;
  padding: 58px 66px;
  box-shadow: 0 25px 80px rgba(0,0,0,.14);
}

.invoice-header {
  background: #dedbd6;
  margin: -58px -66px 42px;
  padding: 42px 66px;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  align-items: center;
  gap: 18px;
}

.invoice-header h1 { font-size: 58px; margin: 0; }
.invoice-header h2 { font-weight: 400; margin: 14px 0 0; }

.invoice-logo{
    transform: translateX(30px);
}

.invoice-status {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-weight: bold;
}

.invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 44px;
  font-size: 20px;
}

.invoice-meta .right { text-align: right; }

.invoice th {
  border-bottom: 7px solid #111;
  background: #fff;
  color: #111;
  font-size: 20px;
}

.invoice .price,
.invoice .total {
  text-align: right;
  white-space: nowrap;
}

.invoice ul {
  margin: 10px 0 0 20px;
  font-size: 16px;
  line-height: 1.45;
}

.summary {
  margin-top: 24px;
  margin-left: auto;
  width: 390px;
  font-size: 20px;
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}

.note,
.payment {
  margin-top: 32px;
  font-size: 17px;
  line-height: 1.5;
}

.thanks {
  margin-top: 48px;
  text-align: center;
  letter-spacing: 12px;
  font-size: 28px;
}

.report-title {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.report-title img {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: #000;
}

.report-title h2 { margin: 0; letter-spacing: 1px; }
.report-title p { margin: 4px 0 0; color: var(--muted); }

.report-summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.report-summary div {
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 18px;
}

.report-summary small {
  display: block;
  color: var(--muted);
  margin-bottom: 7px;
}

.report-summary b { font-size: 20px; }

.report-card { margin-bottom: 18px; }

@media print {
  @page { size: A4; margin: 8mm; }

  .sidebar,
  .topbar,
  .print-hide,
  #dashboard,
  #booking,
  #calendar,
  #expense,
  #supabase {
    display: none !important;
  }

  .main {
    margin: 0 !important;
    width: 100% !important;
    padding: 0 !important;
  }

  .page { display: none !important; }
  #invoice.page.active,
  #report.page.active { display: block !important; }

  body {
    background: #fff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .invoice {
    width: 190mm !important;
    max-width: 190mm !important;
    margin: 0 auto !important;
    padding: 12mm !important;
    box-shadow: none !important;
    transform: scale(.88);
    transform-origin: top center;
  }

  .invoice-header {
    margin: -12mm -12mm 10mm !important;
    padding: 12mm !important;
  }

  .invoice-header h1 { font-size: 38px !important; }
  .invoice-header h2 { font-size: 18px !important; }
  .invoice-logo img { width: 105px !important; }
  .invoice-meta { font-size: 14px !important; margin-bottom: 18px !important; }
  .invoice th, .invoice td { font-size: 12px !important; padding: 6px !important; }
  .invoice ul { font-size: 11px !important; }
  .summary { font-size: 13px !important; width: 270px !important; }
  .note, .payment { font-size: 12px !important; margin-top: 14px !important; }
  .thanks { font-size: 20px !important; margin-top: 18px !important; }

  .report-title img { display: none !important; }
  .report-title {
    border: none !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0 0 10px !important;
  }

  .report-summary {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .report-summary div {
    border-radius: 0 !important;
    padding: 8px !important;
  }

  .report-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  th { background: #111 !important; color: #fff !important; }
  th, td { font-size: 10px !important; padding: 5px !important; }
}

@media (max-width: 1000px) {
  .app { display: block; }

  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 18px;
  }

  .stats,
  .report-summary,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .calendar { grid-template-columns: repeat(2, 1fr); }

  .invoice {
    padding: 35px 28px;
  }

  .invoice-header {
    margin: -35px -28px 35px;
    padding: 35px 28px;
  }

  .invoice-meta {
    grid-template-columns: 1fr;
  }

  .invoice-meta .right { text-align: left; }
}

.calendar-filter{
    display:flex;
    gap:14px;
    align-items:center;
}

.calendar-filter select{
    width:150px;
    height:50px;
    border-radius:16px;
    border:1px solid #ece7df;
    background:#fff;
    padding:0 18px;
    font-size:18px;
    font-weight:600;
    cursor:pointer;
    transition:.25s;
}

.calendar-filter select:hover{
    border-color:#000;
}

.calendar-filter select:focus{
    outline:none;
    border-color:#000;
    box-shadow:0 0 0 3px rgba(0,0,0,.08);
}


/* ===== SUPABASE STATUS ===== */
.connection-status {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff3cd;
  color: #8a6200;
  font-weight: bold;
}

.connection-status.connected {
  background: #dff8e9;
  color: #16794c;
}

.connection-status.error {
  background: #ffe0da;
  color: #c0392b;
}

.alert.success {
  background: #dff8e9;
  color: #16794c;
}

/* ===== INVOICE STATUS COLORS ===== */
.invoice-status.dp {
  background: #f39c12;
}

.invoice-status.lunas {
  background: #27ae60;
}

.invoice-status.selesai {
  background: #2980b9;
}

.invoice-status.batal {
  background: #e74c3c;
}
