/* -----------------------------------------------------------
   ENTERPRISE FINANCIAL SAAS DESIGN SYSTEM
   Professional, high-precision statement generator interface
   ----------------------------------------------------------- */

:root {
  /* Corporate Palette - Slate & Deep Enterprise Blue */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Corporate Brand & Functional Accents */
  --brand-primary: #1e3a8a;       /* Deep Navy */
  --brand-primary-hover: #172554;
  --brand-accent: #2563eb;        /* Enterprise Blue */
  --brand-accent-hover: #1d4ed8;
  --brand-accent-subtle: #eff6ff;

  --status-success: #059669;      /* Financial Emerald */
  --status-success-bg: #ecfdf5;
  --status-success-border: #a7f3d0;

  --status-warning: #d97706;      /* Amber */
  --status-warning-bg: #fffbeb;
  --status-warning-border: #fde68a;

  --status-danger: #dc2626;       /* Crimson */
  --status-danger-bg: #fef2f2;
  --status-danger-border: #fecaca;

  --status-info: #0284c7;         /* Sky */
  --status-info-bg: #f0f9ff;
  --status-info-border: #bae6fd;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Precision Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Navigation Bar */
.navbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-shadow: var(--shadow-xs);
}

.brand-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--brand-accent-subtle);
  color: var(--brand-accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--brand-accent);
  color: #ffffff;
  border-color: var(--brand-accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--brand-accent-hover);
  border-color: var(--brand-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  border-color: #94a3b8;
}

.btn-outline {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

/* Upload Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-strong);
  background: var(--bg-surface-subtle);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--brand-accent);
  background: var(--brand-accent-subtle);
}

.drop-icon {
  font-size: 42px;
  color: var(--brand-accent);
  margin-bottom: 12px;
}

.drop-zone h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drop-zone p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.file-input-hidden {
  display: none;
}

.rules-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.rule-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.rule-tag strong {
  color: var(--text-primary);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot.debit {
  background-color: var(--status-danger);
}

.dot.credit {
  background-color: var(--status-success);
}

/* Progress bar */
.upload-progress-bar {
  margin-top: 14px;
}

.progress-track {
  height: 5px;
  background: var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-accent);
  transition: width 0.25s ease;
}

.progress-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

/* Workbench Top Bar */
.workbench-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.file-info-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-primary);
}

.pill {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
}

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

/* Customer Tabs */
.customer-tabs-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tabs-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.customer-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.cust-tab {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.cust-tab:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.cust-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* Grids */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .grid-2-col {
    grid-template-columns: 1fr;
  }
}

/* Forms */
.form-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.col-6 {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-control[readonly] {
  background: var(--bg-surface-subtle);
  color: var(--brand-primary);
  font-weight: 600;
}

.input-symbol-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.symbol-prefix {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8125rem;
}

.with-prefix {
  padding-left: 24px;
}

.company-preview-tag {
  background: var(--bg-surface-subtle);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.company-preview-tag strong {
  color: var(--text-primary);
}

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

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 550px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.debit-card {
  border-left-color: var(--status-danger);
}

.credit-card {
  border-left-color: var(--status-success);
}

.balance-card {
  border-left-color: var(--brand-accent);
}

.meta-card {
  border-left-color: var(--brand-primary);
}

.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.debit-card .kpi-icon {
  background: var(--status-danger-bg);
  color: var(--status-danger);
}

.credit-card .kpi-icon {
  background: var(--status-success-bg);
  color: var(--status-success);
}

.balance-card .kpi-icon {
  background: var(--brand-accent-subtle);
  color: var(--brand-accent);
}

.meta-card .kpi-icon {
  background: var(--bg-surface-subtle);
  color: var(--brand-primary);
}

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.kpi-value.small-text {
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-secondary);
}

/* Table Card */
.table-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.table-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-muted);
}

.table-search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.8125rem;
  outline: none;
  font-family: inherit;
}

.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.data-table thead th {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 10px 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
}

.data-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tbody tr:hover {
  background: var(--bg-surface-subtle);
}

.data-table tbody tr:nth-child(even) {
  background: #fbfcfd;
}

.type-pill {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.type-invoice {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border: 1px solid var(--status-danger-border);
}

.type-deposit {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid var(--status-success-border);
}

.type-payment {
  background: var(--status-info-bg);
  color: var(--status-info);
  border: 1px solid var(--status-info-border);
}

.type-cheque {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid var(--status-warning-border);
}

.mono-num {
  font-family: var(--font-mono);
  font-weight: 500;
}

.debit-val {
  color: var(--status-danger);
  font-weight: 600;
}

.credit-val {
  color: var(--status-success);
  font-weight: 600;
}

.balance-val {
  font-weight: 700;
  color: var(--text-primary);
}

.tfoot-balance-row td {
  background: var(--bg-surface-subtle);
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--brand-primary);
  border-top: 2px solid var(--border-strong);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  padding: 0;
  overflow: hidden;
}

.pdf-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.modal-footer {
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* -----------------------------------------------------------
   MODE SELECTOR COMPONENT (Customer PSM, Vendor PSM, Customer NUK, Vendor NUK)
   ----------------------------------------------------------- */
.mode-selector-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.mode-selector-group,
.currency-selector-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-selector-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-pills,
.currency-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-pill,
.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-pill:hover,
.currency-pill:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.mode-pill.active {
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.15), var(--shadow-xs);
  color: var(--brand-primary);
}

.currency-pill.active {
  background: #ffffff;
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.18), var(--shadow-xs);
  color: #065f46;
}

.curr-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: #ecfdf5;
  color: #059669;
  font-weight: 800;
  font-size: 0.875rem;
  border: 1px solid #a7f3d0;
}

.currency-pill.active .curr-symbol {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

.curr-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.mode-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

.mode-badge.customer {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.mode-badge.vendor {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

.mode-pill.active .mode-badge.customer {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.mode-pill.active .mode-badge.vendor {
  background: #db2777;
  color: #ffffff;
  border-color: #db2777;
}

.mode-company {
  font-size: 0.85rem;
}

