:root {
  --accent: #6c63ff;
  --bg: #f4f5f9;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f0c29, #302b63, #24243e); }
.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }
.login-logo { text-align: center; margin-bottom: 24px; color: #fff; }
.login-icon { width: 64px; height: 64px; margin: 0 auto 12px; background: linear-gradient(135deg, var(--accent), #a855f7); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; }
.login-card { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 32px; backdrop-filter: blur(12px); color: #fff; }
.login-card h2 { margin: 0 0 6px; }
.login-card .subtitle { color: rgba(255,255,255,.55); font-size: 13px; margin: 0 0 20px; }
.login-card label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; color: rgba(255,255,255,.7); }
.login-card input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.95); color: #111827; font: inherit; }
.login-card input::placeholder { color: rgba(17, 24, 39, 0.45); }
.login-hint { text-align: center; font-size: 12px; color: rgba(255,255,255,.4); margin-top: 16px; }
.lang-toggle-login { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.lang-toggle-login a { padding: 6px 12px; border-radius: 8px; background: rgba(255,255,255,.1); color: #fff; font-size: 12px; font-weight: 600; }
.lang-toggle-login a.active { background: var(--accent); }

/* App layout */
.app-body { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 16px; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-width: 0; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.brand-logo-img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; }
.sidebar-brand strong { display: block; font-size: 11px; line-height: 1.3; letter-spacing: .3px; }
.sidebar-brand small { color: var(--muted); font-size: 10px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link { padding: 11px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--muted); }
.nav-link:hover { background: #f3f4f6; color: var(--text); }
.nav-link.active { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); font-weight: 600; }
.sidebar-footer { margin-top: auto; }
.lang-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.lang-toggle a { flex: 1; text-align: center; padding: 8px; border-radius: 8px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); }
.lang-toggle a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.version { display: block; text-align: center; color: var(--muted); font-size: 11px; margin-bottom: 10px; }
.btn-logout { display: block; text-align: center; padding: 10px; border: 1px solid var(--red); color: var(--red); border-radius: 10px; font-weight: 600; font-size: 13px; }

/* Components */
h1 { margin: 0; font-size: 26px; font-weight: 800; }
.eyebrow { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; }
.live-badge { font-size: 11px; color: var(--muted); background: #fff; border: 1px solid var(--border); padding: 8px 12px; border-radius: 999px; }
.hero-card { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, #000), var(--accent)); color: #fff; border-radius: 16px; padding: 24px 28px; margin-bottom: 24px; }
.hero-card p { margin: 8px 0 0; opacity: .85; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 22px; margin-bottom: 20px; }
.card h3 { margin: 0 0 16px; font-size: 16px; }
.card-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-header-row h3 { margin: 0; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: #fff; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: none; font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-warning { background: #fef3c7; color: #92400e; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 14px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-icon { background: #f3f4f6; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

.filter-bar { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; background: #fff; padding: 16px; border-radius: 14px; border: 1px solid var(--border); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-compact .kpi-card h2 { font-size: 22px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-card h2 { margin: 8px 0 0; font-size: 28px; font-weight: 800; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.kpi-green .kpi-icon { background: #d1fae5; color: var(--green); }
.kpi-red .kpi-icon { background: #fee2e2; color: var(--red); }
.kpi-green-soft { background: #ecfdf5; }
.kpi-red-soft { background: #fef2f2; }
.kpi-yellow-soft { background: #fffbeb; }
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 99px; margin: 12px 0 6px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.progress-red span { background: var(--red); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.shops-layout { align-items: start; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.pill-paid { background: #d1fae5; color: #047857; }
.pill-partial, .pill-vacant { background: #f3f4f6; color: #4b5563; }
.pill-unpaid { background: #fee2e2; color: #b91c1c; }
.pill-occupied { background: #d1fae5; color: #047857; }

.chart-list { display: flex; flex-direction: column; gap: 16px; }
.chart-row .chart-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.stacked-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: #fee2e2; }
.bar-paid { background: var(--green); }
.bar-due { background: var(--red); flex: 1; }

.shop-cards { display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
.shop-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.shop-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.shop-card p { margin: 4px 0; font-size: 14px; color: var(--muted); }
.rent-line { color: var(--text) !important; font-weight: 600; }
.shop-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

.invoice-workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 20px 0 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.deduction-add-row, .payment-add-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.ledger-list { list-style: none; padding: 0; margin: 12px 0; }
.ledger-list li { display: flex; justify-content: space-between; padding: 10px 12px; background: #f9fafb; border-radius: 8px; margin-bottom: 6px; font-size: 14px; }
.summary-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.summary-box { padding: 12px; border-radius: 12px; text-align: center; }
.summary-box small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.summary-box strong { font-size: 18px; }
.summary-net { background: #ede9fe; }
.summary-paid { background: #d1fae5; }
.summary-due { background: #fef3c7; }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.search-form input { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; min-width: 280px; font: inherit; }
.actions-cell { display: flex; gap: 8px; align-items: center; }

.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card-danger { border-color: #fecaca; background: #fff5f5; }
.color-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch { width: 32px; height: 32px; border-radius: 8px; cursor: pointer; position: relative; border: 2px solid transparent; }
.color-swatch input { position: absolute; opacity: 0; }
.color-swatch:has(input:checked) { border-color: #000; box-shadow: 0 0 0 2px #fff inset; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.logo-preview { max-height: 60px; display: block; margin-bottom: 10px; }

/* Invoice print */
.invoice-print { background: #fff; padding: 24px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.inv-header { display: grid; grid-template-columns: 100px 1fr auto; gap: 16px; align-items: start; margin-bottom: 16px; }
.inv-logo img { max-height: 70px; max-width: 100px; }
.inv-logo-placeholder { width: 80px; height: 60px; border: 2px dashed #ccc; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #999; }
.inv-company h2 { margin: 0 0 4px; font-size: 18px; }
.inv-company p { margin: 2px 0; color: var(--muted); font-size: 12px; }
.inv-meta { text-align: right; font-size: 12px; }
.inv-qr { margin-top: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.inv-qr-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.inv-qr img { width: 92px; height: 92px; object-fit: contain; background: #fff; border-radius: 8px; padding: 6px; }
.inv-title-bar { color: #fff; text-align: center; padding: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 16px; border-radius: 4px; }
.inv-billing-box { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; background: #f9fafb; padding: 14px; border-radius: 8px; margin-bottom: 16px; }
.inv-billing-box small { display: block; color: var(--muted); text-transform: uppercase; font-size: 10px; margin-bottom: 4px; }
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.inv-table th, .inv-table td { border: 1px solid var(--border); padding: 10px; }
.inv-table th { background: #f3f4f6; text-align: left; }
.inv-table td:last-child { text-align: right; width: 120px; }
.inv-summary { margin-left: auto; max-width: 320px; }
.inv-summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.inv-due-row { background: #ecfdf5; padding: 10px !important; font-weight: 800; margin-top: 8px; border-radius: 6px; }
.inv-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 32px; }
.inv-signatures div { border-top: 1px solid #333; padding-top: 8px; text-align: center; font-size: 11px; color: var(--muted); }
.inv-owner-signature-img { max-width: 150px; max-height: 54px; object-fit: contain; display: block; margin: 0 auto 6px; }
.inv-payments h4 { margin: 0 0 8px; font-size: 12px; }
.inv-payments ul { margin: 0; padding-left: 18px; font-size: 12px; }

.invoice-design-classic .inv-title-bar { border-radius: 0; font-family: Georgia, serif; }
.invoice-design-minimal .inv-title-bar { background: transparent !important; color: var(--text); border-bottom: 2px solid var(--text); }

/* Strong theme differences so selection is clearly visible */
.invoice-design-modern.invoice-print { border-radius: 12px; }
.invoice-design-modern .inv-title-bar { border-radius: 10px; letter-spacing: 0.6px; }

.invoice-design-classic.invoice-print { border: 2px solid #111827; }
.invoice-design-classic .inv-table th, .invoice-design-classic .inv-table td { font-family: Georgia, 'Times New Roman', serif; }
.invoice-design-classic .inv-billing-box { border: 1px solid #111827; }

.invoice-design-minimal.invoice-print { border: none; box-shadow: none; padding: 18px; }
.invoice-design-minimal .inv-table th, .invoice-design-minimal .inv-table td { border-color: rgba(31,41,55,0.25); }
.invoice-design-minimal .inv-billing-box { background: transparent; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .invoice-workspace, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: static; width: 100%; }
  .main-content { margin-left: 0; padding: 16px; }
  .app-body { flex-direction: column; }
  .kpi-grid { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .page-header, .no-print, .invoice-form-card, .btn { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .print-only-body { padding: 0; }
  .invoice-print { border: none; }
}
