:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --line: #e7e9ef;
  --brand: #e85d3f;
  --brand-soft: #fff0ec;
  --green: #16b981;
  --cyan: #08a5c8;
  --amber: #efae00;
  --red: #e5485d;
  --dark: #263756;
  --shadow: 0 14px 40px rgba(20, 24, 33, 0.06);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: Inter, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
.app { width: 100%; min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); overflow-x: hidden; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 12px 22px; }
.brand { height: 46px; display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 0 10px; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: white; background: linear-gradient(145deg, #e85d3f, #263756); box-shadow: 0 12px 22px rgba(232, 93, 63, .2); }
.brand-title { line-height: 1.05; font-weight: 800; font-size: 20px; }
.brand-title span { color: var(--brand); }
.brand-subtitle { margin-top: 2px; color: #9aa1ad; font-size: 10px; letter-spacing: .3px; }
.menu-label { margin: 22px 12px 10px; color: #1f2937; font-size: 13px; font-weight: 500; }
.nav { display: grid; gap: 4px; }
.nav-link { min-height: 36px; display: flex; align-items: center; gap: 12px; padding: 8px 11px; color: #272b33; text-decoration: none; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav-link i { width: 18px; height: 18px; color: #28313f; }
.nav-link.active { color: #b7513f; background: var(--brand-soft); }
.nav-link.active i { color: var(--brand); }
.nav-group { border-radius: 8px; }
.nav-group summary { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 11px; color: #272b33; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary span { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-group summary i { width: 18px; height: 18px; color: #28313f; }
.nav-group summary > i:last-child { margin-left: auto; transition: transform .18s ease; }
.nav-group[open] summary { background: #f5f3fb; }
.nav-group[open] summary > i:last-child { transform: rotate(180deg); }
.nav-submenu { display: grid; gap: 2px; padding: 6px 0 8px 42px; }
.nav-sublink { min-height: 32px; display: flex; align-items: center; border-radius: 7px; padding: 7px 10px; color: #6b7280; text-decoration: none; font-size: 13px; font-weight: 600; }
.nav-sublink.active { color: #b7513f; background: var(--brand-soft); }
.main { min-width: 0; max-width: 100%; overflow-x: hidden; }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 22px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 8px; color: #202938; background: #f9fafb; cursor: pointer; position: relative; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.badge { position: absolute; top: -5px; right: -3px; min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 99px; color: white; background: #ef233c; border: 2px solid white; font-size: 10px; font-weight: 800; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: linear-gradient(135deg, #17a2b8, #ed6a4e); font-size: 13px; font-weight: 800; }
.content { min-width: 0; max-width: 100%; padding: 34px 22px 26px; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.15; letter-spacing: 0; }
.page-head p { margin: 0; color: #1f2937; font-size: 15px; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: white; color: #1f2937; padding: 0 14px; text-decoration: none; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn.primary { color: white; background: var(--brand); border-color: var(--brand); }
.btn.dark { color: white; background: var(--dark); border-color: var(--dark); }
.search { min-width: 290px; min-height: 40px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 0 12px; }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; min-height: 124px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 20px; box-shadow: var(--shadow); }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; color: white; border-radius: 8px; background: var(--brand); }
.stat-card.green .stat-icon { background: var(--green); }
.stat-card.cyan .stat-icon { background: var(--cyan); }
.stat-card.amber .stat-icon { background: var(--amber); }
.stat-label { margin: 0 0 8px; color: #1f2937; font-size: 14px; font-weight: 500; }
.stat-value { margin: 0; font-size: 25px; line-height: 1; font-weight: 800; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.setup-layout { grid-template-columns: 1fr; }
.panel { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: var(--shadow); overflow: hidden; }
.panel-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 0 22px; }
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.select { min-width: 132px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: white; color: #202938; font-size: 13px; padding: 0 9px; }
.form { padding: 22px; display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
label { color: #253041; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--text); outline: 0; padding: 11px 12px; }
input, select { min-height: 42px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #f0a08d; box-shadow: 0 0 0 3px rgba(232, 93, 63, .12); }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th, td { padding: 15px 22px; text-align: left; border-bottom: 1px solid #f0f1f4; font-size: 14px; }
th { color: #5f6878; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; background: #fbfcfd; }
tbody tr:last-child td { border-bottom: 0; }
.party { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.party-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; color: white; background: linear-gradient(135deg, #263756, #10b6d5); flex: 0 0 auto; }
.party-mark.alt { background: linear-gradient(135deg, #e85d3f, #f6b900); }
.party strong { display: block; margin-bottom: 4px; font-size: 14px; }
.party span, .muted { color: var(--muted); font-size: 12px; }
.amount { font-weight: 800; }
.amount.due { color: var(--red); }
.amount.advance { color: var(--green); }
.tenant-renewal-banner {
  display: block;
  margin-bottom: 16px;
  border: 1px solid #ffd8cd;
  border-radius: 8px;
  background: #fff6f2;
  color: #9b3f2f;
  overflow: hidden;
  text-decoration: none;
}
.tenant-renewal-track {
  display: inline-block;
  min-width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  animation: tenant-marquee 18s linear infinite;
}
@keyframes tenant-marquee {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}
.ledger-section-row td {
  border-bottom: 0;
  background: #f5f7fb;
  color: #263756;
  padding: 10px 22px 7px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}
.ledger-section-row span {
  display: inline-flex;
  align-items: center;
  border-left: 4px solid var(--brand);
  padding-left: 10px;
}
.ledger-detail-row td {
  background: #fbfcfd;
  padding: 0 22px 18px;
}
.ledger-detail-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.ledger-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}
.ledger-detail-head strong {
  font-size: 14px;
}
.ledger-detail-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.detail-table {
  min-width: 720px;
}
.detail-table th,
.detail-table td {
  padding: 11px 14px;
  font-size: 13px;
}
.detail-table tfoot td {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #fff8f5;
  font-weight: 800;
}
.payment-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}
.payment-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}
.payment-detail-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.payment-detail-card strong {
  font-size: 14px;
}
.report-shell {
  display: grid;
  gap: 16px;
}
.print-report {
  display: none;
}
.report-filter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 18px;
  box-shadow: var(--shadow);
}
.report-sheet {
  max-width: 1180px;
  margin: 0 auto;
  border: 1px solid #d8dde7;
  border-radius: 8px;
  background: white;
  box-shadow: 0 18px 48px rgba(20, 24, 33, .08);
  overflow: hidden;
}
.report-company {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 2px solid #263756;
  padding: 14px 22px 12px;
}
.report-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.report-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: linear-gradient(145deg, #263756, #e85d3f);
}
.report-logo i {
  width: 23px;
  height: 23px;
}
.report-logo span {
  color: white;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .4px;
}
.report-company h2 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1;
}
.report-company p {
  margin: 2px 0;
  color: #3d4656;
  font-size: 11px;
}
.report-meta {
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.report-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 5px 8px;
  font-size: 10px;
}
.report-meta-row:last-child {
  border-bottom: 0;
}
.report-meta-row span {
  color: var(--muted);
  font-weight: 700;
}
.report-meta-row strong {
  text-align: right;
}
.report-title-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  padding: 10px 22px;
}
.report-title-block h1 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.1;
}
.report-title-block p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.report-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 99px;
  color: #9b3f2f;
  background: var(--brand-soft);
  padding: 0 10px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.report-customer {
  display: block;
  padding: 10px 22px 8px;
  border-bottom: 0;
}
.report-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.report-box h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  padding: 7px 10px;
  font-size: 12px;
}
.report-info-grid {
  display: grid;
  grid-template-columns: 1fr .8fr 1.4fr;
  gap: 0;
}
.report-info-item {
  min-height: 42px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
}
.report-info-item:nth-child(3n) {
  border-right: 0;
}
.report-info-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.report-info-item strong {
  display: block;
  font-size: 12px;
}
.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 22px 10px;
}
.report-kpi {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.report-kpi span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.report-kpi strong {
  display: block;
  font-size: 14px;
}
.report-kpi.due strong {
  color: var(--red);
}
.report-kpi.due {
  background: #fff8f8;
}
.report-kpi.advance strong {
  color: var(--green);
}
.report-ledger {
  padding: 0 22px 18px;
}
.report-ledger table {
  min-width: 1000px;
}
.report-ledger .detail-table {
  min-width: 760px;
}
.report-ledger-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  overflow: hidden;
}
.report-ledger-totals div {
  display: grid;
  gap: 6px;
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
}
.report-ledger-totals div:last-child {
  border-right: 0;
}
.report-ledger-totals span {
  color: #3d4656;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.report-ledger-totals strong {
  color: #15171c;
  font-size: 15px;
}
.report-ledger-totals div:last-child strong {
  color: var(--red);
}
.report-footer {
  display: block;
  border-top: 1px solid var(--line);
  padding: 18px 30px 26px;
}
.report-note {
  color: #3d4656;
  font-size: 12px;
  line-height: 1.6;
}
.report-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 34px;
}
.report-signature {
  border-top: 1px solid #9aa1ad;
  padding-top: 8px;
  color: #3d4656;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.report-total-box {
  border: 1px solid #263756;
  border-radius: 8px;
  overflow: hidden;
}
.report-total-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}
.report-total-row:last-child {
  border-bottom: 0;
}
.report-total-row.final {
  color: white;
  background: #263756;
  font-size: 15px;
}
@media print {
  @page {
    size: A4;
    margin: 10mm;
  }
  html,
  body {
    overflow: visible;
    background: white;
  }
  .sidebar,
  .topbar,
  .page-head,
  .stats-grid,
  .content > .panel,
  .report-filter-panel {
    display: none !important;
  }
  .app {
    display: block;
    min-height: 0;
  }
  .main,
  .content {
    display: block;
    width: 100%;
    max-width: none;
    padding: 0;
    overflow: visible;
  }
  .print-report {
    display: block !important;
  }
  .print-report .report-sheet {
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .print-report .report-brand {
    margin-left: 0;
    padding-left: 0;
  }
  .print-report .table-wrap {
    overflow: visible;
  }
  .print-report table,
  .print-report .detail-table {
    min-width: 0;
  }
  .print-report th,
  .print-report td {
    padding: 7px 8px;
    font-size: 10px;
  }
  .print-report .report-company,
  .print-report .report-title-block,
  .print-report .report-customer,
  .print-report .report-ledger,
  .print-report .report-footer {
    padding-left: 0;
    padding-right: 0;
  }
  .print-report .ledger-detail-row td {
    padding: 0 8px 10px;
  }
  .print-report .ledger-section-row td {
    padding: 6px 8px 4px;
    font-size: 10px;
  }
  .print-report .report-ledger-totals {
    margin-top: 8px;
  }
  .print-report .report-ledger-totals div {
    padding: 7px 8px;
  }
  .print-report .report-ledger-totals span {
    font-size: 9px;
  }
  .print-report .report-ledger-totals strong {
    font-size: 12px;
  }
  .print-report .report-footer,
  .print-report .report-customer,
  .print-report .report-kpi-grid {
    break-inside: avoid;
  }
}
.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.active { color: #08784c; background: #e6f8ef; }
.chip.hold { color: #936a00; background: #fff5cf; }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tiny-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: white; color: #28313f; cursor: pointer; }
.tiny-btn.action-link { text-decoration: none; }
.party-modal-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.party-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(15, 23, 42, .38);
  z-index: 40;
}
.party-modal-toggle:checked + .party-modal {
  display: flex;
}
.party-modal-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 24px 60px rgba(20, 24, 33, .22);
  overflow: hidden;
}
.party-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.party-modal-head h3 {
  margin: 0;
  font-size: 20px;
}
.party-modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.modal-close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #293244;
  background: #fbfcfd;
  cursor: pointer;
}
.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px 20px;
}
.modal-section-title {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  color: #253041;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}
.modal-action {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #172033;
  background: #fbfcfd;
  text-decoration: none;
  padding: 14px;
}
.modal-action:hover {
  border-color: #ffd8cd;
  background: var(--brand-soft);
}
.modal-action strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}
.modal-action span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.modal-action i {
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: 8px;
  color: white;
  background: var(--brand);
}
.modal-action.green i { background: var(--green); }
.modal-action.teal i { background: var(--cyan); }
.modal-action.dark i { background: var(--dark); }
.modal-action.amber i { background: var(--amber); }
.side-stack { display: grid; gap: 16px; }
.profile-card { padding: 22px; }
.profile-card h3 { margin: 0 0 6px; font-size: 18px; }
.profile-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.quick-list { display: grid; gap: 12px; margin-top: 18px; }
.quick-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.quick-item strong { font-size: 14px; }
.quick-item span { color: var(--muted); font-size: 12px; }
.party-tabs {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  overflow: visible;
}
.party-tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.party-tab-labels {
  display: flex;
  gap: 8px;
  padding: 16px 22px 0;
  overflow-x: auto;
}
.party-tab-labels label {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #2b3444;
  background: #fbfcfd;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.party-tab-labels i {
  width: 17px;
  height: 17px;
}
#customer-list-tab:checked ~ .party-tab-labels label[for="customer-list-tab"],
#customer-add-tab:checked ~ .party-tab-labels label[for="customer-add-tab"],
#supplier-list-tab:checked ~ .party-tab-labels label[for="supplier-list-tab"],
#supplier-add-tab:checked ~ .party-tab-labels label[for="supplier-add-tab"],
#expense-category-tab:checked ~ .party-tab-labels label[for="expense-category-tab"],
#expense-entry-tab:checked ~ .party-tab-labels label[for="expense-entry-tab"],
#expense-history-tab:checked ~ .party-tab-labels label[for="expense-history-tab"] {
  color: #b7513f;
  border-color: #ffd8cd;
  background: var(--brand-soft);
}
.party-tab-panels {
  padding: 16px 22px 22px;
  overflow: visible;
}
.party-tab-panel {
  display: none;
}
#customer-list-tab:checked ~ .party-tab-panels .customer-list-panel,
#customer-add-tab:checked ~ .party-tab-panels .customer-add-panel,
#supplier-list-tab:checked ~ .party-tab-panels .supplier-list-panel,
#supplier-add-tab:checked ~ .party-tab-panels .supplier-add-panel,
#expense-category-tab:checked ~ .party-tab-panels .expense-category-panel,
#expense-entry-tab:checked ~ .party-tab-panels .expense-entry-panel,
#expense-history-tab:checked ~ .party-tab-panels .expense-history-panel {
  display: block;
}
.full-form-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}
.full-form-panel .form {
  padding: 22px;
}
.full-form-panel .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.date-filter {
  position: relative;
  min-width: 280px;
  z-index: 50;
}
.filter-bar {
  position: relative;
  z-index: 15;
  display: flex;
  justify-content: flex-end;
  padding: 16px 22px 0;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  width: 100%;
}
.filter-grid .field { gap: 6px; }
.filter-grid label { color: #5f6878; font-size: 12px; }
.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 13px 14px;
  color: #3d4656;
  font-size: 13px;
  font-weight: 700;
}
.filter-summary strong { color: var(--brand); font-size: 18px; }
.date-filter-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.date-filter-box {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #253041;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.date-filter-box i {
  width: 18px;
  height: 18px;
  color: var(--brand);
}
.date-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(330px, 88vw);
  max-height: 430px;
  overflow-y: auto;
  display: none;
  z-index: 80;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 24px 50px rgba(20, 24, 33, .18);
  padding: 12px;
}
.expense-history-panel,
.expense-history-panel .panel {
  overflow: visible;
}
.expense-history-panel .table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}
.date-filter-toggle:checked ~ .date-menu {
  display: block;
}
.date-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 28px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: white;
}
.date-option {
  display: block;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: #f5f6f8;
  color: #0476bd;
  text-align: left;
  padding: 0 16px;
  margin-bottom: 7px;
  font-weight: 700;
  cursor: pointer;
}
.date-option.active {
  color: white;
  background: var(--cyan);
}
.date-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}
.date-actions .btn {
  min-height: 38px;
}
.date-actions .apply {
  color: white;
  background: #58d765;
  border-color: #58d765;
}
.date-search-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
}
.date-input-shell {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  min-width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: visible;
}
.date-input-shell .date-prefix {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  color: #28313f;
}
.date-input-shell .date-filter {
  min-width: 0;
}
.date-input-shell .date-filter-box {
  border: 0;
  border-radius: 0;
  font-size: 16px;
  justify-content: flex-start;
}
.date-search-btn {
  width: 64px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: white;
  background: #087cff;
  cursor: pointer;
}
.date-search-btn i {
  width: 24px;
  height: 24px;
}
.date-input-shell .date-menu {
  width: min(760px, calc(100vw - 72px));
  max-height: none;
  overflow: visible;
  padding: 0;
}
.date-picker-layout {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
}
.date-presets {
  padding: 12px 0;
  border-right: 1px solid var(--line);
}
.preset-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.date-presets .date-option {
  min-height: 42px;
  display: flex;
  align-items: center;
  margin: 0;
  border-radius: 0;
  background: white;
  color: #111827;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
#preset-today:checked ~ label[for="preset-today"],
#preset-yesterday:checked ~ label[for="preset-yesterday"],
#preset-last-7:checked ~ label[for="preset-last-7"],
#preset-last-30:checked ~ label[for="preset-last-30"],
#preset-this-month:checked ~ label[for="preset-this-month"],
#preset-last-month:checked ~ label[for="preset-last-month"],
#preset-last-90:checked ~ label[for="preset-last-90"],
#preset-this-year:checked ~ label[for="preset-this-year"],
#preset-custom:checked ~ label[for="preset-custom"] {
  color: white;
  background: var(--cyan);
}
.calendar-area {
  padding: 12px 14px 0;
}
.calendar-grid-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.calendar-month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-weight: 800;
  font-size: 14px;
}
.calendar-arrow {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #111827;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  text-align: center;
}
.calendar-grid strong,
.calendar-day {
  min-height: 28px;
  display: grid;
  place-items: center;
  font-size: 12px;
}
.calendar-grid strong {
  font-weight: 800;
}
.calendar-day.muted {
  color: #9aa1ad;
}
.calendar-day.range {
  background: #eaf5fb;
}
.calendar-day.selected {
  color: white;
  background: #3382c5;
  border-radius: 6px;
}
.time-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.time-row select {
  min-height: 30px;
  border-radius: 0;
  background: #f3f4f6;
  padding: 5px 8px;
  font-size: 13px;
}
.date-picker-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 10px 14px;
}
.date-picked-text {
  margin-right: auto;
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 24px 14px; }
  .page-head { flex-direction: column; }
  .actions { width: 100%; justify-content: flex-start; }
  .search { width: 100%; min-width: 0; }
  .date-filter { width: 100%; min-width: 0; }
  .date-search-row { justify-content: flex-start; }
  .date-menu { left: 0; right: auto; }
  .date-input-shell .date-menu { width: min(900px, calc(100vw - 56px)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-company,
  .report-title-block,
  .report-customer,
  .report-footer {
    grid-template-columns: 1fr;
  }
  .report-title-block {
    align-items: flex-start;
  }
  .report-kpi-grid,
  .payment-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-grid, .form-grid, .full-form-panel .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 12px; }
  .nav { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .party-tab-panels, .party-tab-labels { padding-left: 14px; padding-right: 14px; }
  .form-actions { flex-direction: column; }
  .modal-actions { grid-template-columns: 1fr; }
  .date-search-row { flex-direction: column; }
  .date-input-shell { min-width: 0; }
  .date-search-btn { width: 100%; }
  .filter-grid { grid-template-columns: 1fr; }
  .report-company,
  .report-title-block,
  .report-customer,
  .report-ledger,
  .report-footer {
    padding-left: 14px;
    padding-right: 14px;
  }
  .report-brand {
    align-items: flex-start;
  }
  .report-logo {
    width: 52px;
    height: 52px;
  }
  .report-company h2 {
    font-size: 22px;
  }
  .report-info-grid,
  .report-kpi-grid,
  .payment-detail-grid,
  .report-signatures {
    grid-template-columns: 1fr;
  }
  .report-info-item {
    border-right: 0;
  }
  .date-picker-layout,
  .calendar-grid-wrap {
    grid-template-columns: 1fr;
  }
  .date-presets {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .date-picker-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .date-picked-text {
    margin-right: 0;
  }
}
@media print {
  .print-report .report-company {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 210px !important;
    align-items: start !important;
    gap: 14px !important;
    padding: 0 0 8px !important;
    margin: 0 !important;
  }
  .print-report .report-brand {
    align-items: center !important;
  }
  .print-report .report-logo {
    width: 44px !important;
    height: 44px !important;
  }
  .print-report .report-company h2 {
    font-size: 20px !important;
  }
  .print-report .report-meta {
    width: 210px !important;
    min-width: 210px !important;
  }
  .print-report .report-meta-row {
    padding: 4px 7px !important;
    font-size: 9px !important;
  }
}
