:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header Styles */
.app-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background-color: #f1f5f9;
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.btn-back:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.app-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-sample {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-sample:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.btn-backup {
  background-color: #0284c7;
  color: #ffffff;
}

.btn-backup:hover {
  background-color: #0369a1;
}

.btn-restore {
  background-color: #475569;
  color: #ffffff;
}

.btn-restore:hover {
  background-color: #334155;
}

.btn-export-excel {
  background-color: #059669;
  color: #ffffff;
}

.btn-export-excel:hover {
  background-color: #047857;
}

.btn-print-report {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-print-report:hover {
  background-color: var(--primary-hover);
}

/* Main Container */
.main-container {
  max-width: 1380px;
  margin: 20px auto;
  padding: 0 20px 40px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-balance::before { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.kpi-income::before { background: linear-gradient(90deg, #10b981, #059669); }
.kpi-expense::before { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.kpi-meta::before { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.kpi-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-balance { background-color: #eff6ff; color: #2563eb; }
.icon-income { background-color: #ecfdf5; color: #059669; }
.icon-expense { background-color: #fef2f2; color: #dc2626; }

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  white-space: nowrap;
}

.kpi-income .kpi-value { color: #059669; }
.kpi-expense .kpi-value { color: #dc2626; }
.kpi-balance .kpi-value { color: #1e40af; }

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background-color: #ecfdf5;
  color: #047857;
}

.badge.warning {
  background-color: #fef2f2;
  color: #b91c1c;
}

.meta-info {
  font-size: 12.5px;
  line-height: 1.6;
  color: #334155;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-text:hover {
  text-decoration: underline;
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.form-card {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.tag-live {
  font-size: 11px;
  font-weight: 600;
  background-color: #ecfdf5;
  color: #059669;
  padding: 2px 8px;
  border-radius: 10px;
}

.form-group {
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 {
  flex: 1;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.required {
  color: var(--danger);
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Radio Toggle for Type */
.tx-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background-color: #f8fafc;
}

.radio-label input {
  display: none;
}

.radio-income:has(input:checked) {
  border-color: #10b981;
  background-color: #ecfdf5;
  color: #065f46;
}

.radio-expense:has(input:checked) {
  border-color: #ef4444;
  background-color: #fef2f2;
  color: #991b1b;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-primary {
  flex: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  flex: 1;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Table Card */
.table-card {
  padding: 16px 20px;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-box input {
  padding-left: 36px;
}

.filter-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-outline-danger {
  background: none;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline-danger:hover {
  background-color: #fee2e2;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: #334155;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.badge-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-pill.thu {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-pill.chi {
  background-color: #fee2e2;
  color: #b91c1c;
}

.amount-thu {
  color: #15803d;
  font-weight: 700;
}

.amount-chi {
  color: #b91c1c;
  font-weight: 700;
}

.tx-cat-badge {
  background-color: #f1f5f9;
  color: #475569;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.table-actions {
  display: inline-flex;
  gap: 6px;
}

.btn-icon {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #64748b;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
}

.btn-icon:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.btn-icon-danger:hover {
  background-color: #fee2e2;
  color: #dc2626;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin: 10px 0 14px;
  font-size: 14px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #1e293b;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Printable Report Area */
.printable-report {
  display: none;
  background-color: #ffffff;
  width: 210mm;
  margin: 0 auto;
  padding: 20mm 18mm;
  font-family: 'Times New Roman', Times, serif;
  color: #000000;
  box-sizing: border-box;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 15mm 15mm;
  }

  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  .no-print,
  .app-header,
  .main-container,
  .modal-backdrop,
  .toast {
    display: none !important;
  }

  .printable-report {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-table th,
  .print-table td {
    border-color: #333333 !important;
  }
}

.print-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.print-org {
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
}

.org-school {
  font-weight: 700;
  text-transform: uppercase;
}

.org-class {
  font-size: 12.5px;
  border-bottom: 1px solid #000;
  padding-bottom: 2px;
  display: inline-block;
}

.print-national {
  text-align: center;
  font-size: 13px;
}

.nat-title {
  font-weight: 700;
}

.nat-subtitle {
  font-size: 12.5px;
  font-style: italic;
}

.nat-divider {
  font-size: 9px;
  letter-spacing: 4px;
  margin-top: 2px;
}

.print-title-block {
  text-align: center;
  margin: 22px 0 16px;
}

.print-doc-title {
  font-size: 19px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.print-doc-subtitle {
  font-size: 13px;
  font-style: italic;
}

.print-summary-box {
  display: flex;
  justify-content: space-around;
  border: 1.5px solid #000;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  background-color: #fafafa;
}

.ps-item {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ps-label {
  font-weight: 600;
}

.ps-val {
  font-weight: 700;
}

.ps-highlight .ps-val {
  font-size: 15px;
  color: #000;
  text-decoration: underline;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 24px;
}

.print-table th,
.print-table td {
  border: 1px solid #444;
  padding: 6px 8px;
  vertical-align: middle;
}

.print-table th {
  background-color: #f2f2f2;
  font-weight: 700;
  text-align: center;
}

.print-table .tr-sum td {
  background-color: #f9f9f9;
}

.font-bold {
  font-weight: 700;
}

.text-income {
  color: #15803d;
}

.text-expense {
  color: #b91c1c;
}

.print-footer-sign {
  margin-top: 15px;
  page-break-inside: avoid;
}

.print-date-location {
  text-align: right;
  font-size: 13px;
  font-style: italic;
  margin-bottom: 10px;
}

.sign-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  text-align: center;
}

.sign-title {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

.sign-hint {
  font-size: 11.5px;
  font-style: italic;
  color: #444;
  margin-bottom: 60px;
}

.sign-name {
  font-weight: 700;
  font-size: 13.5px;
}

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
}

/* Welcome / First Time Banner */
.welcome-sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  border: 1px solid #bfdbfe;
  border-left: 5px solid #2563eb;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  animation: fadeIn 0.3s ease-in-out;
}

.welcome-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.welcome-banner-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
  flex-shrink: 0;
}

.welcome-banner-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 2px;
}

.welcome-banner-desc {
  font-size: 13.5px;
  color: #334155;
  margin: 0;
}

.welcome-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-banner-empty {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-banner-empty:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.btn-banner-sample {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: #2563eb;
  border: 1px solid #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.btn-banner-sample:hover {
  background: #1d4ed8;
}

@media (max-width: 768px) {
  .welcome-sample-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .welcome-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

