:root {
  --primary: #3b82f6;
  --bg-main: #0f172a;
  --border-color: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --font-family: "Inter", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden; /* Page complete scroll aakathirikkan */
  display: flex;
  flex-direction: column;
}

/* Content Layout */
.content-layout {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0; /* Flexbox-il overflow handle cheyyan */
  height: auto;
}

/* 3 Mini KPI Boxes in Detail Header Ribbon */
.owner-kpi-pill-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kpi-mini-box {
  display: flex;
  flex-direction: column;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  min-width: 105px;
}
.kpi-mini-box .mini-label {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
}
.kpi-mini-box .mini-val {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.box-total {
  border-color: #1e40af;
  background: rgba(30, 58, 138, 0.35);
}
.box-total .mini-val {
  color: #38bdf8;
}
.box-paid {
  border-color: #166534;
  background: rgba(20, 83, 45, 0.35);
}
.box-paid .mini-val {
  color: #4ade80;
}
.box-setoff {
  border-color: #92400e;
  background: rgba(120, 53, 15, 0.35);
}
.box-setoff .mini-val {
  color: #fbbf24;
}
.box-remaining {
  border-color: #991b1b;
  background: rgba(127, 29, 29, 0.35);
}
.box-remaining .mini-val {
  color: #f87171;
}

/* Detail Table */
.table-container {
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 0;
  background: #1e293b;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
th {
  position: sticky;
  top: 0;
  background: #020617;
  color: #f8fafc;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid #334155; /* Header column border */
  border-bottom: 2px solid #334155;
  z-index: 2;
}
th:last-child {
  border-right: none;
}
td {
  padding: 7px 10px;
  border-bottom: 1px solid #334155;
  border-right: 1px solid #293548; /* Body column border */
  color: #e2e8f0;
  white-space: nowrap;
}
td:last-child {
  border-right: none;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-title {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #334155;
  color: #cbd5e1;
}
.status-badge.saved {
  background: #dcfce7;
  color: #15803d;
}
.status-badge.saving {
  background: #fef3c7;
  color: #b45309;
}
.status-badge.error {
  background: #fee2e2;
  color: #b91c1c;
}

/* Buttons */
.btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: #1d4ed8;
}
.btn-success {
  background: #10b981;
  color: white;
}
.btn-success:hover {
  background: #059669;
}
.btn-outline {
  background: #0f172a;
  border-color: var(--border-color);
  color: #e2e8f0;
}
.btn-outline:hover {
  background: #334155;
}

/* Dashboard Body */
.dashboard-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Top Navbar Center KPIs */
.nav-center-kpis {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-kpi-pill {
  display: flex;
  flex-direction: column;
  padding: 3px 12px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
}
.nav-kpi-title {
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
}
.nav-kpi-data {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.nav-kpi-val {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.nav-kpi-count {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
}

.box-nav-total {
  border-color: #1e40af;
  background: rgba(30, 58, 138, 0.35);
}
.box-nav-total .nav-kpi-val {
  color: #38bdf8;
}

.box-nav-paid {
  border-color: #166534;
  background: rgba(20, 83, 45, 0.35);
}
.box-nav-paid .nav-kpi-val {
  color: #4ade80;
}

.box-nav-setoff {
  border-color: #92400e;
  background: rgba(120, 53, 15, 0.35);
}
.box-nav-setoff .nav-kpi-val {
  color: #fbbf24;
}

.box-nav-remaining {
  border-color: #991b1b;
  background: rgba(127, 29, 29, 0.35);
}
.box-nav-remaining .nav-kpi-val {
  color: #f87171;
}

/* Owner Sidebar */
.owner-sidebar {
  width: 290px;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.sidebar-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #f8fafc;
  flex-shrink: 0;
}
.badge {
  background: #334155;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  color: #e2e8f0;
}
.sidebar-search {
  padding: 8px 10px;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  outline: none;
}
.owner-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.owner-item {
  padding: 10px 12px;
  border-bottom: 1px solid #293548;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
.owner-item:hover {
  background: #293548;
}
.owner-item.active {
  background: rgba(30, 58, 138, 0.45);
  border-left: 3px solid var(--primary);
}
.owner-item-name {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
}
.owner-item-amt {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
}

/* Right Detail Panel */
.owner-detail-panel {
  flex: 1;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.detail-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.owner-title {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}
.owner-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.table-search-box input {
  padding: 6px 10px;
  font-size: 12px;
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  outline: none;
  width: 180px;
}
.table-search-box input:focus {
  border-color: var(--primary);
}
th[data-col] {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
th[data-col]:hover {
  background: #1e293b;
}

/* Filter Popup */
.filter-popup {
  position: absolute;
  display: none;
  flex-direction: column;
  background: #1e293b;
  color: #f1f5f9;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
  border-radius: 6px;
  width: 240px;
  padding: 10px;
  z-index: 2500;
}
.filter-sort-actions {
  display: flex;
  gap: 6px;
  margin: 6px 0;
}
.btn-sort {
  flex: 1;
  padding: 4px 6px;
  font-size: 11px;
  background: #334155;
  color: #f1f5f9;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
}
.btn-sort:hover {
  background: #475569;
}
.filter-search {
  width: 100%;
  padding: 5px 8px;
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 6px;
  outline: none;
}
.filter-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #334155;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 4px;
  color: #e2e8f0;
}

tr:nth-child(even) td {
  background: #162032;
}
tfoot td {
  background: #0f172a;
  border-top: 2px solid var(--border-color);
  padding: 8px 10px;
}

/* Status Badges in Table */
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.status-pill.paid {
  background: rgba(20, 83, 45, 0.55);
  color: #4ade80;
}
.status-pill.pending {
  background: rgba(127, 29, 29, 0.55);
  color: #f87171;
}

/* Bottom Sticky Summary Bar for Owner */
.owner-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 16px;
  background: #0f172a;
  color: #ffffff;
  border-top: 1px solid #334155;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}
.summary-line-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary-line-item .lbl {
  color: #94a3b8;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.summary-line-item .val {
  font-size: 14px;
  font-weight: 700;
}
.summary-line-item .val.text-primary {
  color: #38bdf8;
}
.summary-separator {
  color: #475569;
  font-weight: 300;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal-box {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid #334155;
  padding: 22px;
  border-radius: 8px;
  width: 100%;
}
.modal-input {
  width: 100%;
  padding: 7px 10px;
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 4px;
  outline: none;
}

/* Toast */
.bottom-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: white;
  padding: 8px 16px;
  font-size: 12px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 4000;
}
.bottom-toast.show {
  opacity: 1;
}

/* Table Amount Cell Colors */
.td-amt-total {
  color: #f8fafc;
}
.td-amt-paid {
  color: #4ade80;
}

/* ================= LIGHT THEME OVERRIDES ================= */
body.light-theme {
  background-color: #f8fafc;
  color: #0f172a;
}
body.light-theme .navbar,
body.light-theme .owner-sidebar,
body.light-theme .owner-detail-panel,
body.light-theme .table-container {
  background: #ffffff;
  border-color: #cbd5e1;
}
body.light-theme .nav-title,
body.light-theme .owner-title,
body.light-theme .sidebar-header {
  color: #0f172a;
}
body.light-theme .status-badge,
body.light-theme .badge {
  background: #e2e8f0;
  color: #334155;
}
body.light-theme .btn-outline {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}
body.light-theme .btn-outline:hover {
  background: #f1f5f9;
}
body.light-theme .nav-kpi-pill,
body.light-theme .kpi-mini-box {
  border-color: #cbd5e1;
  background: #f8fafc;
}
body.light-theme .nav-kpi-title,
body.light-theme .nav-kpi-count,
body.light-theme .kpi-mini-box .mini-label,
body.light-theme .owner-subtitle,
body.light-theme .owner-item-amt {
  color: #64748b;
}
body.light-theme .box-nav-total,
body.light-theme .box-total {
  border-color: #bfdbfe;
  background: #eff6ff;
}
body.light-theme .box-nav-total .nav-kpi-val,
body.light-theme .box-total .mini-val {
  color: #0284c7;
}
body.light-theme .box-nav-paid,
body.light-theme .box-paid {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
body.light-theme .box-nav-paid .nav-kpi-val,
body.light-theme .box-paid .mini-val {
  color: #15803d;
}
body.light-theme .box-nav-setoff,
body.light-theme .box-setoff {
  border-color: #fde68a;
  background: #fffbeb;
}
body.light-theme .box-nav-setoff .nav-kpi-val,
body.light-theme .box-setoff .mini-val {
  color: #d97706;
}
body.light-theme .box-nav-remaining,
body.light-theme .box-remaining {
  border-color: #fecaca;
  background: #fef2f2;
}
body.light-theme .box-nav-remaining .nav-kpi-val,
body.light-theme .box-remaining .mini-val {
  color: #dc2626;
}
body.light-theme .sidebar-search {
  border-bottom-color: #f1f5f9;
}
body.light-theme .sidebar-search input,
body.light-theme .table-search-box input,
body.light-theme .filter-search,
body.light-theme .modal-input {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}
body.light-theme .owner-item {
  border-bottom-color: #f1f5f9;
}
body.light-theme .owner-item:hover {
  background: #f1f5f9;
}
body.light-theme .owner-item.active {
  background: #eff6ff;
}
body.light-theme .owner-item-name {
  color: #1e293b;
}
body.light-theme th {
  background: #0f172a;
  color: #ffffff;
}
body.light-theme td {
  border-bottom-color: #cbd5e1;
  border-right-color: #e2e8f0;
  color: #1e293b;
}
body.light-theme tr:nth-child(even) td {
  background: #f8fafc;
}
body.light-theme .td-amt-total {
  color: #0f172a;
}
body.light-theme .td-amt-paid {
  color: #15803d;
}
body.light-theme .status-pill.paid {
  background: #dcfce7;
  color: #15803d;
}
body.light-theme .status-pill.pending {
  background: #fee2e2;
  color: #b91c1c;
}
body.light-theme .filter-popup,
body.light-theme .modal-box {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}
body.light-theme .btn-sort {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}
body.light-theme .btn-sort:hover {
  background: #e2e8f0;
}
body.light-theme .filter-list {
  border-color: #f1f5f9;
}
body.light-theme .filter-item {
  color: #1e293b;
}
