/* ============================================================
   FARUQ'S LEDGER - MINIMAL, CLEAN & AESTHETIC DESIGN
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --accent: #0f172a;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #e11d48;
  --red-bg: #fff1f2;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
}

/* App Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: 10px;
  transition: all 0.15s ease;
  user-select: none;
}

.brand:hover {
  background: var(--border-subtle);
}

.brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--text-main);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-caret {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.brand:hover .brand-caret {
  color: var(--text-main);
  transform: translateY(1px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.35rem;
}

.icon-btn:hover {
  background: var(--border-subtle);
}

.icon-btn:active {
  transform: scale(0.97);
}

/* Main Container */
.main-wrapper {
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Hero Balance Card */
.hero-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.balance-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.balance-amount {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-top: 0.15rem;
}

/* Account Split Cards */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1rem;
}

.split-card {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.split-card:hover {
  border-color: var(--text-light);
}

.split-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.split-card-amount {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
}

/* Primary Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-received {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--green);
  color: #ffffff;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-received:hover {
  background: #047857;
}

.btn-received:active {
  transform: scale(0.98);
}

.btn-paid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--red);
  color: #ffffff;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-paid:hover {
  background: #be123c;
}

.btn-paid:active {
  transform: scale(0.98);
}

/* Account Filter Pills */
.filter-tabs {
  display: flex;
  background: var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.tab-btn {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Search & Filter Bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--text-main);
}

.select-filter {
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

/* Transaction List */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tx-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tx-row:hover {
  border-color: var(--text-light);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.tx-badge-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.tx-badge-icon.received {
  background: var(--green-bg);
  color: var(--green);
}

.tx-badge-icon.paid {
  background: var(--red-bg);
  color: var(--red);
}

.tx-details {
  min-width: 0;
}

.tx-note {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tag-account {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  background: var(--border-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.tx-right {
  text-align: right;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 0.95rem;
  font-weight: 700;
}

.tx-amount.received {
  color: var(--green);
}

.tx-amount.paid {
  color: var(--red);
}

.tx-balance-point {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.tx-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.7rem;
}

.tx-action-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}

.tx-action-btn:hover {
  color: var(--text-main);
}

.tx-action-btn.del:hover {
  color: var(--red);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .modal-content {
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
}

.form-input:focus {
  border-color: var(--text-main);
}

.amount-input-box {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
}

.amount-input-box input {
  padding-left: 2rem;
  font-size: 1.35rem;
  font-weight: 800;
}

.type-toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.toggle-option {
  cursor: pointer;
}

.toggle-option input {
  display: none;
}

.toggle-box {
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.toggle-option input:checked + .toggle-box {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.submit-btn {
  width: 100%;
  padding: 0.85rem;
  background: var(--text-main);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.5rem;
}

.submit-btn:hover {
  background: #1e293b;
}

.submit-btn:active {
  transform: scale(0.98);
}

/* Statement Modal Elements */
.period-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.period-chip {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
}

.period-chip.active {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.statement-summary-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.summary-metric-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.summary-metric-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.1rem;
}

.summary-metric-val.green {
  color: var(--green);
}

.summary-metric-val.red {
  color: var(--red);
}

.secondary-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--border-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.secondary-btn:hover {
  background: #e2e8f0;
}

/* Printable Statement Layout (for @media print) */
.print-only {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header, .main-wrapper, .modal-backdrop {
    display: none !important;
  }
  .print-only {
    display: block !important;
    padding: 15mm;
  }
  .print-header-clean {
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }
  .print-table-clean {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
    font-size: 9pt;
  }
  .print-table-clean th, .print-table-clean td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: left;
  }
  .print-table-clean th {
    background-color: #f1f5f9 !important;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Remove any Netlify badge on screen & print */
iframe[src*="netlify"],
[data-netlify-badge],
.netlify-badge,
#netlify-badge,
[id*="netlify"],
[class*="netlify"],
[href*="netlify.com"],
div:has(> a[href*="netlify.com"]),
div[style*="z-index: 2147483647"],
div[style*="z-index: 1000000"],
netlify-drawer,
netlify-badge {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  clip: rect(0, 0, 0, 0) !important;
}

@media print {
  [data-netlify-badge],
  .netlify-badge,
  #netlify-badge,
  [id*="netlify"],
  [class*="netlify"],
  [href*="netlify.com"] {
    display: none !important;
  }
}

/* Floating Selection Toolbar (Long-Press Multi-Delete) */
.selection-toolbar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 480px;
  background: var(--text-main);
  color: #ffffff;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  z-index: 50;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.selection-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  transition: all 0.15s ease;
}

.selection-mode .selection-checkbox {
  display: flex;
}

.tx-row.selected {
  border-color: var(--text-main);
  background: var(--border-subtle);
}

.tx-row.selected .selection-checkbox {
  background: var(--text-main);
  border-color: var(--text-main);
  color: #ffffff;
}

/* Card Tap Remarks Expansion */
.tx-remarks-expand {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-main);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* Cloud Sync & View-Only Mode */
.sync-btn {
  padding: 0.42rem 0.55rem;
  font-size: 0.75rem;
}

.sync-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-light);
  display: inline-block;
  flex-shrink: 0;
}

.sync-status-dot.synced {
  background: #10b981;
}

.sync-status-dot.syncing {
  background: #f59e0b;
}

.sync-status-dot.error {
  background: #ef4444;
}

.view-only-pill {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--border-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}

body.view-only .action-buttons,
body.view-only .tx-action-btn.edit,
body.view-only .tx-action-btn.del,
body.view-only .owner-only,
body.view-only #selectionToolbar {
  display: none !important;
}

/* Accounts / Persons Switcher */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}

.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 0.75rem;
}

.account-item:hover {
  border-color: var(--text-light);
  background: var(--border-subtle);
}

.account-item.active {
  border-color: var(--text-main);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.account-item-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--border-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.account-item.active .account-avatar {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.account-info {
  flex: 1;
  min-width: 0;
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.account-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-active-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.account-balance-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.acc-icon-btn {
  background: none;
  border: none;
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.acc-icon-btn:hover {
  background: var(--border);
  color: var(--text-main);
}

.acc-icon-btn.delete:hover {
  background: #fef2f2;
  color: var(--red);
}

.add-account-card {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}
