/* ========== CSS Reset & Variables ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg-start: #1c1917;
  --sidebar-bg-end: #0c0a09;
  --primary: #1c1917;
  --primary-dark: #0c0a09;
  --primary-light: #44403c;
  --success: #10B981;
  --success-bg: rgba(16,185,129,0.10);
  --danger: #EF4444;
  --danger-bg: rgba(239,68,68,0.08);
  --warning: #F59E0B;
  --warning-bg: rgba(245,158,11,0.12);
  --info: #78716c;
  --info-bg: rgba(28,25,23,0.06);
  --bg-page: #f7f2ed;
  --bg-card: #ffffff;
  --bg-header: #f5f0eb;
  --border: #e8e0d8;
  --border-light: #f5f0eb;
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #78716c;
  --text-light: #a8a29e;
  --white: #FFFFFF;
  --sidebar-width: 256px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; color: var(--text-primary);
  background: var(--bg-page); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { width: 100%; min-height: 100vh; display: flex; background: var(--bg-page); }

/* ========== AUTH PAGES (New Split-Screen) ========== */
.auth-screen {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  background: var(--white);
  z-index: 2000; overflow: hidden;
}
.auth-screen.active { display: flex; }

/* Brand panel (left) */
.auth-brand-panel {
  width: 55%; min-width: 420px;
  display: flex; flex-direction: column;
  padding: 48px 64px 40px;
  background: linear-gradient(160deg, #1c1917 0%, #0c0a09 60%, #1c1917 100%);
  color: var(--white);
  position: relative; overflow: hidden;
}
.auth-brand-panel::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(120, 113, 108, 0.18) 0%, transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(68, 64, 60, 0.22) 0%, transparent 40%);
  pointer-events: none;
}
.auth-brand-header,
.auth-brand-body,
.auth-brand-footer { position: relative; z-index: 1; }

.auth-brand-header { flex-shrink: 0; }
.auth-brand-logo {
  display: inline-flex; align-items: center; gap: 14px;
}
.auth-brand-logo-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.auth-brand-logo-text { display: flex; flex-direction: column; gap: 2px; }
.auth-brand-logo-title { font-size: 48px; font-weight: 700; letter-spacing: 0.02em; }
.auth-brand-logo-subtitle { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.55); letter-spacing: 0.12em; }

.auth-brand-body { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.auth-brand-headline {
  font-size: 42px; font-weight: 700; line-height: 1.18;
  letter-spacing: -0.03em; margin-bottom: 20px;
  background: linear-gradient(135deg, #fafaf9 0%, #d6d3d1 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.auth-brand-desc {
  max-width: 480px;
  font-size: 14px; line-height: 1.8; color: rgba(255,255,255,0.55);
}

.auth-brand-footer { flex-shrink: 0; display: flex; gap: 40px; padding-bottom: 8px; }
.auth-brand-feature { display: flex; flex-direction: column; gap: 6px; }
.auth-feature-value {
  font-size: 20px; font-weight: 700; color: var(--white); letter-spacing: -0.01em;
}
.auth-feature-label {
  font-size: 12px; color: rgba(255,255,255,0.50); font-weight: 500;
}

/* Form panel (right) */
.auth-form-panel {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: #f7f2ed;
  padding: 40px 48px;
  overflow-y: auto;
}
.auth-form-scroll {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 24px;
}

.auth-card {
  position: relative; width: 100%;
  background: transparent; border-radius: 0;
  padding: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 0;
  z-index: 1;
}

.auth-header { margin-bottom: 28px; }
.auth-title { font-size: 26px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 8px; }
.auth-spacer { width: 1px; height: 20px; flex-shrink: 0; }
.auth-spacer-sm { width: 1px; height: 14px; flex-shrink: 0; }
.auth-spacer-lg { width: 1px; height: 28px; flex-shrink: 0; }

.auth-form-group { width: 100%; margin-bottom: 16px; }
.auth-form-group:last-of-type { margin-bottom: 0; }
.auth-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.auth-input-wrap {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 46px; padding: 0 16px;
  border: 1px solid #e8e0d8; border-radius: 10px;
  background: var(--white); transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input-wrap:focus-within {
  border-color: #1c1917;
  box-shadow: 0 0 0 3px rgba(28, 25, 23, 0.06);
}
.auth-input-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
}
.auth-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--text-primary);
}
.auth-input::placeholder { color: var(--text-light); }

.auth-btn {
  width: 100%; height: 48px; margin-top: 24px;
  border: none; border-radius: 9999px;
  background: #0c0a09; color: var(--white);
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background 0.2s, transform 0.1s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 0.02em;
}
.auth-btn:hover { background: #292524; }
.auth-btn:active { transform: scale(0.98); }
.auth-btn-arrow { transition: transform 0.2s; }
.auth-btn:hover .auth-btn-arrow { transform: translateX(3px); }

.auth-link-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; font-size: 13px; margin-top: 18px;
}
.auth-link-left { display: flex; align-items: center; gap: 4px; }
.auth-link-text { color: var(--text-muted); }
.auth-link-action {
  color: var(--text-primary); cursor: pointer; font-weight: 600;
  transition: opacity 0.15s; text-decoration: none;
}
.auth-link-action:hover { text-decoration: underline; opacity: 0.80; }
.auth-link-muted {
  color: var(--text-light); cursor: pointer; font-size: 12px;
  transition: color 0.15s; text-decoration: none;
}
.auth-link-muted:hover { color: var(--text-muted); }
.auth-copyright {
  margin-top: auto; padding-top: 12px;
  font-size: 11px; color: var(--text-light); text-align: center;
}
.auth-msg {
  display: none; width: 100%; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; text-align: center; margin-bottom: 16px;
}
.auth-msg.error { display: block; background: var(--danger-bg); color: var(--danger); }
.auth-msg.success { display: block; background: var(--success-bg); color: var(--success); }

/* Demo account card removed */

/* ========== App Layout ========== */
.app-layout { display: flex; width: 100%; min-height: 100vh; }

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  height: 100vh; position: sticky; top: 0;
  background: linear-gradient(160deg, #1c1917 0%, #0c0a09 60%, #1c1917 100%);
  display: flex; flex-direction: column; z-index: 100; user-select: none; flex-shrink: 0;
  position: relative; overflow: hidden;
}
.sidebar::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(120, 113, 108, 0.18) 0%, transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(68, 64, 60, 0.22) 0%, transparent 40%);
  pointer-events: none;
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 24px 16px 20px; }
.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--white); flex-shrink: 0;
}
.sidebar-logo-text-stack { display: flex; flex-direction: column; gap: 2px; }
.sidebar-logo-text { font-size: 22px; font-weight: 700; color: var(--white); letter-spacing: 0.02em; }
.sidebar-logo-subtitle { font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.55); letter-spacing: 0.14em; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 12px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 14px; border-radius: var(--radius-lg);
  cursor: pointer; transition: all 0.15s ease; text-decoration: none;
  color: rgba(255,255,255,0.75); font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active {
  background: #f7f2ed; color: #1c1917;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.nav-item .nav-icon {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; opacity: 0.75; flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-admin-separator {
  height: 1px; background: rgba(255,255,255,0.12); margin: 8px 14px;
}
.nav-item.admin-only { display: none; }

.sidebar-footer { padding: 16px; margin-top: auto; }
.user-profile-actions { display: flex; align-items: center; gap: 8px; }
.user-profile {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(4px); cursor: pointer; transition: background 0.15s;
}
.user-profile:hover { background: rgba(255,255,255,0.12); }
.sidebar-logout-btn {
  height: 44px; padding: 0 14px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.10); border-radius: var(--radius-lg);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.sidebar-logout-btn:hover { background: rgba(239,68,68,0.25); color: #fff; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.user-avatar.admin-avatar { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.user-info .user-name { font-size: 14px; font-weight: 600; color: var(--white); }
.user-info .user-role { font-size: 11px; color: rgba(255,255,255,0.60); }

/* ========== Main Content ========== */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; background: var(--bg-page); }
.page { display: none; flex-direction: column; height: 100%; min-height: 100vh; }
.page.active { display: flex; }

/* ========== Top Toolbar ========== */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px 16px; background: var(--bg-page); flex-shrink: 0;
  flex-wrap: wrap; gap: 12px;
}
.toolbar-left h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-xl);
  font-size: 13px; font-weight: 500; border: none; cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap; font-family: inherit;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-header); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 6px 12px; }
.btn-ghost:hover { background: var(--bg-header); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; }

.content-area {
  flex: 1; overflow-y: auto; overflow-x: auto; padding: 0 32px 32px;
}
.content-area::-webkit-scrollbar { width: 6px; height: 6px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ========== Cards ========== */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-body { padding: 20px; }

/* Stat Cards */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; transition: box-shadow 0.2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card.highlight-blue {
  background: linear-gradient(135deg, #1c1917 0%, #292524 100%);
  border-color: transparent;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.stat-card.highlight-blue .stat-label,
.stat-card.highlight-blue .stat-sub { color: rgba(255,255,255,0.80); }
.stat-card.highlight-blue .stat-value { color: var(--white); }
.stat-card:not(.highlight-blue) .stat-value { color: var(--text-primary); }
.stat-card .stat-sub { font-size: 12px; margin-top: 6px; }
.stat-card .stat-sub.green { color: var(--success); }
.stat-card .stat-sub.orange { color: var(--warning); }
.stat-card .stat-sub.red { color: var(--danger); }

/* ========== Tables ========== */
.table-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; min-width: 600px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap; gap: 8px;
}
.section-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.data-table { width: 100%; border-collapse: collapse; table-layout: auto; min-width: 700px; }
.data-table thead th {
  padding: 12px 20px; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: none; letter-spacing: 0.01em;
  background: var(--bg-header); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody td {
  padding: 14px 20px; font-size: 13px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-header); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

.action-link {
  color: var(--primary); text-decoration: none; font-size: 12px;
  font-weight: 500; cursor: pointer; transition: color 0.15s;
  white-space: nowrap; margin-right: 14px; display: inline-block;
}
.action-link:last-child { margin-right: 0; }
.action-link.purple { color: #7C3AED; }
.action-link.red { color: var(--danger); }
.action-link:hover { text-decoration: underline; opacity: 0.85; }

.fee-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fee-amount { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.fee-status { font-size: 10px; }
.fee-status.collected { color: var(--success); }
.fee-status.pending { color: var(--danger); }
.fee-status.empty { color: var(--text-light); }

.fee-detail-cell { display: flex; flex-wrap: wrap; gap: 6px; }
.fee-item-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.fee-item-tag.fee-item-collected { background: var(--success-bg); color: var(--success); }
.fee-item-tag.fee-item-pending { background: var(--danger-bg); color: var(--danger); }
.fee-item-tag.collected {
    background: #ecfdf5; border: 1px solid #10b981; color: #047857;
    cursor: pointer; position: relative;
}
.fee-item-tag.collected small {
    font-size: 10px; opacity: 0.7; margin-left: 4px; font-weight: normal;
}
.fee-item-tag.pending-fee {
    cursor: pointer;
}
.badge-partial { background: rgba(245, 158, 11, 0.1); color: #D97706; }
.receipt-time-col {
    font-size: 11px; color: var(--text-light); text-align: center;
}

.tenant-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 12px; font-weight: 600;
  vertical-align: middle; flex-shrink: 0;
}
.avatar-blue { background: linear-gradient(135deg, #78716c, #57534e); }
.avatar-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.avatar-red { background: linear-gradient(135deg, #ef4444, #dc2626); }

.search-bar { position: relative; width: 280px; }
.search-bar input {
  width: 100%; padding: 9px 38px 9px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  font-size: 13px; outline: none; font-family: inherit; transition: border-color 0.15s;
}
.search-bar input:focus { border-color: var(--primary); }
.search-bar .search-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); font-size: 14px; pointer-events: none;
}

.toolbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 600; font-size: 14px; cursor: pointer; flex-shrink: 0;
}

.view-all-link {
  color: var(--primary); font-size: 13px; font-weight: 500;
  text-decoration: none; display: flex; align-items: center; gap: 4px;
}
.view-all-link:hover { text-decoration: underline; }

/* ======== Rent Records Rule Banner ======== */
.rule-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 24px; margin-top: 16px;
  background: var(--info-bg); border-radius: 0;
  font-size: 12px; color: var(--primary-dark); font-weight: 500;
}
.rule-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* ======== RECEIPT - Optimized ======== */
.receipt-container { max-width: 720px; margin: 0 auto; padding: 32px; position: relative; }
.receipt-header { text-align: center; margin-bottom: 28px; }
.receipt-title { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.receipt-subtitle { font-size: 11px; color: var(--text-light); letter-spacing: 0.2em; margin-top: 2px; }

.receipt-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 16px; border-radius: var(--radius-xl);
  font-size: 13px; font-weight: 500;
  border: 1px solid;
}
.receipt-badge.collected { background: var(--success-bg); color: var(--success); border-color: rgba(16,185,129,0.25); }
.receipt-badge.preview { background: var(--warning-bg); color: #B45309; border-color: rgba(245,158,11,0.3); }
.receipt-badge.partial { background: rgba(245,158,11,0.08); color: #D97706; border-color: rgba(245,158,11,0.2); }

/* Preview watermark */
.receipt-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 72px; font-weight: 800; color: rgba(245,158,11,0.06); white-space: nowrap;
  pointer-events: none; z-index: 0; letter-spacing: 0.15em; user-select: none;
  text-shadow: 0 0 1px rgba(245,158,11,0.1);
}
.receipt-preview-notice {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; margin-bottom: 20px;
  background: #FFFBEB; border: 1px solid rgba(245,158,11,0.25); border-radius: var(--radius-lg);
  font-size: 13px; color: #92400E;
  position: relative; z-index: 1;
}
.receipt-preview-notice .notice-icon { font-size: 18px; flex-shrink: 0; }

.receipt-meta-row { display: flex; gap: 48px; margin-bottom: 24px; flex-wrap: wrap; }
.receipt-meta-item label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.receipt-meta-item value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.party-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.party-card { padding: 16px 20px; background: #fafaf9; border-radius: var(--radius-lg); }
.party-card h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.party-card .name { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.party-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

.property-info-box { padding: 16px 20px; background: #fafaf9; border-radius: var(--radius-lg); margin-bottom: 24px; }
.property-info-box p { font-size: 13px; color: var(--text-secondary); line-height: 1.8; }

/* Receipt Table */
.receipt-table { width: 100%; border-collapse: collapse; margin-bottom: 0; position: relative; z-index: 1; }
.receipt-table thead th {
  background: var(--primary); color: var(--white);
  padding: 12px 16px; font-size: 13px; font-weight: 600; text-align: left;
}
.receipt-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.receipt-table thead th:last-child { border-radius: 0 var(--radius-lg) 0 0; text-align: center; }
.receipt-table thead th:nth-child(3) { text-align: right; }
.receipt-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); font-size: 13px; color: var(--text-secondary); }
.receipt-table td:last-child { text-align: center; font-weight: normal; color: var(--text-light); }
.receipt-table td:nth-child(3) { text-align: right; font-weight: 600; color: var(--text-primary); }

/* Fixed base rent row - visually distinct */
.receipt-table tr.base-rent-row td {
  background: rgba(28,25,23,0.04); font-weight: 600;
}
.receipt-table tr.base-rent-row td:first-child::before {
  content: '🏠 '; margin-right: 2px;
}
.receipt-table tr.base-rent-row td:first-child {
  color: var(--primary-dark); font-weight: 600;
}

/* Preview mode: gray-out non-rent items */
.receipt-table.preview-mode tr.fee-row td { opacity: 0.6; }
.receipt-table.preview-mode tr.base-rent-row td { opacity: 1; }

.receipt-total-row td {
  background: var(--primary); color: var(--white);
  font-size: 17px; font-weight: 700; padding: 16px;
}
.receipt-total-row td:first-child { border-radius: 0 0 0 var(--radius-lg); }
.receipt-total-row td:last-child { border-radius: 0 0 var(--radius-lg) 0; color: var(--white); }

.receipt-signature { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 28px; }
.signature-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.signature-line { height: 44px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); }

/* Preview mode: signature not yet valid */
.receipt-preview-mode .signature-line {
  border-style: dashed; border-color: var(--border-light);
}

/* ======== Fee Statistics ======== */
.prop-stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.prop-stat-card { border-radius: var(--radius-lg); padding: 20px 24px; border: 1px solid; }
.prop-stat-card.blue { background: var(--primary); border-color: transparent; color: var(--white); }
.prop-stat-card.green { background: var(--success-bg); border-color: rgba(16,185,129,0.2); }
.prop-stat-card.red { background: var(--danger-bg); border-color: rgba(239,68,68,0.2); }
.prop-stat-card .psc-label { font-size: 12px; opacity: 0.85; margin-bottom: 6px; }
.prop-stat-card .psc-val { font-size: 22px; font-weight: 700; }
.prop-stat-card .psc-sub { font-size: 11px; opacity: 0.70; margin-top: 4px; }

.prop-detail-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 20px; overflow: hidden; }
.prop-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border-light); flex-wrap: wrap; gap: 8px;
}
.prop-card-header .prop-name { font-size: 15px; font-weight: 600; }
.prop-card-header .prop-address { font-size: 12px; color: var(--text-light); margin-left: 8px; }
.prop-card-header .prop-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: var(--radius-xl); font-size: 12px; font-weight: 500;
}
.prop-card-header .badge-all-collected { background: var(--success-bg); color: var(--success); }
.prop-card-header .badge-partial { background: var(--danger-bg); color: var(--danger); }

.fee-detail-table { width: 100%; border-collapse: collapse; }
.fee-detail-table td {
  padding: 12px 20px; font-size: 13px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
.fee-detail-table tr:last-child td { border-bottom: none; background: #fafaf9; font-weight: 600; }
.fee-detail-table td:last-child { text-align: right; font-weight: 600; }

/* ======== Contract Management ======== */
.contract-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.year-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.year-tab {
  padding: 7px 18px; border-radius: var(--radius-xl); font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; background: #F3F4F6; color: var(--text-muted);
  transition: all 0.15s; font-family: inherit;
}
.year-tab.active { background: var(--primary); color: var(--white); }
.year-tab:hover:not(.active) { color: var(--text-secondary); }

.tenant-info-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #f5f0eb; border-radius: var(--radius-lg);
  margin-bottom: 20px; max-width: fit-content;
}
.tenant-info-bar .tenant-name { font-size: 15px; font-weight: 600; }
.tenant-info-bar .sep { color: var(--text-light); font-size: 18px; }
.tenant-info-bar .tenant-prop { font-size: 13px; color: var(--text-muted); }
.contract-stats-text { font-size: 13px; color: var(--text-muted); margin-left: auto; }
.pdf-tag {
  font-size: 10px; color: var(--danger); font-weight: 600;
  background: rgba(239,68,68,0.06); padding: 1px 6px; border-radius: 3px;
  margin-left: 6px; display: inline-block;
}
.days-remaining { font-size: 13px; font-weight: 500; }
.days-green { color: var(--success); }
.days-orange { color: var(--warning); }
.days-red { color: var(--danger); }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; background: #F3F4F6; border: none; border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
  font-family: inherit; font-weight: 500; transition: background 0.15s;
}
.back-btn:hover { background: var(--border); }

/* ======== User Management ======== */
.password-reset-modal {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 3000;
  align-items: center; justify-content: center;
}
.password-reset-modal.active { display: flex; }
.password-reset-dialog {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--white); border-radius: var(--radius-xl); padding: 32px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
}
.password-reset-dialog h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.password-reset-dialog .reset-target { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.password-reset-dialog .reset-input {
  width: 100%; height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: 14px; margin-bottom: 20px; outline: none;
}
.password-reset-dialog .reset-input:focus { border-color: var(--primary); }
.password-reset-actions { display: flex; gap: 12px; justify-content: flex-end; }

.toast {
  position: fixed; top: 24px; right: 24px; z-index: 4000;
  padding: 12px 20px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateX(120%); transition: transform 0.3s ease;
  max-width: 380px;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); color: var(--white); }
.toast.error { background: var(--danger); color: var(--white); }
.toast.info { background: var(--primary); color: var(--white); }

/* ========== Modal ========== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 3000;
  align-items: flex-start; justify-content: center; padding-top: 40px;
  overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-dialog {
  width: 520px; max-width: calc(100vw - 32px);
  background: var(--white); border-radius: var(--radius-xl);
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  margin-bottom: 40px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px; border: none; background: transparent;
  font-size: 20px; color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-header); }
.modal-body { padding: 24px; max-height: 60vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; gap: 12px; justify-content: flex-end; }

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: inherit; font-size: 13px; outline: none; color: var(--text-primary);
  background: var(--white); transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-select { cursor: pointer; appearance: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.fee-config-table { width: 100%; border-collapse: collapse; }
.fee-config-table th { padding: 8px 12px; font-size: 11px; color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border); }
.fee-config-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-light); }
.fee-config-table input { width: 80px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; text-align: right; }
.fee-config-table input:focus { border-color: var(--primary); outline: none; }

/* 计量费用输入行 */
.metered-fee-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.metered-input { width: 80px; }
.metered-result { font-weight: 600; color: var(--primary); min-width: 80px; }

/* 编辑费用模态框 */
.fee-edit-section { margin: 16px 0; }
.fee-edit-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fee-edit-label { font-weight: 500; min-width: 100px; }
.fee-edit-total { font-size: 16px; font-weight: 600; color: var(--primary); padding: 12px 0; border-top: 2px solid var(--border); margin-top: 12px; }

.receipt-selector { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border-light); }
.receipt-selector select { height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); font-family: inherit; font-size: 13px; }

.month-selector { display: flex; gap: 4px; flex-wrap: wrap; }
.month-tab {
  padding: 5px 14px; border-radius: var(--radius-xl); font-size: 12px;
  border: 1px solid var(--border); cursor: pointer; background: transparent;
  color: var(--text-secondary); font-family: inherit; font-weight: 500;
}
.month-tab.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.month-tab:hover:not(.active) { background: var(--bg-header); }

/* ========== Loading Indicator ========== */
.loading-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.6); z-index: 5000;
  align-items: center; justify-content: center;
}
.loading-overlay.active { display: flex; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Responsive ========== */
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .prop-stats-cards { grid-template-columns: 1fr; }
  .party-cards { grid-template-columns: 1fr; }
  .receipt-signature { grid-template-columns: 1fr; }
  .receipt-meta-row { gap: 24px; }
}
@media (max-width: 900px) {
  .toolbar { padding: 16px 20px 12px; }
  .content-area { padding: 0 20px 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px 20px; }
  .stat-card .stat-value { font-size: 24px; }
  .auth-card { padding: 36px 28px; }
}
@media (max-width: 820px) {
  .auth-brand-panel { display: none; }
  .auth-form-panel {
    width: 100%; padding: 32px 24px;
    justify-content: flex-start;
  }
  .auth-form-scroll { max-width: 400px; }
  .auth-brand-headline { font-size: 32px; }
}
@media (max-width: 480px) {
  .auth-form-panel { padding: 24px 20px; }
  .auth-form-scroll { max-width: 100%; }
  .auth-title { font-size: 22px; }
  .auth-brand-footer { flex-wrap: wrap; gap: 24px; }
}
/* Print styles for receipt */
@media print {
  .sidebar, .toolbar, .receipt-selector, .receipt-preview-notice, .receipt-watermark, .nav-item, .toast, .modal-overlay, .password-reset-modal, .auth-screen, .loading-overlay { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .page { display: block !important; }
  #page-receipt { display: block !important; }
  .receipt-container { max-width: 100%; padding: 20px; }
  .receipt-preview-mode .signature-line { border-style: solid; }
  body { background: white; }
}
