﻿:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1b2533;
  --muted: #6b7787;
  --accent: #0f9d8a;
  --danger: #c0392b;
  --line: #dfe5ef;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  position: relative;
  overflow: hidden;
  padding: 1rem 1.5rem;
  background: linear-gradient(120deg, #ffe082, #ffca28);
  color: #4a3400;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 30%, rgba(255, 255, 255, 0.2), transparent 45%),
    radial-gradient(circle at 85% 25%, rgba(255, 214, 102, 0.28), transparent 38%);
}

.topbar-title-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.9rem, 2.8vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #ffffff;
  padding: 0.18rem 0.72rem 0.22rem;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: linear-gradient(100deg, #cfefff, #a9dcff, #8ecfff);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.24);
}

.title-images {
  display: inline-flex;
  gap: 0.4rem;
}

.title-images img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.25);
}

.topbar p {
  position: relative;
  z-index: 1;
  margin: 0.25rem 0 0;
  opacity: 1;
  color: #b42318;
  text-align: center;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  padding: 1rem;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.nav-panel,
.content-panel {
  min-height: 0;
  overflow-y: auto;
}

.nav {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.nav button {
  width: 100%;
}

.nav.icon-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.menu-icon-btn {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 56px;
  padding: 0.35rem;
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.03em;
  position: relative;
}

.menu-emoji {
  font-size: 1.3rem;
  display: block;
  line-height: 1;
}

.menu-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
}

.menu-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

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

button.danger {
  background: #fff5f3;
  border-color: #f1c7c2;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

form {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-presets button {
  background: #f8fafc;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

input,
select {
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.picker {
  position: relative;
}

.customer-field.invalid .picker input {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.14);
}

.picker-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 30;
}

.picker-option {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  border-radius: 0;
  background: #fff;
  padding: 0.5rem 0.65rem;
}

.picker-option:hover {
  background: #f4f8ff;
}

.picker-empty {
  padding: 0.5rem 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
}

.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi .card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
}

.kpi .value {
  font-weight: 700;
  font-size: 1.15rem;
}

.tenant-workspace {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(0, 1.5fr);
  gap: 1rem;
  align-items: start;
}

.tenant-unit-pane,
.tenant-detail-pane {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 1rem;
}

.tenant-unit-pane {
  display: grid;
  gap: 0.55rem;
}

.tenant-pane-heading h3,
.tenant-detail-header h3,
.tenant-records h3 {
  margin: 0;
}

.tenant-pane-heading p,
.tenant-detail-header p {
  margin: 0.2rem 0 0;
}

.tenant-pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.tenant-add-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
}

.tenant-unit-option {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.2rem 0.5rem;
  text-align: left;
  padding: 0.7rem;
  background: #f8fafc;
}

.tenant-unit-option:hover {
  border-color: #8bd2c8;
  background: #f1fbf9;
}

.tenant-unit-option.selected {
  border-color: var(--accent);
  background: #e9fbf7;
  box-shadow: 0 0 0 2px rgba(15, 157, 138, 0.12);
}

.tenant-unit-name {
  font-weight: 800;
}

.tenant-unit-tenant {
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.86rem;
}

.tenant-unit-option .income-pill {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
}

.tenant-detail-pane {
  min-height: 100%;
}

.tenant-detail-header {
  display: flex;
  justify-content: end;
  align-items: start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.tenant-detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.5rem;
}

.tenant-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.tenant-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.tenant-profile-form {
  margin: 1rem 0 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.tenant-profile-form h3 {
  margin: 0;
}

.tenant-master-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

/**/
.tenant-profile-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.bill-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.bill-section h3 {
  grid-column: 1 / -1;
  margin: 0 0 4px 0;
}

.bill-section label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bill-section input,
.bill-section select,
.bill-section textarea {
  width: 100%;
  box-sizing: border-box;
}

.other-section label:last-child {
  grid-column: 1 / -1;
}

.monthly-due-table-container {
  width: 100%;
  overflow-x: auto;
  margin-top: 20px;
}

.monthly-due-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.monthly-due-table th,
.monthly-due-table td {
  border: 1px solid #d9d9d9;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.monthly-due-table th {
  background: #f3f4f6;
  font-weight: 700;
  color: #333;
}

.monthly-due-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.monthly-due-table tbody tr:hover {
  background: #f1f5f9;
}

.monthly-due-table td:nth-child(n+3):nth-child(-n+9) {
  text-align: right;
}

.monthly-due-table .due-total {
  font-weight: 700;
}

.monthly-due-table .due-balance {
  color: #dc2626;
  font-weight: 700;
}
/**/
.tenant-profile-actions {
  display: flex;
  justify-content: end;
}

.tenant-profile-form input:disabled {
  color: var(--muted);
  background: #f1f5f9;
  cursor: not-allowed;
}

.monthly-transaction-month {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.monthly-transaction-month input {
  width: auto;
}

.monthly-transaction-header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.monthly-transaction-header h3,
.monthly-transaction-header p {
  margin: 0;
}

.monthly-dues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.monthly-due-item {
  display: grid;
  gap: 0.3rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafc;
}

.monthly-due-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.monthly-due-item.total {
  background: #e9fbf7;
  border-color: #8bd2c8;
}

.monthly-due-item.balance {
  background: #fffaf0;
}

.monthly-transaction-payment {
  display: flex;
  justify-content: end;
}

.monthly-payment-form {
  display: grid;
  gap: 0.65rem;
  width: min(360px, 100%);
}

.monthly-payment-form label {
  display: grid;
  gap: 0.35rem;
}

.monthly-payment-form p {
  margin: 0;
}

.monthly-transaction-empty {
  padding: 1rem 0;
}

.monthly-due-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
}

.monthly-due-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.monthly-due-card-heading {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.monthly-due-card-heading strong {
  font-size: 1.1rem;
}

.monthly-due-card-heading span,
.monthly-due-card-item span,
.monthly-due-card-status span {
  color: var(--muted);
  font-size: 0.82rem;
}

.monthly-due-card-item,
.monthly-due-card-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.due-status {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #f1f5f9;
}

.due-status.fully-paid {
  color: #087f5b;
  background: #e9fbf7;
}

.due-status.partial {
  color: #9a6700;
  background: #fff4cc;
}

.due-status.not-yet-paid {
  color: #b42318;
  background: #fff0ef;
}

.annual-income-grid {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.annual-income-grid table {
  min-width: 1180px;
  margin: 0;
}

.annual-income-grid th,
.annual-income-grid td {
  text-align: right;
  white-space: nowrap;
}

.annual-income-grid th:first-child,
.annual-income-grid td:first-child {
  text-align: left;
}

.annual-income-grid tbody tr:last-child {
  background: #e9fbf7;
}

.bill-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.bill-toolbar label {
  display: grid;
  gap: 0.35rem;
}

.tenant-detail-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem;
  border-radius: 9px;
  background: #f8fafc;
}

.tenant-detail-item > span {
  color: var(--muted);
  font-size: 0.8rem;
}

.tenant-records {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.tenant-records h3 {
  margin-bottom: 0.75rem;
}

.tenant-detail-empty {
  display: grid;
  place-content: center;
  min-height: 240px;
  text-align: center;
}

.tenant-detail-empty h3 {
  margin-bottom: 0;
}

.tenant-add-dialog {
  width: min(620px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.tenant-history-dialog {
  width: min(850px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.tenant-history-dialog-wide {
  width: min(1200px, calc(100vw - 2rem));
}

.tenant-history-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.tenant-history-content {
  margin-top: 1rem;
  max-height: min(60vh, 520px);
  overflow: auto;
}

.tenant-add-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.tenant-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.tenant-dialog-header h3 {
  margin: 0;
}

.tenant-checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-content: end;
  padding-bottom: 0.25rem;
}

.tenant-checkbox-field input {
  width: 18px;
  height: 18px;
}

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

.line-items {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sales-order-grid {
  grid-template-columns: 180px minmax(320px, 2fr) minmax(220px, 1fr);
}

.sales-order-form label,
.sales-order-form .picker {
  min-width: 0;
}

.sales-order-form .picker input[type="text"],
.sales-order-form input[type="date"],
.sales-order-form input[type="number"] {
  width: 100%;
}

.line-item-header,
.line-item-row {
  display: grid;
  grid-template-columns: 1fr 120px 46px;
  gap: 0.5rem;
  align-items: center;
}

.sales-order-form .line-item-header,
.sales-order-form .line-item-row {
  grid-template-columns: minmax(420px, 1fr) 120px 46px;
}

.line-item-header {
  font-size: 0.85rem;
  color: var(--muted);
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
}

.add-item-btn {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #ffffff;
  font-weight: 700;
}

.add-item-btn:hover {
  background: #0b5ed7;
  border-color: #0b5ed7;
}

.payable-card {
  border: 2px solid #0f9d8a;
  background: linear-gradient(120deg, #e9fbf7, #d7f5ef);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.payable-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
}

.payable-label {
  font-size: 0.85rem;
  color: #0c6f62;
  font-weight: 600;
}

.payable-value {
  margin-top: 0.15rem;
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 800;
  color: #064b42;
}

.payable-change {
  border-color: #1f6feb;
  background: linear-gradient(120deg, #eef5ff, #ddeaff);
}

.payable-given {
  border-color: #a16207;
  background: linear-gradient(120deg, #fff8e6, #ffefc2);
}

.payable-input-wrap {
  margin-top: 0.2rem;
}

.payable-input-wrap input {
  width: 100%;
  border: 1px solid #e2c270;
  background: #fffdf5;
  font-weight: 700;
}

.negative-value {
  color: #b42318;
}

.income-pill {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
}

.income-pill.positive {
  background: #dcfce7;
  color: #166534;
}

.income-pill.negative {
  background: #fee2e2;
  color: #991b1b;
}

.disabled-card {
  opacity: 0.45;
  filter: grayscale(0.25);
}

.disabled-card input {
  pointer-events: none;
}

td input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.toggle-field {
  display: grid;
  gap: 0.35rem;
}

.toggle-title {
  font-size: 0.9rem;
}

.payment-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-option {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}

.toggle-option.active {
  color: var(--text);
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #d1d8e5;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .slider {
  background: #0f9d8a;
}

.switch input:checked + .slider:before {
  transform: translateX(24px);
}

@media (max-width: 860px) {
  body {
    overflow: auto;
    height: auto;
    display: block;
  }

  .layout {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sales-order-grid {
    grid-template-columns: 1fr;
  }

  .line-item-header,
  .line-item-row {
    grid-template-columns: 1fr 100px 42px;
  }

  .sales-order-form .line-item-header,
  .sales-order-form .line-item-row {
    grid-template-columns: 1fr 100px 42px;
  }

  .nav-panel,
  .content-panel {
    overflow-y: visible;
  }

  .payable-row {
    grid-template-columns: 1fr;
  }

  .tenant-workspace {
    grid-template-columns: 1fr;
  }

  .tenant-detail-header {
    flex-direction: column;
  }

  .tenant-detail-actions {
    justify-content: start;
  }

  .topbar-title-row {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .title-images img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }
}
