/* ============================================================================
   Citadele PSD2 Multi-Tenant SaaS Hub — Light-First Design System (theme.css)
   Noklusējums startā: Gaišie toņi (Day / Light Mode) + Dark & System atbalsts
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root,
[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Banka Citadele iedvesmots rubīnsarkanais akcents + finanšu semantiskie toņi */
  --brand-primary: #c8102e;
  --brand-primary-hover: #a50d26;
  --brand-soft: #fff1f2;
  --brand-border: #fecdd3;

  --income-fg: #047857;
  --income-bg: #ecfdf5;
  --expense-fg: #b91c1c;
  --expense-bg: #fef2f2;
  --warning-fg: #b45309;
  --warning-bg: #fffbeb;
  --info-fg: #1d4ed8;
  --info-bg: #eff6ff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --border-strong: #334155;

  --brand-primary: #ef4444;
  --brand-primary-hover: #dc2626;
  --brand-soft: rgba(239, 68, 68, 0.14);
  --brand-border: rgba(239, 68, 68, 0.35);

  --income-fg: #34d399;
  --income-bg: rgba(16, 185, 129, 0.15);
  --expense-fg: #f87171;
  --expense-bg: rgba(239, 68, 68, 0.15);
  --warning-fg: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --info-fg: #60a5fa;
  --info-bg: rgba(59, 130, 246, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, .mono {
  font-family: 'IBM Plex Mono', Consolas, monospace;
  font-size: 0.875rem;
}

/* Header & Navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 1rem;
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.brand-logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
  border-radius: 10px;
}

.brand-logo-mark {
  width: 44px;
  height: 44px;
  display: block;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.brand-logo-link:hover .brand-logo-mark {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.auth-brand-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-color);
}

.auth-brand-banner img {
  max-width: 100%;
  height: auto;
}

.logo-dark {
  display: none;
}

[data-theme="dark"] .logo-light {
  display: none;
}

[data-theme="dark"] .logo-dark {
  display: block;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* 3-Mode Theme Switcher */
.theme-switcher {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 150ms ease, color 150ms ease;
}

.theme-btn.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Main Navigation Tabs */
.nav-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.nav-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  overflow-x: auto;
  gap: 0.25rem;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: color 150ms ease, border-color 150ms ease;
}

.nav-tab:hover {
  color: var(--brand-primary);
}

.nav-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* Page Container */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Policy Banner */
.policy-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-color);
}

.policy-banner.draft-only {
  background: var(--warning-bg);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--warning-fg);
}

.policy-banner.exec-enabled {
  background: var(--income-bg);
  border-color: rgba(5, 150, 105, 0.35);
  color: var(--income-fg);
}

/* Grid & Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

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

@media (min-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-value.income { color: var(--income-fg); }
.kpi-value.expense { color: var(--expense-fg); }

.kpi-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-income, .badge-valid { background: var(--income-bg); color: var(--income-fg); }
.badge-expense, .badge-expired { background: var(--expense-bg); color: var(--expense-fg); }
.badge-warning, .badge-received, .badge-draft { background: var(--warning-bg); color: var(--warning-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); }

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 768px) {
  .form-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .form-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Mandatory Password Field with Eye Visibility Toggle ("Actiņa" - Rule 38) */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-wrapper .input {
  padding-right: 3.1rem;
}

.pw-toggle-btn {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pw-toggle-btn:hover, .pw-toggle-btn:focus-visible {
  background: var(--bg-subtle);
  color: var(--text-primary);
  outline: 2px solid var(--brand-primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-success {
  background: var(--income-fg);
  color: #ffffff;
}

.btn-sm {
  min-height: 34px;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

/* Tables & Mandatory Column Sorting (Rule 37) */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
  padding: 0.72rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

table.data-table thead th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease;
}

table.data-table thead th:hover {
  background: var(--bg-hover);
  color: var(--brand-primary);
}

table.data-table thead th .sort-indicator {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

table.data-table thead th[aria-sort="ascending"] .sort-indicator,
table.data-table thead th[aria-sort="descending"] .sort-indicator {
  color: var(--brand-primary);
  font-weight: 700;
}

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

.num-col {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Settings Sub-navigation */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 960px) {
  .settings-layout {
    grid-template-columns: 270px 1fr;
  }
}

.settings-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.settings-nav-btn {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.settings-nav-btn.active {
  background: var(--brand-soft);
  color: var(--brand-primary);
  border-color: var(--brand-border);
}

.settings-subpanel {
  display: none;
}

.settings-subpanel.active {
  display: block;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  background: var(--bg-subtle);
}

.toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand-primary);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* Login Page */
.auth-shell {
  min-height: calc(100vh - 75px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 540px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

.demo-pill-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

@media (min-width: 520px) {
  .demo-pill-grid { grid-template-columns: repeat(2, 1fr); }
}

.demo-pill {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
}

.demo-pill:hover {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
}

/* Toast Notification */
#toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 420px;
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  border-left: 4px solid var(--brand-primary);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
}

.toast.ok { border-left-color: var(--income-fg); }
.toast.err { border-left-color: var(--expense-fg); }

/* Multi-File Drag & Drop Import Zone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 1.5rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  outline: none;
}

.dropzone.drag-over {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
  transform: scale(1.005);
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.65rem;
  border-radius: 12px;
  background: var(--bg-surface);
  color: var(--brand-primary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.dropzone-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', Consolas, monospace;
}
