/* VINTEC & CTBA Unified Theme — Open Design: Bento Modular (Light) + Linear Dark Pro (Dark) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f8ff;
  --surface: #ffffff;
  --surface-2: #eaf1ff;
  --card: #ffffff;
  --text: #101828;
  --fg: #101828;
  --muted: #667085;
  --border: #d7e0ef;
  --primary: #2563eb;
  --primary-light: #eaf1ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --r-card: 16px;
  --r-ctrl: 10px;
  --shadow: 0 10px 26px rgba(16, 24, 40, 0.06);
}

html[data-theme="dark"] {
  --bg: #08090a;
  --surface: #141517;
  --surface-2: #1c1e21;
  --card: #141517;
  --text: #f3f4f6;
  --fg: #f3f4f6;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.10);
  --primary: #7c8aff;
  --primary-light: rgba(94, 106, 210, 0.22);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --r-card: 12px;
  --r-ctrl: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  transition: background .2s ease, color .2s ease;
}

/* Full-Width Widescreen ERP Layout (98% viewport width, keep current readable font size) */
main {
  max-width: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
  box-sizing: border-box;
}
header, nav, nav.tabs {
  padding-left: 18px !important;
  padding-right: 18px !important;
}
@media (min-width: 1400px) {
  .form-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
  }
}
/* Wide Data Modals */
#ktCashflowModal > div,
#ktApprovalModal > div,
#cnDetailModal > div,
#kuDetailModal > div,
#hdtgDetailModal > div,
#importModal > div,
#reviewModal > div {
  max-width: min(95vw, 1640px) !important;
}
/* Smart No-Wrap for Financial Tables (no awkward breaks on amounts, dates, badges, buttons) */
th {
  white-space: nowrap !important;
}
td {
  vertical-align: middle;
}
td.num, td.nowrap, td.act-col {
  white-space: nowrap !important;
}
.badge, .btn, .btn-sm, .btn-pill, .btn-icon, .pg-btn {
  white-space: nowrap;
}
#cnBody td:nth-child(3) {
  min-width: 185px;
}

/* Cards & Surfaces (Bento Modular Light / Linear Dark) */
.card, .kpi-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-card) !important;
  box-shadow: var(--shadow) !important;
  color: var(--text);
}
.card-header {
  border-bottom-color: var(--border) !important;
}
html[data-theme="light"] .card-header {
  background: #fafcff !important;
}
html[data-theme="light"] header {
  background: #ffffff !important;
  color: #101828 !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.04);
}
html[data-theme="light"] header a,
html[data-theme="light"] header .pill-date,
html[data-theme="light"] header #globalPeriod,
html[data-theme="light"] header #actorCode {
  background: #eaf1ff !important;
  color: #1d4ed8 !important;
  border-color: #cbd8f5 !important;
}
html[data-theme="light"] header label {
  color: #344054 !important;
}
html[data-theme="light"] nav,
html[data-theme="light"] nav.tabs {
  background: #ffffff !important;
  border-bottom: 1px solid var(--border) !important;
}

/* Inputs, Selects, Buttons */
input, select, textarea {
  border-radius: var(--r-ctrl) !important;
}
.btn, .btn-pill, .btn-sm, .btn-icon, .pg-btn {
  border-radius: var(--r-ctrl);
}

/* Dark Mode (Linear Dark Pro) Overrides */
html[data-theme="dark"] header {
  background: #0d0e10 !important;
  color: #f7f8f8 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}
html[data-theme="dark"] nav,
html[data-theme="dark"] nav.tabs,
html[data-theme="dark"] .subtabs,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .pager-wrap {
  background: #141517 !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
  color: #f7f8f8 !important;
}
html[data-theme="dark"] .tab-btn,
html[data-theme="dark"] .subtab-btn {
  color: #9ca3af !important;
  background: transparent !important;
}
html[data-theme="dark"] .tab-btn.active,
html[data-theme="dark"] .subtab-btn.active {
  color: #828fff !important;
  border-bottom-color: #5e6ad2 !important;
}
html[data-theme="dark"] .card-title,
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] h4,
html[data-theme="dark"] strong, html[data-theme="dark"] b {
  color: #f7f8f8;
}
html[data-theme="dark"] .card-subtitle,
html[data-theme="dark"] .card-sub,
html[data-theme="dark"] .kpi-label,
html[data-theme="dark"] .kpi-sub,
html[data-theme="dark"] small,
html[data-theme="dark"] label {
  color: #9aa0aa !important;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #1c1e21 !important;
  color: #f7f8f8 !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
}
html[data-theme="dark"] .btn,
html[data-theme="dark"] .btn-sm,
html[data-theme="dark"] .btn-pill,
html[data-theme="dark"] .btn-icon,
html[data-theme="dark"] .pg-btn {
  background: #1c1e21 !important;
  color: #e2e8f0 !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
}
html[data-theme="dark"] .btn.primary,
html[data-theme="dark"] .btn-pill.active,
html[data-theme="dark"] .btn-sm.clone,
html[data-theme="dark"] .pg-btn.active {
  background: #5e6ad2 !important;
  color: #ffffff !important;
  border-color: #5e6ad2 !important;
}
html[data-theme="dark"] .btn.success {
  background: #27a644 !important;
  color: #ffffff !important;
  border-color: #27a644 !important;
}
/* Dark Mode Tables — Linear Dark Pro (Clean neutral rows, crisp left accents, zero muddy fills) */
html[data-theme="dark"] table,
html[data-theme="dark"] .table-wrap {
  background: #141517 !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
}
html[data-theme="dark"] th,
html[data-theme="dark"] thead th.act-col {
  background: #191c22 !important;
  color: #9ca3af !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11) !important;
}
html[data-theme="dark"] tbody tr,
html[data-theme="dark"] tbody tr td,
html[data-theme="dark"] tbody tr:nth-child(odd) td {
  background: #141517 !important;
  border-bottom-color: rgba(255, 255, 255, 0.06) !important;
  color: #e5e7eb;
}
html[data-theme="dark"] tbody tr:nth-child(even) td {
  background: #181b21 !important;
}
/* Overdue rows: subtle opaque dark-crimson + crisp 3px red left edge (no heavy maroon flood) */
html[data-theme="dark"] tbody tr[style*="#fef2f2"],
html[data-theme="dark"] tbody tr[style*="#fef2f2"] td {
  background: #1d1417 !important;
  color: #f3f4f6;
}
html[data-theme="dark"] tbody tr[style*="#fef2f2"] td:first-child {
  box-shadow: inset 3px 0 0 #ef4444 !important;
}
html[data-theme="dark"] tbody tr[style*="#fef2f2"] td.act-col {
  background: #1d1417 !important;
}
/* Due-soon rows: keep clean neutral dark background + crisp 3px amber left edge (no muddy brown) */
html[data-theme="dark"] tbody tr[style*="#fffbeb"],
html[data-theme="dark"] tbody tr[style*="#fffbeb"] td {
  background: #141517 !important;
  color: #e5e7eb;
}
html[data-theme="dark"] tbody tr[style*="#fffbeb"]:nth-child(even) td {
  background: #181b21 !important;
}
html[data-theme="dark"] tbody tr[style*="#fffbeb"] td:first-child {
  box-shadow: inset 3px 0 0 #f59e0b !important;
}
html[data-theme="dark"] tbody tr[style*="#fffbeb"] td.act-col {
  background: #141517 !important;
}
html[data-theme="dark"] tbody tr[style*="#fffbeb"]:nth-child(even) td.act-col {
  background: #181b21 !important;
}
/* Internal / muted rows */
html[data-theme="dark"] tbody tr[style*="#f8fafc"],
html[data-theme="dark"] tbody tr[style*="#f8fafc"] td {
  background: #13151a !important;
  color: #9ca3af !important;
}
/* Group header / active month rows */
html[data-theme="dark"] tbody td[style*="#eff6ff"],
html[data-theme="dark"] tbody tr[style*="#eff6ff"] td {
  background: #1a2236 !important;
  color: #bfdbfe !important;
  border-top-color: #334a7d !important;
}
/* Hover states — always opaque so sticky columns never bleed through */
html[data-theme="dark"] tbody tr:hover td {
  background: #1f2433 !important;
}
html[data-theme="dark"] tbody tr[style*="#fef2f2"]:hover td,
html[data-theme="dark"] tbody tr[style*="#fef2f2"]:hover td.act-col {
  background: #27191e !important;
}
html[data-theme="dark"] td.act-col,
html[data-theme="dark"] th.act-col {
  background: #141517 !important;
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}
html[data-theme="dark"] tbody tr:nth-child(even) td.act-col {
  background: #181b21 !important;
}
html[data-theme="dark"] tbody tr:hover td.act-col {
  background: #1f2433 !important;
}
html[data-theme="dark"] tr.total-pin td {
  background: #1c2338 !important;
  color: #f8fafc !important;
  border-bottom: 2px solid #5e6ad2 !important;
}
html[data-theme="dark"] tr.total-pin.warn-pin td {
  background: #261e12 !important;
  color: #fde68a !important;
  border-bottom: 2px solid #d97706 !important;
}

/* Dark Mode Section Headers, Filter Bars, Modals, Hints & Inline Light Surfaces */
html[data-theme="dark"] .hint,
html[data-theme="dark"] .schema-box,
html[data-theme="dark"] .mode-switch {
  background: #191c22 !important;
  border-color: rgba(255, 255, 255, 0.11) !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .schema-box code {
  background: #262a34 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] div[style*="#fafbfc"],
html[data-theme="dark"] div[style*="#ffffff"],
html[data-theme="dark"] div[style*="#fff;"],
html[data-theme="dark"] div[style*="#fff "],
html[data-theme="dark"] div[style*="background:#fff"],
html[data-theme="dark"] div[style*="background: #fff"],
html[data-theme="dark"] div[style*="#f8fafc"],
html[data-theme="dark"] div[style*="#f1f5f9"],
html[data-theme="dark"] div[style*="#e2e8f0"],
html[data-theme="dark"] div[style*="#eff6ff"],
html[data-theme="dark"] div[style*="#ecfdf5"],
html[data-theme="dark"] div[style*="#f0fdf4"],
html[data-theme="dark"] div[style*="#fffbeb"],
html[data-theme="dark"] div[style*="#fef3c7"],
html[data-theme="dark"] div[style*="#fef2f2"] {
  background: #191c22 !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  color: #f3f4f6 !important;
}
/* Ensure modal containers remain deep charcoal while modal header bars are slightly elevated */
html[data-theme="dark"] [id$="Modal"] > div,
html[data-theme="dark"] .login-box,
html[data-theme="dark"] .toggle-box {
  background: #141517 !important;
  color: #f7f8f8 !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}
html[data-theme="dark"] [id$="Modal"] > div > div[style*="#fafbfc"],
html[data-theme="dark"] [id$="Modal"] > div > div[style*="#f8fafc"] {
  background: #191c22 !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  color: #f7f8f8 !important;
}
/* Money suggestion & floating popups (z-index: 99999, excluding auth gate overlay) */
html[data-theme="dark"] div[style*="99999"]:not(#vintecAuthGate) {
  background: #181b21 !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55) !important;
  color: #f3f4f6 !important;
}
html[data-theme="dark"] div[style*="99999"]:not(#vintecAuthGate) > div {
  background: #181b21 !important;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
  color: #f3f4f6 !important;
}
html[data-theme="dark"] div[style*="99999"]:not(#vintecAuthGate) > div:hover {
  background: #252b3d !important;
}
html[data-theme="dark"] div[style*="99999"]:not(#vintecAuthGate) strong {
  color: #f8fafc !important;
}
/* Inline semantic text colors -> readable bright tones in Dark Mode */
html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color: #0f172a"],
html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #334155"] {
  color: #f3f4f6 !important;
}
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"] {
  color: #9ca3af !important;
}
html[data-theme="dark"] [style*="color:#1e3a8a"],
html[data-theme="dark"] [style*="color: #1e3a8a"],
html[data-theme="dark"] [style*="color:#1d4ed8"],
html[data-theme="dark"] [style*="color: #1d4ed8"] {
  color: #93c5fd !important;
}
html[data-theme="dark"] [style*="color:#92400e"],
html[data-theme="dark"] [style*="color: #92400e"],
html[data-theme="dark"] [style*="color:#b45309"],
html[data-theme="dark"] [style*="color: #b45309"] {
  color: #fbbf24 !important;
}
html[data-theme="dark"] [style*="color:#991b1b"],
html[data-theme="dark"] [style*="color: #991b1b"],
html[data-theme="dark"] [style*="color:#dc2626"],
html[data-theme="dark"] [style*="color: #dc2626"] {
  color: #f87171 !important;
}
html[data-theme="dark"] [style*="color:#059669"],
html[data-theme="dark"] [style*="color: #059669"],
html[data-theme="dark"] [style*="color:#15803d"],
html[data-theme="dark"] [style*="color: #15803d"],
html[data-theme="dark"] [style*="color:#16a34a"],
html[data-theme="dark"] [style*="color: #16a34a"] {
  color: #4ade80 !important;
}
/* Inline styled badges & buttons in Dark Mode */
html[data-theme="dark"] .badge {
  background: rgba(94, 106, 210, 0.22);
  color: #c7d2fe;
}
html[data-theme="dark"] .badge[style*="#fef2f2"],
html[data-theme="dark"] .b-red {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] .badge[style*="#fffbeb"],
html[data-theme="dark"] .badge[style*="#fef3c7"],
html[data-theme="dark"] .b-yellow,
html[data-theme="dark"] .b-orange {
  background: rgba(245, 158, 11, 0.20) !important;
  color: #fde047 !important;
}
html[data-theme="dark"] .badge[style*="#ecfdf5"],
html[data-theme="dark"] .badge[style*="#dcfce7"],
html[data-theme="dark"] .b-green {
  background: rgba(39, 166, 68, 0.22) !important;
  color: #86efac !important;
}
html[data-theme="dark"] .badge[style*="#eff6ff"],
html[data-theme="dark"] .badge[style*="#dbeafe"],
html[data-theme="dark"] .b-blue {
  background: rgba(94, 106, 210, 0.25) !important;
  color: #a5b4fc !important;
}
html[data-theme="dark"] .b-gray {
  background: rgba(255, 255, 255, 0.10) !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .btn-sm.danger,
html[data-theme="dark"] .btn-icon.danger,
html[data-theme="dark"] .btn.danger,
html[data-theme="dark"] button[style*="#fef2f2"] {
  background: rgba(239, 68, 68, 0.16) !important;
  border-color: rgba(239, 68, 68, 0.35) !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] button[style*="#fffbeb"] {
  background: rgba(245, 158, 11, 0.16) !important;
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #fcd34d !important;
}
html[data-theme="dark"] button[style*="#eff6ff"] {
  background: rgba(94, 106, 210, 0.20) !important;
  border-color: rgba(94, 106, 210, 0.40) !important;
  color: #a5b4fc !important;
}
html[data-theme="dark"] button[style*="#ecfdf5"] {
  background: rgba(39, 166, 68, 0.20) !important;
  border-color: rgba(39, 166, 68, 0.42) !important;
  color: #86efac !important;
}
html[data-theme="dark"] .bar-track { background: #262930 !important; }
html[data-theme="dark"] #cfBankDetailWrap,
html[data-theme="dark"] #cfBlockedDetailWrap,
html[data-theme="dark"] #ktCfBankWrap,
html[data-theme="dark"] #ktCfBlkWrap,
html[data-theme="dark"] #portalAuthBar,
html[data-theme="dark"] #btExtraFields,
html[data-theme="dark"] #qtExtraFields,
html[data-theme="dark"] #qtSummaryBox,
html[data-theme="dark"] #editLockWarning {
  background: #191c22 !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #e5e7eb !important;
}
html[data-theme="dark"] #btExtraFields {
  background: #13201b !important;
  border-color: rgba(52, 211, 153, 0.28) !important;
}
html[data-theme="dark"] #qtExtraFields {
  background: #151c2c !important;
  border-color: rgba(94, 106, 210, 0.35) !important;
}
html[data-theme="dark"] #editLockWarning {
  background: #231518 !important;
  border-color: rgba(239, 68, 68, 0.35) !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] [style*="color:#065f46"],
html[data-theme="dark"] [style*="color: #065f46"],
html[data-theme="dark"] [style*="color:#047857"],
html[data-theme="dark"] [style*="color: #047857"] {
  color: #6ee7b7 !important;
}
html[data-theme="dark"] input[type="file"]::file-selector-button {
  background: #262932;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 4px 10px;
  margin-right: 8px;
  cursor: pointer;
}
html[data-theme="dark"] input[type="file"]::file-selector-button:hover {
  background: #323643;
}

/* Theme Toggle Button */
.vg-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.vg-theme-btn:hover { transform: scale(1.06); }

/* Print always pure white background & black text */
@media print {
  html, body, #printArea {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
