body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f4f6f9;
  display: flex;
}

/* Ensure the page cannot become arbitrarily long due to layout bugs or absolute-positioned elements
   Make root fill the viewport and keep main as a scrolling region rather than growing indefinitely. */
html, body { height: 100%; min-height: 100%; }
body { min-height: 100vh; flex-direction: row; }

/* Make sizing predictable: include padding/border in width calculations */
*, *::before, *::after { box-sizing: border-box; }

/* CSS variables for easy theming */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #222;
  --muted: #666;
  --accent: #007bff;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --status-bg: #ffecb5;
  --border: #ddd;
  --hr: #eee;
  --inset-highlight: rgba(255,255,255,0.6);
  --sidebar-bg: #1e2a38;
  --sidebar-width: 220px; /* single source of truth for sidebar sizing */
}

body.dark {
  --bg: #0f1720;
  --panel: #0b1220;
  --text: #e6eef8;
  --muted: #9fb3cf;
  --accent: #4aa3ff;
  --danger: #d85757;
  --success: #2fa24a;
  --warning: #b88600;
  --status-bg: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.06);
  --hr: rgba(255,255,255,0.04);
  --inset-highlight: rgba(255,255,255,0.06);
  --sidebar-bg: #08121a;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: white;
  height: 100vh; /* fill full viewport so left column doesn't show a bottom gap */
  padding-top: 20px;
  padding-bottom: 6px; /* small bottom inset so the support button can sit visually near the bottom */
  position: fixed;
  left: 0;
  top: 0;
  display:flex;
  flex-direction:column;
  z-index: 10010; /* ensure sidebar sits above floating toasts/status bars */
  pointer-events: auto; /* ensure it receives clicks */
}

/* Modernized sidebar look (tighter spacing & contrast fixes) */
.sidebar {
  background: linear-gradient(180deg, #08121a 0%, #0d1722 60%);
  border-right: 1px solid rgba(255,255,255,0.03);
  padding-top: 12px; /* more compact */
}

.sidebar .logo {
  text-align: center;
  margin-bottom: 12px;
  padding-top: 8px; /* nudge down */
  display:flex;
  align-items:center;
  justify-content:center;
}

.sidebar .logo img {
  width: 96px; /* larger for visibility */
  height: auto;
  margin-top: 6px;
}

/* compact AI badge aligned top-right of the logo area */
.dark-toggle-wrap { display:flex; align-items:center; gap:6px; padding: 0 8px 6px 10px }
.ai-button { background: linear-gradient(90deg,#22c55e,#06b6d4); box-shadow: 0 3px 8px rgba(3,10,18,0.35); border-radius: 999px; width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center; font-weight:700 }

/* Sidebar nav modern styles */
.sidebar-nav { margin-top: 6px; padding: 4px 6px 4px 6px; }
.sidebar-nav ul { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; }
.sidebar-nav { overflow-y: visible; max-height: none; }
.sidebar-nav .nav-link { width:100%; display:flex; align-items:center; gap:6px; background:transparent; border:none; color:#ffffff; text-align:left; padding:0 10px; border-radius:0; cursor:pointer; transition: background 120ms ease }
.sidebar-nav .nav-item { display:block; }
.sidebar-nav .nav-item .nav-link { display:block; width:100%; text-align:left; }
.sidebar-nav .nav-link .nav-label { font-size:12px; font-weight:700; color: #ffffff; text-shadow: 0 1px 0 rgba(0,0,0,0.45); }

/* Strong override: remove any inner rounded box the label might have (background, border, inset shadow) */
.sidebar-nav .nav-link .nav-label,
.sidebar-nav .nav-link .nav-label * {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

/* Ensure link itself doesn't create an inner rounded box */
.sidebar-nav .nav-link {
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.sidebar-nav .nav-link:hover { background: transparent; color: #ffffff; }
.sidebar-nav ul li { padding: 0; margin: 0; }

/* Override global button margins within sidebar so items don't get extra vertical gaps */
.sidebar button { margin: 0; }

/* Make sure support/link buttons are compact */
.sidebar .support-link, .sidebar .ai-button { padding: 6px 10px; }
.sidebar-nav .nav-link:focus { outline: none; box-shadow: none; }

/* Show a subtle focus ring only when focused via keyboard (accessibility) */
.sidebar-nav .nav-link:focus-visible {
  outline: 2px solid rgba(74,163,255,0.18);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Also suppress any active/mouse-down box styling so clicking doesn't create the small box */
.sidebar-nav .nav-link:active {
  outline: none;
  box-shadow: none;
}
.sidebar-nav .nav-link.active, .sidebar-nav .nav-link[aria-current="page"] { background: transparent; color: #ffffff; border-left: 4px solid var(--accent); padding-left: 10px }

/* Support pill at bottom */
.sidebar-footer { margin-top: auto; padding: 10px 8px; display:flex; justify-content:center; position: static }
.support-link { width: 100%; max-width: 160px; padding: 8px 12px; border-radius: 999px; background: linear-gradient(90deg,#007bff,#2f98ff); color: #fff; font-weight:700; box-shadow: 0 4px 12px rgba(7,14,30,0.22) }
.support-link:hover { filter: brightness(1.02); transform: none }

/* AI compact button style in sidebar */
.ai-button {
  background: transparent;
  border: none;
  color: #fff;
  font-weight: 700;
  width: 38px;
  height: 38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: 999px;
  cursor: pointer;
}
.ai-button:focus { outline: 2px solid rgba(255,255,255,0.08); }

.sidebar ul {
  list-style: none;
  padding: 0;
}

.sidebar-footer { margin-top: auto; padding: 10px 12px 10px; }
.support-link { width: 100%; padding: 12px; border-radius: 8px; border: none; background: transparent; color: #fff; cursor: pointer; font-weight:600; display:flex; align-items:center; justify-content:center }
.support-link:hover { background: #32485d }

.sidebar ul li {
  padding: 15px;
  cursor: pointer;
}

.sidebar ul li:hover {
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

/* Apply the same subtle rounded hover to the nav-link so the clickable area matches the li visual */
.sidebar-nav .nav-item:hover .nav-link {
  background: transparent; /* keep inner link transparent to avoid inner box */
  border-radius: 6px;
}

.main {
  margin-left: var(--sidebar-width);
  padding: 20px;
  flex: 1;
  background: var(--bg);
  color: var(--text);
  /* ensure main doesn't create an invisible layer above the sidebar */
  position: relative;
  /* Prevent accidental extremely tall content from stretching the layout; let main scroll naturally */
  min-height: 100vh;
  box-sizing: border-box;
}

/* Responsive: collapse sidebar into top bar on small screens */
@media (max-width: 800px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); width: 260px; z-index: 20000; transition: transform 240ms ease; }
  .sidebar.open { transform: translateX(0) }
  .logo img { width: 90px }
  .sidebar ul { display: block }
  .main { margin-left: 0; padding: 12px }
  .dashboard-split { flex-direction: column }
  .dashboard-split .left-box, .dashboard-split .right-box { width: 100% }
  .card { padding: 14px }
  .profile-header { flex-direction: column; align-items: flex-start }
  .profile-actions { margin-left: 0; margin-top: 8px }

  /* Mobile header and backdrop */
  .mobile-header { position: fixed; left: 0; right: 0; top: 0; height: 56px; display:flex; align-items:center; gap:12px; padding: 8px 12px; background: var(--panel); z-index: 19999; justify-content: center }
  .mobile-header { position: fixed; left: 0; right: 0; top: 0; height: 56px; display:flex; align-items:center; gap:12px; padding: 8px 12px 8px 8px; background: var(--panel); z-index: 19999; justify-content: flex-start }
  .mobile-header #mobileMenuBtn { font-size:20px; background:transparent; border:none; cursor:pointer; margin-left: 0; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--nav-icon-color, #0b3b70); width:36px; height:36px; display:inline-flex; align-items:center; justify-content:center; border-radius:8px; padding:0; }

  /* Ensure the icon visually centers: give header equal vertical padding and a fixed height so top/bottom spacing is equal */
  .mobile-header, .mobile-header .logo { height:56px; line-height:56px; }
  .mobile-header #mobileMenuBtn { z-index: 20001; }
  .mobile-header .mobile-brand { font-weight:600; margin-left:0 }
  .mobile-header .logo { display:flex; align-items:center; margin-left:12px }
  .mobile-header .logo img { vertical-align: middle; }
  .main { padding-top: 72px }
  .mobile-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 19998 }
  .mobile-backdrop[hidden] { display:none }
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: var(--panel);
  border-top: 1px solid var(--hr);
  z-index: 20005;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 8px;
}

/* ensure nav icon color in light mode (nav-specific) */
body:not(.dark) .mobile-header #mobileMenuBtn { color: #0b3b70; }
/* when dark mode is active, make the menu icon white for contrast */
body.dark .mobile-header #mobileMenuBtn { color: #ffffff; }
.mobile-bottom-nav .mbtn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 6px 2px 6px;
  width: 56px;
  height: 56px;
  border-radius: 10px;
}
.mobile-bottom-nav .mbtn span { font-size: 11px; color: var(--muted); display:block }
.mobile-bottom-nav .mbtn:active, .mobile-bottom-nav .mbtn[aria-current="true"] { background: rgba(0,0,0,0.04); }

/* Make sure icons are visible in light mode (increase contrast) */
.mobile-bottom-nav .mbtn { color: var(--text); }
.mobile-bottom-nav .mbtn svg, .mobile-bottom-nav .mbtn img { filter: none; }

/* Slight lift for icon to move it a bit up visually */
.mobile-bottom-nav .mbtn span { margin-top: 2px }

@media (max-width: 800px) {
  .mobile-bottom-nav { display: flex; }
  /* leave space for fixed bottom nav so main content isn't covered */
  .main { padding-bottom: 86px; }
  /* ensure large touch targets on small screens */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
}

/* Mobile sidebar close button */
.mobile-sidebar-close {
  position: absolute;
  right: 8px;
  top: 8px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 30002;
}
@media (max-width: 800px) {
  .mobile-sidebar-close { display: inline-flex; align-items:center; justify-content:center; }
  .sidebar { padding-top: 46px; }
  .mobile-sidebar-close { color: #fff; background: rgba(0,0,0,0.12); }
}
@media (min-width: 801px) {
  .mobile-sidebar-close { display: none !important; }
}

/* Ensure the mobile header doesn't overlap content when visible */
@media (max-width: 800px) {
  .main { padding-top: 72px; }
}

/* Hide mobile header/backdrop only on wider screens; allow media query to show them on small screens */
@media (min-width: 801px) {
  .mobile-header { display: none }
  .mobile-backdrop { display: none }
}

.sidebar-section {
  padding: 0 16px 16px 16px;
}

.customers-sidebar h4 {
  margin: 8px 0;
  font-size: 14px;
  color: #cfe4ff;
}

.customers-sidebar input, .customers-sidebar button {
  width: calc(100% - 0);
  margin: 6px 0;
  padding: 8px;
  font-size: 13px;
}

.customers-sidebar button {
  background: var(--success);
  border-radius: 8px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.dark .card { /* keep original panel colors; ensure modern geometry for dark mode */
  border-radius: 12px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.06);
}

/* hr inside cards (subtle separators). In dark mode make even more subtle */
.card hr { border: none; height: 1px; background: rgba(0,0,0,0.06); margin: 12px 0 }
.dark .card hr { opacity: 0.9 }

.card.two-column {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.card.two-column .small-table,
.card.two-column .recent-customers {
  flex: 1;
}

.small-table table {
  width: 100%;
  font-size: 14px;
}

.dashboard-split {
  display: flex;
  gap: 20px;
}

.dashboard-split .left-box,
.dashboard-split .right-box {
  flex: 1;
  background: var(--panel);
  padding: 16px;
  border-radius: 10px;
  min-width: 0; /* allow flex children to shrink and prevent overflow pushing layout */
}
.dark .dashboard-split .left-box, .dark .dashboard-split .right-box {
  /* preserve original background color from variables; keep rounded corners */
  border-radius: 10px;
}

.right-box .recent-customers ul { margin: 0; padding: 0; list-style:none }
.budget-summary { margin-top: 12px; padding-top: 8px; border-top: 1px solid #eee }

/* Müşteriler page tweaks */
#customerTable th, #customerTable td { padding:8px }

/* Customer profile styles */
#customerProfile textarea {
  width: 100%;
  min-height: 80px;
  margin: 8px 0;
}

#profileNotesList { list-style:none; padding:0; }
#profileNotesList li { padding:8px; border-bottom:1px solid var(--hr) }

#profileNotesList small { display:block; color:#666; margin-top:4px }

#profileEditBtn, #profileDeleteBtn {
  background: var(--accent); color:#fff; border:none; padding:6px 10px; border-radius:6px; cursor:pointer;
}
#profileDeleteBtn { background: var(--danger) }

/* modern back button and profile actions */
.profile-header { display:flex; align-items:center; gap:12px; margin-bottom:12px }
.btn-back { display:inline-flex; align-items:center; gap:8px; background:transparent; border:1px solid #ddd; padding:6px 10px; border-radius:8px; cursor:pointer }
.btn-back svg { color:#333 }
.profile-actions { margin-left:auto; display:flex; gap:8px }
.profile-actions .btn { width: auto; }
.btn { padding:6px 10px; border-radius:8px; border:none; cursor:pointer }
.btn-primary { background: var(--accent); color:#fff }
.btn-danger { background: var(--danger); color:#fff }

.tool-button { width: 100%; padding: 8px; border-radius: 8px; border: none; background: var(--warning); color: #111; cursor: pointer; }
.tool-button:hover { filter: brightness(0.95) }

.support-card .support-link-text { font-weight: 600; text-decoration: none; color: inherit }
.support-card .muted { color: var(--muted); margin-bottom: 8px }

/* invoice form tweaks */
.invoice-form .row { display:flex; gap:12px; align-items:center; margin-bottom:10px }
.invoice-form .row input, .invoice-form .row select { flex:1 }
.invoice-items { margin-top:8px; padding:10px; border-radius:8px; background: rgba(0,0,0,0.02) }
invoice-items table { width:100%; border-collapse: collapse }
.invoice-items table th, .invoice-items table td { padding:8px; border-bottom:1px solid var(--hr) }
.totals { display:flex; gap:20px; align-items:center; justify-content:flex-end }

.note-controls { display:flex; gap:8px; margin:8px 0 12px 0; flex-wrap:wrap }
.note-controls button { flex: 0 0 auto; padding: 8px 12px; width: auto }
.note-text { margin-bottom:4px }

/* Dark toggle styles */
.dark-toggle-wrap { display:flex; justify-content:space-between; align-items:center; padding: 8px 8px }
.dark-toggle { width:38px; height:38px; border-radius: 999px; border: none; background: rgba(0,0,0,0.04); display:inline-flex; align-items:center; justify-content:center; cursor:pointer; transition: background 180ms ease, transform 120ms ease }
.dark-toggle svg { color: var(--panel); transform: translateX(0); transition: transform 220ms ease }
.dark-toggle:hover { transform: scale(1.03) }
.dark .dark-toggle { transform: scale(1.01); }
.dark .dark-toggle svg { transform: translateX(-2px) rotate(-6deg); color: inherit }
/* nudge dark-toggle slightly away from left edge and AI a bit inward so they're not flush to the sidebar edge */
.dark-toggle-wrap { padding-left: 14px; padding-right: 14px }
.dark-toggle { margin-left: 6px }
.ai-button { margin-right: 6px }

/* modern form inputs and textarea */
/* Form controls: use theme variables so dark-mode colors apply consistently */
input[type="text"], input[type="email"], input[type="number"], select, textarea, input[type="date"] {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 var(--inset-highlight);
  transition: box-shadow 120ms ease, border-color 120ms ease;
  box-sizing: border-box; /* ensure padding doesn't increase visual width */
  max-width: 100%;
}

/* Invoice top-row controls (four boxes) - keep consistent sizing and borders */
.invoice-form .row > input[type="text"],
.invoice-form .row > input[type="date"],
.invoice-form .row > select,
.invoice-form .row > input[type="number"] {
  height: 44px;
  line-height: 20px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Ensure the invoice customer select spans full height and caret is visible */
.invoice-form select#invoiceCustomer { height:44px }
.invoice-form select#invoiceCustomer option { background: var(--panel); color: var(--text) }

/* Calendar icon visibility for date inputs: use appearance none + background svg tint based on color */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(0.85);
}

/* Role assign selects and company info - same visual treatment */
#assignEmployeeSelect, #assignRoleSelect, #companyName, #companyTaxNo {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
}

/* Fix for invoice items area to visually match the form controls */
.invoice-items { background: var(--panel); border: 1px solid var(--border); }

/* Special case: make sure placeholders are lighter but visible in dark mode */
input::placeholder, textarea::placeholder { color: rgba(0,0,0,0.35) }
.dark input::placeholder, .dark textarea::placeholder { color: rgba(255,255,255,0.28) }

input[type="text"]:focus, input[type="email"]:focus, input[type="number"]:focus, select:focus, textarea:focus, input[type="date"]:focus {
  outline: none;
  border-color: rgba(0,123,255,0.6);
  box-shadow: 0 6px 18px rgba(0,123,255,0.08);
}

textarea { min-height: 90px; resize: vertical }

/* Removed explicit dark-mode color overrides to preserve original color palette.
  Inputs and tables will inherit colors from variables; geometry (radius, padding)
  remains modern. */

/* Invoice controls inherit global input styles; no forced dark-mode color overrides. */

/* date inputs - match dark theme */
input[type="date"] { padding: 8px 10px; border-radius:8px }
.dark input[type="date"] { border-radius:8px }

select, select option { color: var(--text); background: var(--panel); }

select, .invoice-form select, #assignEmployeeSelect, #assignRoleSelect { border: 1px solid var(--border); background: var(--panel); color: var(--text); }

/* Ensure invoice item description matches other inputs */
.invoice-items { margin-top:8px; padding:10px; border-radius:8px; background: var(--panel) }
.invoice-items input.inv-desc { background: transparent; color: var(--text); border-radius:6px; padding:6px; border: 1px solid var(--border); }

/* Make description field visually match inputs instead of white */
.invoice-items input.inv-desc { background: transparent; color: var(--text); border-radius:6px; padding:6px; border: 1px solid var(--border); }

/* Soft placeholder color so users see guidance */
::placeholder { color: rgba(0,0,0,0.35); }
.dark ::placeholder { color: rgba(255,255,255,0.35); }

/* Explicitly ensure specific small numeric/date/amount fields inherit theme */
#logDate, #amount, #invoiceDue, #invoiceTax, #companyName, #companyTaxNo { background: var(--panel); color: var(--text); border: 1px solid var(--border) }

/* FX Rates strip (top-right) - transparent and theme-aware */
.fx-rates {
  position: fixed;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: transparent; /* no background as requested */
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: none;
  z-index: 20050; /* ensure it sits above most app UI and overlays */
  font-size: 13px;
  color: var(--text);
  pointer-events: auto;
}
.fx-rates .fx-item { display:flex; gap:6px; align-items:center; padding:4px 6px; border-radius:8px; background:transparent; color:var(--text); }
.fx-rates .fx-item .fx-icon { font-size:14px; }
.fx-rates .fx-item .fx-code { font-weight:600; color:var(--muted); margin-left:2px }
.fx-rates .fx-item .fx-rate { font-weight:700; margin-left:4px }
.fx-rates .fx-item:hover { background: transparent; }

@media (max-width: 700px) {
  .fx-rates { right: 8px; top: 56px; font-size:12px; }
}

#customerProfile button[onclick^="showPage"] {
  background: transparent;
  color: #007bff;
  border: none;
  font-size: 14px;
  margin-bottom: 8px;
}

/* cust-link should look like plain text */
.cust-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.cust-link:focus { outline: 2px solid rgba(0,123,255,0.25); border-radius:4px }

/* profile flash animation when opening a customer profile */
.card.flash {
  animation: profileFlash 1.2s ease;
}

@keyframes profileFlash {
  0% { box-shadow: 0 0 0 rgba(255,193,7,0); transform: translateY(0); }
  30% { box-shadow: 0 8px 30px rgba(255,193,7,0.45); transform: translateY(-2px); }
  100% { box-shadow: 0 0 0 rgba(255,193,7,0); transform: translateY(0); }
}

.recent-customers ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.recent-customers ul li {
  padding: 10px;
  border-bottom: 1px solid var(--hr);
}

/* Offline / update status bar */
.status-bar { position: fixed; left: var(--sidebar-width); right: 16px; bottom: 16px; background: var(--status-bg); color: var(--text); padding: 10px 12px; border-radius: 8px; display:flex; gap:12px; align-items:center; box-shadow:0 6px 18px rgba(0,0,0,0.08); z-index:9998 }
.status-bar .status-action { margin-left:auto; background: var(--accent); color:#fff; border:none; padding:8px 12px; border-radius:6px; cursor:pointer }
.dark .status-bar { border-color: rgba(0,0,0,0.06) }

/* Make the mini table visually smaller */
#miniTable th, #miniTable td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--hr);
}

input, select, button {
  display: block;
  margin: 8px 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

/* Modern select styling: remove native chrome/ios/edge appearance and add custom caret */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(1em + 2px), calc(100% - 13px) calc(1em + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

/* Place caret on the right and align color in dark mode */
select:focus { outline: none; box-shadow: 0 6px 18px rgba(0,123,255,0.08); }
.dark select { border-radius: 8px }

/* Date input modern look (use consistent padding & border). Native datepickers may vary by browser */
input[type="date"] { appearance: none; -webkit-appearance: none; padding: 10px 12px; border-radius: 8px }

/* hide native calendar icon and use a consistent inline SVG background */
input[type="date"]::-webkit-calendar-picker-indicator { display: none; -webkit-appearance: none }
/* blue calendar icon in light mode (percent-encoded SVG for reliability) */
input[type="date"] { background: var(--panel) url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23007bff' d='M7 10h10v2H7zM7 5h2v2H7zM15 5h2v2h-2zM5 9h14v10H5z'/%3E%3C/svg%3E") no-repeat calc(100% - 14px) center/18px }
/* white calendar icon in dark mode */
.dark input[type="date"] { background: var(--panel) url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M7 10h10v2H7zM7 5h2v2H7zM15 5h2v2h-2zM5 9h14v10H5z'/%3E%3C/svg%3E") no-repeat calc(100% - 14px) center/18px }

/* Ensure custom look on mobile smaller screens */
@media (max-width:800px) {
  select { background-position: calc(100% - 28px) calc(1em + 2px), calc(100% - 22px) calc(1em + 2px); }
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th, table td {
  padding: 10px;
  border-bottom: 1px solid var(--hr);
  text-align: left;
}

/* prevent charts or other canvas elements from overflowing their containers */
canvas { max-width: 100%; height: auto; display: block; }

/* ensure balance chart has a visible height so Chart.js can compute sizes when hidden initially */
#balanceChart { width: 100% !important; min-height: 240px; height: 320px !important; max-height: 420px; display:block }

/* give a reasonable min-height for other small charts so they render when hidden */
canvas[id$="Chart"], canvas[id$="chart"] { min-height: 80px; }

.error-box {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 360px;
  background: var(--panel);
  color: var(--danger);
  border: 1px solid rgba(0,0,0,0.06);
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  font-size: 13px;
  z-index: 50; /* low z-index to avoid covering app interactable areas */
  pointer-events: none; /* don't capture clicks */
}

.error-box small { display:block; color: var(--muted); margin-top:6px; }

/* Manual unblock button that stays above overlays. z-index intentionally very high. */
.manual-unblock-btn {
  position: fixed;
  right: 12px;
  bottom: 110px; /* move a little higher to avoid taskbar overlap */
  z-index: 30001; /* above mobile/backdrop and sidebar */
  background: #ff8c00;
  color: #fff;
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
  cursor: pointer;
  font-weight: 600;
  width: auto;    /* don't inherit global button width */
  min-width: 72px;
  max-width: 160px;
  text-align: center;
}
.manual-unblock-btn:active{ transform: translateY(1px); }

.badge { display:inline-block; padding:4px 8px; border-radius:999px; font-size:12px; color:#fff; margin-right:6px }
.badge.local { background: #6c757d }
.badge.sending { background: #0d6efd }
.badge.sent { background: #198754 }
.badge.failed { background: #dc3545 }

/* Support send button spinner + animation */
.btn-with-spinner { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; }
.btn-with-spinner .spinner { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: rgba(255,255,255,0.95); animation: spin 900ms linear infinite; display: none; }
.btn-with-spinner.sending { pointer-events: none; opacity: 0.95; padding-right: 36px; }
.btn-with-spinner.sending .spinner { display: inline-block; }

@keyframes spin { from { transform: translateY(-50%) rotate(0deg); } to { transform: translateY(-50%) rotate(360deg); } }

/* Adapt spinner color in dark mode for visibility */
.dark .btn-with-spinner .spinner { border: 2px solid rgba(255,255,255,0.18); border-top-color: rgba(255,255,255,0.95); }
.btn-with-spinner .spinner { /* ensure spinner sits above button text */ z-index: 2; }

/* Support retry area styling */
#supportRetryArea { margin-top: 6px; font-size: 0.95rem; }
#supportRetryArea button { background: var(--accent); color: #fff; border: none; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
#supportRetryArea ul li button { background: var(--warning); color: #111; padding: 4px 8px; border-radius: 6px; margin-left:6px }

/* Make dashboard a positioning context so FX can be absolutely positioned inside it */
#dashboard {
  position: relative;
}

/* Slight style tweak for FX widget when inside dashboard */
.fx-rates {
  transition: transform 160ms ease, opacity 160ms ease;
}

