:root{
  /* ClientConnect AI Brand Colors */
  --accent-main: #22c55e;     /* Main green accent from logo */
  --accent-hover: #16a34a;    /* Green 600 - buttons, links */
  --accent-dark: #15803d;     /* Green 700 - hover states */
  --accent-darker: #166534;   /* Green 800 - darker green */
  --accent-darkest: #14532d;  /* Green 900 - darkest green */
  
  --green-50: #f0fdf4;        /* Very light backgrounds */
  --green-100: #dcfce7;       /* Light backgrounds */
  --green-200: #bbf7d0;       /* Subtle highlights */
  --green-300: #86efac;       /* Lighter accents */
  --green-400: #4ade80;       /* Medium green */
  
  --navy-dark: #1a1f23;       /* Darkest navy */
  --navy-medium: #212529;     /* Dark navy */
  --navy-light: #343a40;      /* Medium navy */
  
  --gray-50: #f8f9fa;         /* Lightest gray */
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-300: #ced4da;
  --gray-400: #adb5bd;
  --gray-500: #6c757d;        /* Medium gray */
  --gray-600: #495057;        /* Dark gray */
  
  /* Main theme variables */
  --bg: var(--gray-50);
  --card: #fff;
  --text: var(--navy-dark);
  --muted: var(--gray-500);
  --primary: var(--accent-main);
  --danger: #dc3545;
  --border: var(--gray-200);
  --statement-panel-bg: #ffffff;
  --statement-panel-text: #0f172a;
  --statement-panel-muted: var(--gray-600);
  --statement-panel-section-bg: #f8fafc;
  --bg-secondary: #f1f5f9;
  --shadow: rgba(15, 23, 42, 0.08);
  --hover-bg: rgba(34, 197, 94, 0.18); /* brand-green hover glow */
  --card-bg: var(--card);
  --border-color: var(--border);
  --text-color: var(--text);
  --text-muted: var(--muted);
  --accent-bg: rgba(34, 197, 94, 0.12);
  --hover-bg: rgba(34, 197, 94, 0.12);
}
html[data-theme="dark"]{ 
  --bg: var(--navy-dark); 
  --card: var(--navy-medium); 
  --text: #ffffff; 
  --muted: var(--gray-100); 
  --primary: var(--accent-main); 
  --danger: #ff6b6b; 
  --border: var(--navy-light); 
  --statement-panel-bg: #ffffff;
  --statement-panel-text: #0f172a;
  --statement-panel-muted: #475569;
  --statement-panel-section-bg: #f1f5f9;
  --bg-secondary: rgba(255,255,255,0.08);
  --shadow: rgba(0,0,0,0.55);
  --card-bg: var(--card);
  --border-color: var(--border);
  --text-color: var(--text);
  --text-muted: var(--muted);
  --accent-bg: rgba(34, 197, 94, 0.22);
  --hover-bg: rgba(34, 197, 94, 0.25);
}
*{ box-sizing: border-box; }
html, body{ height:100%; }
body{ margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial; background:var(--bg); color:var(--text); }
.appbar{ display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); background:var(--card); position:sticky; top:0; z-index:3; overflow:visible; }
.brand{ font-weight:700; display:flex; align-items:center; gap:6px; min-width:0; }
.org-name-chip{ padding:4px 8px; border-radius:8px; background:var(--accent-bg); color:var(--accent-main); font-size:12px; font-weight:600; display:inline-block; max-width:min(42vw,260px); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:middle; }
.spacer{ flex:1; }
.icon, .btn{ border:1px solid var(--border); background:var(--card); color:var(--text); padding:8px 12px; border-radius:10px; cursor:pointer; }
#aiPanelBtn{ font-weight:700; letter-spacing:.02em; }
.btn.primary{ background:var(--primary); color:white; border:none; }
.btn.danger{ background:var(--danger); color:white; border:none; }
.btn.secondary.active{ border-color:var(--primary); color:var(--primary); }
.chip{ padding:6px 10px; border:1px solid var(--border); border-radius:999px; }
.pill-outstanding{ display:inline-flex; align-items:center; gap:8px; padding:10px 14px; border-radius:14px; background:linear-gradient(135deg,#fdf5e6 0%,#e9f5ff 100%); color:#0f172a; box-shadow:0 8px 24px rgba(0,0,0,0.05); border:1px solid rgba(15,23,42,0.08); font-weight:600; }
.pill-outstanding::before{ content:'Outstanding'; text-transform:uppercase; font-size:11px; letter-spacing:0.4px; color:#16a34a; background:rgba(22,163,74,0.12); padding:4px 8px; border-radius:999px; }
.link-btn{ border:none; background:none; color:var(--primary); cursor:pointer; padding:0; font-size:inherit; }
.center{ display:grid; place-items:center; padding:40px; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg); z-index: 1000; }
.card{ background:var(--card); border:1px solid var(--border); border-radius:14px; padding:24px; width:min(560px, 90vw); box-shadow: 0 10px 24px rgba(0,0,0,.08); }
.card.table-full{ width:100%; max-width:100%; }
.card h1{ margin-top:0; }
.card-header { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px; }
.card-header h3 { margin: 0; color: var(--text); font-size: 16px; font-weight: 600; }
.card-body p { margin: 0 0 8px 0; }
.btn-group { display: flex; flex-wrap: wrap; }

/* Login Logo Styles */
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.logo-img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(34,197,94,0.25);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}

.card input,
.card select,
.card textarea{ width:100%; padding:10px; border-radius:10px; border:1px solid var(--border); background:transparent; color:var(--text); }
select{
  background:var(--card);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:10px;
  padding:8px 10px;
}
select:focus{
  outline:none;
  border-color:var(--primary);
  box-shadow:0 0 0 2px rgba(34,197,94,0.2);
}
select option{
  background:var(--card);
  color:var(--text);
}
html[data-theme="dark"] select option{
  background:var(--navy-medium);
  color:#fff;
}
label{ display:block; margin:10px 0 6px; color:var(--muted); font-size:13px; }
.muted{ color:var(--muted); }
.row{ display:flex; align-items:center; gap:10px; }
.row.end{ justify-content:flex-end; }
.gap{ gap:10px; }
.tabs{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:4px;
  padding:8px 16px;
  border-bottom:1px solid var(--border);
}
.tab{
  border:none;
  background:transparent;
  padding:8px 10px;
  min-height:40px;
  border-bottom:2px solid transparent;
  cursor:pointer;
  color:var(--muted);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:500;
  white-space:nowrap;
}
.tab.active{ color:var(--text); border-color:var(--primary); }
.tab-icon{
  width:16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 16px;
}
.tab-label{
  display:inline-block;
  line-height:1;
}
.tab-caret{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  opacity:.72;
}

/* Tab Dropdown Navigation */
.tab-dropdown { position: relative; display: inline-flex; }
.tab-dropdown .dropdown-toggle { 
  border:none; 
  background:transparent; 
  padding:10px 14px; 
  min-height:44px;
  border-bottom:2px solid transparent; 
  cursor:pointer; 
  color:var(--muted); 
  white-space: nowrap;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:500;
}
.tab-dropdown.active .dropdown-toggle { color:var(--text); border-color:var(--primary); }
.tab-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 1000;
  min-width: 180px;
  margin-top: 4px;
}
.tab-dropdown-item {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 0;
  display: block;
}
.tab-dropdown-item:hover {
  background: var(--hover-bg);
  color: var(--primary);
}
.tab-dropdown-item.active {
  background: rgba(47,111,237,.1);
  color: var(--primary);
  font-weight: 500;
}
.tab-dropdown-item:first-child { border-radius: 8px 8px 0 0; }
.tab-dropdown-item:last-child { border-radius: 0 0 8px 8px; }
.tab-dropdown-item:only-child { border-radius: 8px; }

.toolbar{ display:flex; gap:10px; padding:12px 16px; }
.toolbar input{ padding:10px; border-radius:10px; border:1px solid var(--border); background:transparent; color:var(--text); }
.payments-toolbar {
  flex-wrap: wrap;
  align-items: center;
}
.payments-toolbar .spacer {
  flex: 1 1 24px;
}
.payments-toolbar .btn {
  white-space: nowrap;
}
.tabview{ padding:6px 16px 16px; }
.list{ border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--card); }
.list .row{ padding:12px 14px; border-bottom:1px solid var(--border); }
.list .row:last-child{ border-bottom:none; }
.list .row.header{ font-weight:700; background:rgba(127,127,127,.08); }
.list .row > div{ flex:1; }
.list .row:hover{ background:var(--hover-bg); cursor:pointer; }
.list.scrollable{ overflow-y:auto; max-height:320px; }

#clientsList {
  overflow-y: auto;
  max-height: calc(100vh - 260px);
}

@media (max-width: 900px) {
  #clientsList {
    max-height: calc(100vh - 320px);
  }
}

#journalsListArea,
#accountsListArea {
  overflow-x: auto;
}

#journalsListArea .row,
#accountsListArea .row {
  min-width: 760px;
}

html[data-theme="dark"] .list .row.header,
html[data-theme="dark"] .list.table-grid .row.header,
html[data-theme="dark"] #employeesList .row.header {
  background: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .list .row:hover,
html[data-theme="dark"] .list.table-grid .row:not(.header):hover,
html[data-theme="dark"] #employeesList .row:not(.header):hover {
  background: var(--hover-bg);
}
html[data-theme="dark"] .table-card thead th {
  background: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .table-card tbody tr:hover {
  background: var(--hover-bg);
}

.report-panel,
.gl-report-card,
.aging-summary-card,
.gl-report-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.hidden{ display:none !important; }
.drawer{ position:fixed; top:0; right:0; height:100vh; width:min(720px, 95vw); background:var(--bg); border-left:1px solid var(--border); box-shadow:-10px 0 24px rgba(0,0,0,.15); z-index:10; display:flex; flex-direction:column; overflow:hidden; }
.drawer-head{ position:sticky; top:0; display:flex; align-items:center; justify-content:space-between; background:var(--card); border-bottom:1px solid var(--border); padding:12px 16px; z-index:11; }
.drawer-body{ padding:16px; overflow-y:auto; flex:1; }
.client-drawer-actions{
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-top: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.client-drawer-actions .btn{
  flex: 1 1 140px;
}
.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.grid2 input, .grid2 select, textarea{ width:100%; padding:10px; border-radius:10px; border:1px solid var(--border); background:var(--card); color:var(--text); }
textarea{ width:100%; }
.toasts{ position:fixed; bottom:16px; right:16px; display:flex; flex-direction:column; gap:8px; z-index:300; }
.toast{ background:var(--card); border:1px solid var(--border); padding:10px 12px; border-radius:10px; box-shadow:0 10px 20px rgba(0,0,0,.12); }
.processing-status-overlay{ position:fixed; inset:0; background:rgba(15,23,42,.42); display:flex; align-items:center; justify-content:center; z-index:13000; padding:16px; }
.processing-status-overlay.hidden{ display:none; }
.processing-status-modal{ width:min(360px,100%); background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:14px; padding:22px 20px; box-shadow:0 24px 60px rgba(15,23,42,.28); text-align:center; }
.processing-status-spinner{ width:42px; height:42px; margin:0 auto 14px; border-radius:50%; border:4px solid rgba(34,197,94,.18); border-top-color:var(--primary); animation:processing-spin 1s linear infinite; }
.processing-status-title{ font-size:18px; font-weight:700; margin-bottom:8px; }
.processing-status-message{ color:var(--muted); line-height:1.45; }
@keyframes processing-spin{ from{ transform:rotate(0deg);} to{ transform:rotate(360deg);} }
.filters{display:flex;gap:1rem;margin:.75rem 0;align-items:center;}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:.75rem;}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:.75rem;}
.row.task{display:grid;grid-template-columns: 160px 1fr 1fr 120px 140px;gap:.5rem;align-items:center;padding:.4rem 0;border-bottom:1px solid var(--border);}
.badge.pending{background:#fff3cd;color:#9c6f00;border:1px solid #ffe6a7;padding:.1rem .35rem;border-radius:8px;}
.badge.filed{background:#d1fae5;color:#065f46;border:1px solid #9ae6b4;padding:.1rem .35rem;border-radius:8px;}

/* Settings modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Must sit above drawers, notifications, and statement preview overlay */
  z-index: 5000;
}
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
}
.modal-content {
  position: relative;
  background: var(--card);
  color: var(--text);
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,.15);
  width: min(720px, 95vw);
  max-height: 85vh;
  overflow: auto;
  z-index: 5001;
}
.modal-content h2 { margin-top: 0; margin-bottom: 0.5rem; }
.modal-content input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-secondary, rgba(255,255,255,0.08));
  color: var(--text);
}

.modal-content textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-secondary, rgba(255,255,255,0.08));
  color: var(--text);
  min-height: 80px;
  resize: vertical;
}

.modal-content input:focus,
.modal-content textarea:focus {
  outline: none;
  border-color: var(--primary, #22c55e);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.grid2 .wide { grid-column: 1 / -1; }

.modal-content.medium { width: min(560px, 95vw); }
.modal-content.wide { width: min(960px, 95vw); }
#admin2faModal {
  z-index: 20000;
}

#admin2faModal .modal-backdrop {
  z-index: 0;
}

#admin2faModal .modal-content {
  z-index: 1;
  pointer-events: auto;
}

#admin2faOtp {
  pointer-events: auto;
  user-select: text;
}

#admin2faEnableBtn,
#admin2faVerifyBtn,
#admin2faContinueBtn,
#admin2faCancelBtn,
#admin2faDisableBtn {
  pointer-events: auto;
}

.bank-status-error { color: var(--danger); }
.bank-status-success { color: var(--accent-dark); }
.bank-status-info { color: var(--muted); }
.email-settings-page {
  width: min(1180px, 96vw);
  max-height: 88vh;
}
.email-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.email-settings-header p {
  margin: 6px 0 0;
  max-width: 720px;
}
.email-settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.25fr);
  gap: 16px;
  align-items: start;
}
.email-section-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}
.email-section-card--connector,
.email-section-card--templates {
  grid-column: 2;
}
.email-section-title-row h3 {
  margin: 0;
}
.email-section-title-row p {
  margin: 6px 0 14px;
}
.email-provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.email-provider-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.email-provider-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.12);
  transform: translateY(-1px);
}
.email-provider-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.16);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), rgba(34, 197, 94, 0.02));
}
.email-provider-card.is-disabled,
.email-provider-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.email-provider-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--primary);
  flex: 0 0 auto;
}
.email-provider-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.email-provider-copy small {
  color: var(--muted);
  line-height: 1.45;
}
.mail-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}
.mail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.mail-topbar h2 {
  margin: 0;
}
.mail-topbar p {
  margin: 6px 0 0;
}
.mail-compose-modal textarea {
  resize: vertical;
}
.mail-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 250px);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  padding: 0;
}
.mail-sidebar,
.mail-list-pane {
  min-width: 0;
}
.mail-sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), rgba(34, 197, 94, 0.01));
}
.mail-sidebar-section + .mail-sidebar-section {
  margin-top: 18px;
}
.mail-sidebar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}
.mail-folder-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 6px;
}
.mail-folder-item:hover {
  background: rgba(34, 197, 94, 0.08);
}
.mail-folder-item.active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
}
.mail-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.mail-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.mail-search-input {
  min-width: 240px;
}
.mail-sort-select {
  min-width: 160px;
}
.mail-message-list {
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mail-list-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  min-height: 0;
}
.mail-list-item:hover {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.mail-list-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.14);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), rgba(34, 197, 94, 0.02));
}
.mail-list-item.is-unread {
  border-color: rgba(34, 197, 94, 0.28);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.11), rgba(34, 197, 94, 0.03));
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}
.mail-list-item.is-unread strong {
  font-weight: 800;
}
.mail-list-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.mail-list-preview {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mail-list-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.onboarding-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--primary, #16a34a);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.onboarding-activation-modal,
.onboarding-first-value-modal {
  width: min(760px, 95vw);
}
.onboarding-plan-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-secondary, rgba(255,255,255,0.08));
}
.onboarding-plan-summary strong {
  font-size: 14px;
}
.onboarding-grid .input {
  min-height: 44px;
}
.onboarding-inline-checkbox {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary, rgba(255,255,255,0.04));
}
.onboarding-inline-checkbox input[type="checkbox"] {
  width: auto;
}
.onboarding-actions .btn {
  min-height: 46px;
}
.first-value-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.first-value-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-align: left;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.first-value-option strong {
  font-size: 16px;
}
.first-value-option span {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.first-value-option:hover,
.first-value-option:focus-visible {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.14);
}
.first-value-option.is-selected {
  border-color: var(--primary, #16a34a);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
  transform: translateY(-1px);
}
.expense-wide {
  width: 95vw;
  max-width: 1200px;
  height: 90vh;
  max-height: 90vh;
}
#expenseModal .modal-content {
  width: 95vw;
  max-width: 1200px;
  height: 90vh;
  max-height: 90vh;
}
.credit-modal {
  max-height: 90vh;
  overflow-y: auto;
}

/* Item sales table responsiveness */
.item-sales-table {
  width: 100%;
  overflow-x: auto;
}
.item-sales-table table {
  min-width: 900px;
}

/* Hide Item Sales on dashboard */
.item-sales-section {
  display: none !important;
  visibility: hidden !important;
}

.row.right { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.list.table-grid .row { cursor: default; }
.list.table-grid .row.header { background: rgba(127,127,127,.08); font-weight: 600; }
.table-grid .actions { display:flex; gap:6px; justify-content:flex-end; }
.table-card,
.list.table-grid,
#paymentsListArea,
#creditNotesListContainer,
#expensesTableContainer {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
  overflow: hidden;
}
.table-card table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}
.table-card thead th {
  background: rgba(0,0,0,0.04);
  color: var(--text);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table-card td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.table-card tbody tr:last-child td { border-bottom: none; }
.table-card tbody tr:hover { background: var(--hover-bg); }
.table-card .badge { border-radius: 999px; font-weight: 600; }

#vatTab .table-card {
  overflow-x: auto;
}
#vatTab .vat-table {
  width: 100%;
  min-width: 760px;
}
#vatTab .vat-table th,
#vatTab .vat-table td {
  white-space: nowrap;
}
#vatTab .vat-table td:nth-child(2) {
  white-space: normal;
}
#vatTab .vat-table .actions-cell {
  display: flex;
  gap: 6px;
}
#vatTab .vat-table .actions-cell .btn {
  min-width: 70px;
}

.quote-row {
  display:grid;
  grid-template-columns: minmax(200px, 2.2fr) minmax(140px, 1.2fr) minmax(120px, 1fr) minmax(120px, 1fr) 140px;
  gap:8px;
  align-items:center;
}
.invoice-row {
  display:grid;
  grid-template-columns: 36px minmax(200px, 2.2fr) minmax(140px, 1.2fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) 140px;
  gap:8px;
  align-items:center;
}
.payment-row {
  display:grid;
  grid-template-columns: minmax(220px, 2.3fr) 120px 120px minmax(140px, 1fr) minmax(140px, 1fr) 160px;
  gap:8px;
  align-items:center;
}
.credit-row {
  display:grid;
  grid-template-columns: minmax(220px, 2.4fr) minmax(180px, 1.6fr) minmax(120px, 1fr) minmax(140px, 1fr) minmax(120px, .8fr) minmax(220px, 2fr) 140px;
  gap:8px;
  align-items:center;
}
.expense-row {
  display:grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.4fr) minmax(220px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) minmax(120px, .9fr);
  gap:8px;
  align-items:center;
}
.service-row {
  display:grid;
  grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) 120px;
  gap:8px;
  align-items:center;
}
.service-row .pill {
  display:inline-flex;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(127,127,127,.12);
  font-size:12px;
}

/* Employee table layout */
#employeesList .row {
  display: grid;
  grid-template-columns: minmax(100px, 0.8fr) minmax(150px, 1.2fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(100px, 0.8fr) 100px;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}
#employeesList .row.header {
  background: rgba(127,127,127,.08);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
#employeesList .row:not(.header):hover {
  background: rgba(127,127,127,.05);
}

.item-row {
  display:grid;
  grid-template-columns: minmax(150px, 1.5fr) minmax(180px, 2fr) minmax(80px, .8fr) repeat(3, minmax(100px, 1fr)) minmax(80px, .8fr) minmax(100px, 1fr) 70px;
  gap:8px;
  align-items:center;
}
.item-field {
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}
.item-field-label {
  display:none;
  font-size:12px;
  font-weight:600;
  color:var(--muted);
}
.item-row input,
.item-row select,
.item-row textarea {
  width:100%;
  padding:8px;
  border-radius:8px;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
}
.item-row .item-total {
  text-align:right;
  font-weight:600;
}
.item-actions {
  display:flex;
  gap:6px;
  justify-content:flex-end;
}

.totals {
  text-align:right;
  font-weight:600;
  color:var(--text);
}

.statement-row {
  display:grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(100px, 1fr) minmax(100px, .8fr) minmax(100px, .8fr) minmax(120px, 1fr) 100px;
  gap:8px;
  align-items:center;
}
.statement-actions {
  display:flex;
  justify-content:flex-end;
  gap:6px;
}

.aging-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow);
}

.aging-card-label {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--muted);
}

.aging-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.aging-card-value.accent {
  color: var(--primary);
}

.aging-card-value.success {
  color: #059669;
}

/* Downloads Grid Styles */
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
}

.download-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
  transition: all 0.2s ease;
  cursor: pointer;
}

.download-card:hover {
  border-color: var(--accent-main);
  box-shadow: 0 4px 12px var(--shadow);
  background: var(--hover-bg);
  transform: translateY(-1px);
}

.download-card-header {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.download-card-title {
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px 0;
  font-size: 1rem;
}

.download-card-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0;
}

.download-card-body {
  padding: 16px;
}

.download-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.download-card-date {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.download-card-size {
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.download-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.download-card-actions button {
  padding: 6px 12px;
  font-size: 0.875rem;
  border-radius: 6px;
}

/* Document Viewer Modal */
.document-viewer-modal {
  width: 90vw;
  height: 90vh;
  max-width: none;
  max-height: none;
}

/* Sub-tabs for Downloads */
.sub-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  margin: 0 16px;
  border-radius: 8px 8px 0 0;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  padding: 12px 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-tab-btn:hover {
  color: var(--text);
  background: var(--bg-secondary);
}

.sub-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-secondary);
}

.aging-table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow);
}

.aging-report-table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.aging-report-table-wrap table {
  min-width: 760px;
}

.aging-table table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

.aging-table thead {
  background: var(--bg-secondary);
}

.aging-table th,
.aging-table td {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.aging-table tfoot {
  background: var(--bg-secondary);
  font-weight: 600;
}

.surface-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow);
}

.statement-outstanding {
  margin-top: 1em;
}

.statement-outstanding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.statement-outstanding-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.statement-outstanding-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.statement-outstanding-card .name {
  font-weight: 600;
  color: var(--text);
}

.statement-outstanding-card .meta {
  font-size: 13px;
  color: var(--muted);
}

.statement-outstanding-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.statement-outstanding-card .amount {
  font-weight: 600;
  font-size: 16px;
  color: var(--primary);
}

.recurring-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.recurring-summary-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 14px;
}

.bank-recon-toolbar {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bank-recon-toolbar h2 {
  margin: 0;
  white-space: nowrap;
}

.bank-recon-toolbar > select,
.bank-recon-toolbar > input[type="file"],
.bank-recon-toolbar > .btn {
  min-height: 40px;
}

.bank-recon-toolbar > input[type="file"] {
  max-width: 260px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}

.bank-recon-grid > .card,
.bank-recon-grid .column > .card,
.statement-outstanding.card.table-full,
#statementRunsArea.card.table-full,
#supplierStatementsTab .statement-outstanding.card.table-full {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#bankReconImportsList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none;
  background: transparent;
  box-shadow: none;
}

.bank-import-card {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 0.9fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.bank-import-title {
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: anywhere;
}

.bank-import-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.bank-import-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr));
  gap: 8px;
}

.bank-import-metric {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  padding: 8px 10px;
}

.bank-import-metric-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bank-import-metric-value {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.bank-import-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.bank-import-actions .btn {
  min-width: 88px;
}

.bank-import-empty {
  padding: 12px 0;
}

.bank-reconcile-quick-content {
  width: min(1040px, 96vw);
  max-height: 92vh;
  padding: 18px;
}

.bank-reconcile-quick-header {
  align-items: flex-start;
  position: sticky;
  top: -18px;
  z-index: 3;
  margin: -18px -18px 0;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.bank-reconcile-help {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.bank-reconcile-help summary {
  cursor: pointer;
  font-weight: 600;
}

.bank-reconcile-help > div {
  margin-top: 8px;
  line-height: 1.5;
}

#bankReconQuickWorkspaceBody #bankReconWorkspaceCard {
  width: 100%;
  max-width: none;
  padding: 16px;
  box-shadow: none;
}

.bank-account-search {
  margin-bottom: 6px;
}

.bank-client-invoice-filter {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.bank-client-invoice-filter label {
  margin-top: 0;
}

.bank-client-invoice-filter .input {
  flex: 1;
  min-width: 220px;
}

.bank-split-account-picker {
  flex: 1 1 280px;
  min-width: 220px;
}

.bank-split-account-picker .split-account-search {
  margin-bottom: 6px;
}

@media (max-width: 720px) {
  .bank-reconcile-quick-content {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  #bankReconQuickWorkspaceBody .grid2 {
    grid-template-columns: 1fr;
  }
}

.statement-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  /* Keep statement preview below other modals (invoice/credit/payment) */
  z-index: 150;
}

.statement-preview-modal.hidden {
  display: none;
}

.statement-preview-panel {
  width: min(960px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.statement-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.statement-preview-body {
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

#quoteModal, #invoiceModal {
  position: fixed !important;
  top: 60px !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 60px) !important;
  height: calc(100dvh - 60px) !important;
  background: var(--surface) !important;
  z-index: 1000 !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

#quoteModal .document-editor, #invoiceModal .document-editor,
#quoteModal .modal-content, #invoiceModal .modal-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  margin: 0;
  padding: 24px;
  padding-bottom: 120px;
  border-radius: 0;
  max-width: none;
}

#quoteModal .modal-backdrop, #invoiceModal .modal-backdrop {
  display: none !important;
}

#quoteModal .modal-content, #invoiceModal .modal-content {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

#quoteModal .document-editor .list.table-grid, #invoiceModal .document-editor .list.table-grid,
#quoteModal .modal-content .list.table-grid, #invoiceModal .modal-content .list.table-grid {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

.invoice-logo-preview{ max-width:180px; max-height:120px; border:1px solid var(--border); border-radius:8px; margin-top:8px; object-fit:contain; }
.document-layout-designer{margin-top:18px;padding:14px;border:1px solid var(--border);border-radius:12px;background:var(--bg-secondary)}
.document-layout-canvas{position:relative;width:min(100%,680px);aspect-ratio:210/297;margin:14px auto 0;background:#fff;border:1px solid #cbd5e1;box-shadow:0 8px 24px rgba(15,23,42,.14);overflow:hidden}
.document-layout-block{position:absolute;border:1px dashed #16a34a;background:rgba(34,197,94,.1);padding:5px;cursor:move;font-size:11px;color:#166534;min-width:38px;min-height:24px;user-select:none;overflow:hidden}
.document-layout-label{display:block;font-size:9px;font-weight:700;text-transform:uppercase;opacity:.65;margin-bottom:3px}.document-layout-sample{font-size:10px;line-height:1.2;color:#0f172a}.document-layout-sample span{float:right}.document-layout-sample hr{border:0;border-top:1px solid #64748b;margin:3px 0}
.document-layout-handle{position:absolute;right:-4px;bottom:-4px;width:9px;height:9px;background:#16a34a;cursor:nwse-resize}
.document-layout-block.selected{border:2px solid #15803d;background:rgba(34,197,94,.2)}.document-layout-typography{margin:12px auto 0;max-width:680px;padding:10px;border:1px solid var(--border);border-radius:8px;background:var(--card)}.document-layout-typography>div{display:flex;gap:10px;flex-wrap:wrap}.document-layout-typography label{min-width:130px}.document-layout-typography input{width:100%;margin-top:4px}
.document-layout-presets{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:12px auto 0;max-width:680px}.document-layout-preset{text-align:left;padding:9px;border:1px solid var(--border);border-radius:8px;background:var(--card);color:var(--text);cursor:pointer}.document-layout-preset:hover{border-color:var(--primary)}.document-layout-preset strong,.document-layout-preset small{display:block}.document-layout-preset small{margin-top:3px;color:var(--muted)}
#invoiceTemplateModal .grid2 > div:has(> #inv_logo_position),#invoiceTemplateModal .grid2 > div:has(> #inv_details_position),#invoiceTemplateModal .grid2 > div:has(> #inv_logo_vertical_position),#invoiceTemplateModal .grid2 > div:has(> #inv_logo_width),#invoiceTemplateModal .grid2 > div:has(> #inv_address_block_position),#invoiceTemplateModal .grid2 > div:has(> #inv_totals_position),#invoiceTemplateModal .grid2 > div:has(> #inv_notes_position){display:none}

/* Settings Dropdown Styles */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 1000;
  min-width: 160px;
  max-width: min(340px, calc(100vw - 16px));
}
.dropdown-content:not(.hidden) { display: block; }
.dropdown-item {
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}
.dropdown-item:hover {
  background: rgba(127,127,127,.1);
}
.dropdown-item:first-child { border-radius: 8px 8px 0 0; }
.dropdown-item:last-child { border-radius: 0 0 8px 8px; }
.dropdown-item:only-child { border-radius: 8px; }

/* Locked/Disabled Features */
.locked-feature {
  position: relative;
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed !important;
}

.locked-feature::before {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  z-index: 10;
  pointer-events: none;
}

.locked-feature-wrapper {
  position: relative;
  display: inline-block;
}

.locked-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  margin-bottom: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}

.locked-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.locked-feature-wrapper:hover .locked-tooltip {
  opacity: 1;
}

/* Tab/Button specific locked state */
.tab.locked, .btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.tab.locked::after, .btn.locked::after {
  content: '🔒';
  margin-left: 6px;
  font-size: 12px;
}

/* Chart of Accounts Styles */
.account-group {
  margin-bottom: 24px;
}

.account-type-header {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  padding: 8px 16px;
  background: var(--border);
  border-radius: 8px;
  color: var(--text);
}

.account-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-row {
  display: grid;
  grid-template-columns: 100px 1fr 2fr 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.account-row:hover {
  background: rgba(127, 127, 127, 0.05);
  border-color: var(--primary);
}

.account-row.inactive {
  opacity: 0.6;
}

.account-code {
  font-weight: 600;
  font-family: 'Courier New', monospace;
  color: var(--muted);
}

.account-name {
  font-weight: 500;
  color: var(--text);
}

.account-desc {
  color: var(--muted);
  font-size: 14px;
}

.account-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: #10b981;
  color: white;
}

.badge.inactive {
  background: var(--muted);
}

.badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.paid {
  background: #16a34a;
}

.status-pill.partial {
  background: #f59e0b;
}

.status-pill.unpaid {
  background: #ef4444;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.ghost.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn.xs {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

/* Utility text colors */
.text-green {
  color: #10b981;
}

.text-blue {
  color: #3b82f6;
}

.text-red {
  color: #ef4444;
}

/* Payment invoice item hover */
.payment-invoice-item:hover {
  background: #f9fafb;
}

.credit-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.credit-action-bar {
  display: flex;
  gap: 8px;
}

.credit-view-section label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.credit-summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  margin-bottom: 16px;
}

.credit-amount {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}

.credit-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.credit-view-value {
  font-weight: 600;
  color: var(--text);
}

.credit-notes-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--bg-secondary);
}

.credit-form-section {
  margin-bottom: 16px;
}

.credit-selected-invoice {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.credit-selected-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credit-invoice-ref {
  font-weight: 600;
  font-size: 16px;
}

.credit-invoice-amount {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.credit-invoice-results {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--card);
}

.credit-invoice-results .table-row {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.credit-invoice-results .table-row:last-child {
  border-bottom: none;
}

/* Dashboard Styles */
.dashboard-grid {
  padding: 10px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(100vh - 112px);
  overflow-y: auto;
}

.dashboard-toolbar {
  padding-top: 8px;
  padding-bottom: 4px;
}

.dashboard-widget-board {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  padding: 6px 0 16px;
}

.dashboard-widget-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  max-width: 100%;
  min-height: 160px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: auto;
}

.dashboard-widget-card.is-draggable {
  cursor: move;
}

.dashboard-widget-card.is-resizable {
  resize: both;
}

.dashboard-widget-card.is-drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.dashboard-widget-card.is-resizable::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  background:
    linear-gradient(135deg, transparent 0 45%, var(--text-muted) 45% 55%, transparent 55% 100%),
    linear-gradient(135deg, transparent 0 68%, var(--text-muted) 68% 78%, transparent 78% 100%);
  opacity: 0.45;
  pointer-events: none;
}

.dashboard-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.dashboard-widget-header h3 {
  margin: 0;
  font-size: 18px;
}

.dashboard-widget-meta {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-widget-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-widget-handle {
  color: var(--muted);
  font-size: 14px;
}

.dashboard-widget-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  flex: 1;
}

.dashboard-widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.dashboard-widget-grid.dashboard-widget-grid--stats {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

@media (max-width: 960px) {
  .dashboard-widget-board {
    gap: 12px;
  }

  .dashboard-widget-card {
    width: 100% !important;
    min-width: 0;
  }
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.dashboard-card-slot,
.dashboard-stat-slot {
  position: relative;
}

.dashboard-card-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  padding: 4px 8px;
}

.dashboard-stat-slot .dashboard-card-menu {
  top: 8px;
  right: 8px;
}

.kpi-card.management-kpi-action {
  cursor: pointer;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.kpi-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.kpi-icon.clients { background: linear-gradient(135deg, var(--accent-main), var(--accent-hover)); }
.kpi-icon.revenue { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-icon.invoices { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kpi-icon.inventory { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.kpi-content {
  flex: 1;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.kpi-change {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.kpi-change.positive {
  color: var(--accent-main);
  background-color: var(--accent-bg);
}

.kpi-change.negative {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.dashboard-row.analytics-row {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.activity-panel, .summary-panel, .actions-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.management-workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.management-workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.management-workspace-actions {
  margin-left: auto;
}
.management-workspace-panel .table-card {
  overflow: auto;
}
.management-workspace-panel table {
  min-width: 980px;
}
.management-workspace-panel tbody tr {
  cursor: pointer;
}
.management-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.management-detail-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--card);
}
.management-detail-card .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.management-detail-card .value {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}
.management-code-block {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  min-height: 72px;
}

.chart-panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.chart-body {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chart-fixed { min-height: 300px; }
.chart-fixed-small { min-height: 240px; }

.chart-body canvas {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  align-items: center;
  max-height: 110px;
  overflow: auto;
}
.chart-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.chart-legend .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.chart-empty.hidden {
  display: none;
}

.dashboard-chart-tooltip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.96);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.dashboard-chart-tooltip.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
  margin: 0;
  color: var(--text-color);
  font-size: 18px;
  font-weight: 600;
}
.chart-control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-range-select {
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 10px;
}

.chart-custom-range {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: -6px 0 14px;
  flex-wrap: wrap;
}

.chart-custom-range.hidden {
  display: none;
}

.chart-custom-range .input,
.chart-custom-range input[type="date"] {
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-color);
}

.refresh-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.refresh-btn:hover {
  background-color: var(--hover-bg);
  color: var(--accent-main);
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.activity-item:hover {
  background-color: var(--hover-bg);
}

.activity-icon {
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-bg);
  color: var(--accent-main);
  flex-shrink: 0;
}

.activity-icon.invoice { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.activity-icon.client { background-color: var(--accent-bg); color: var(--accent-main); }
.activity-icon.stock { background-color: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

.activity-text {
  flex: 1;
}

.activity-title {
  font-weight: 600;
  color: var(--text-color);
  font-size: 14px;
  margin-bottom: 4px;
}

.activity-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}


.stat-item {
  text-align: center;
  padding: 16px;
  border-radius: 8px;
  background-color: var(--accent-bg);
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-main);
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard-widget-config-list {
  display: grid;
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
}

.dashboard-widget-config-group {
  display: grid;
  gap: 10px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border);
}

.dashboard-widget-config-group:last-child {
  border-bottom: none;
}

.dashboard-widget-config-group-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-preferences-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-widget-config-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.dashboard-widget-config-item strong {
  display: block;
  margin-bottom: 4px;
}

.dashboard-widget-config-item small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.management-dashboard-board {
  width: 100%;
  padding-top: 0;
}

.management-dashboard-card {
  width: min(420px, 100%);
  min-height: 250px;
}

.management-dashboard-card--wide {
  width: min(620px, 100%);
}

.actions-panel {
  grid-column: 1 / -1;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
}

.action-btn.primary {
  background: var(--accent-main);
  color: white;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.action-btn.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.action-btn.secondary {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.action-btn.secondary:hover {
  background: var(--hover-bg);
  border-color: var(--accent-main);
  color: var(--accent-main);
}

.action-icon {
  font-size: 18px;
}

.action-text {
  font-size: 14px;
}

/* Responsive Dashboard */
@media (max-width: 768px) {
  .email-settings-header {
    flex-direction: column;
  }

  .email-settings-grid {
    grid-template-columns: 1fr;
  }

  .email-section-card--connector,
  .email-section-card--templates {
    grid-column: auto;
  }

  .email-provider-grid {
    grid-template-columns: 1fr;
  }

  .mail-topbar {
    flex-direction: column;
  }

  .mail-workspace {
    grid-template-columns: 1fr;
  }

  .client-drawer-actions{
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
  }

  .client-drawer-actions .btn{
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding-inline: 10px;
  }

  .mail-sidebar,
  .mail-list-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .mail-message-list {
    padding: 12px;
  }

  .mail-search-input,
  .mail-sort-select {
    min-width: 0;
    width: 100%;
  }

  .dashboard-row {
    grid-template-columns: 1fr;
  }
  
  .kpi-row {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
  
  .actions-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .recurring-summary-grid {
    grid-template-columns: 1fr;
  }

  .bank-import-card {
    grid-template-columns: 1fr;
  }

  .bank-import-actions {
    justify-content: flex-start;
  }
  
  .stat-item {
    padding: 12px 8px;
  }
  
  .stat-number {
    font-size: 18px;
  }
}

/* Voice Input Modal Styling */
.voice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
}

.voice-input-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card, #1a1a1a);
  color: var(--text, #ffffff);
  border-radius: 12px;
  padding: 24px;
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border, #333);
  z-index: 10001;
}

.voice-input-modal h3 {
  margin: 0 0 16px 0;
  color: var(--text, #ffffff);
  font-size: 1.25rem;
}

.voice-input-modal textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #333);
  background: var(--bg-secondary, #2a2a2a);
  color: var(--text, #ffffff);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  box-sizing: border-box;
}

.voice-input-modal textarea:focus {
  outline: none;
  border-color: var(--primary, #22c55e);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.voice-input-modal .buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  justify-content: flex-end;
}

.voice-input-modal button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.voice-input-modal button.secondary {
  background: var(--bg-secondary, #2a2a2a);
  color: var(--text, #ffffff);
  border: 1px solid var(--border, #333);
}

.voice-input-modal button.secondary:hover {
  background: var(--border, #333);
}

.voice-input-modal button.primary {
  background: var(--primary, #22c55e);
  color: white;
}

.voice-input-modal button.primary:hover {
  background: #16a34a;
}

.brand-dialog-shell {
  position: fixed;
  inset: 0;
  z-index: 21000;
}

.brand-dialog-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(34, 197, 94, 0.16), transparent 42%),
    rgba(3, 8, 18, 0.58);
  backdrop-filter: blur(10px);
}

.brand-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(240,253,244,0.96));
  color: #0f172a;
  border: 1px solid rgba(34, 197, 94, 0.18);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

html[data-theme="dark"] .brand-dialog {
  background: linear-gradient(180deg, rgba(33, 37, 41, 0.98), rgba(26, 31, 35, 0.98));
  color: #f8fafc;
  border-color: rgba(74, 222, 128, 0.22);
}

.brand-dialog::before {
  content: '';
  display: block;
  height: 5px;
  background: linear-gradient(90deg, #22c55e, #4ade80, #16a34a);
}

.brand-dialog-header,
.brand-dialog-actions,
.brand-dialog-message,
.brand-dialog-title,
.brand-dialog-input {
  position: relative;
  z-index: 1;
}

.brand-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 8px;
}

.brand-dialog-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

html[data-theme="dark"] .brand-dialog-badge {
  background: rgba(74, 222, 128, 0.14);
  color: #86efac;
}

.brand-dialog-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  color: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

html[data-theme="dark"] .brand-dialog-close {
  background: rgba(255,255,255,0.04);
}

.brand-dialog-title {
  padding: 0 22px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-dialog-message {
  padding: 12px 22px 0;
  white-space: pre-wrap;
  line-height: 1.6;
  color: rgba(15, 23, 42, 0.82);
}

html[data-theme="dark"] .brand-dialog-message {
  color: rgba(248, 250, 252, 0.86);
}

.brand-dialog-input {
  width: calc(100% - 44px);
  margin: 16px 22px 0;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(34, 197, 94, 0.22);
  background: rgba(255,255,255,0.88);
  color: inherit;
  font: inherit;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

html[data-theme="dark"] .brand-dialog-input {
  background: rgba(255,255,255,0.05);
}

.brand-dialog-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

textarea.brand-dialog-input {
  min-height: 120px;
  resize: vertical;
}

.brand-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 22px 22px;
}

.brand-dialog-actions .btn {
  min-width: 108px;
  min-height: 42px;
}

.support-modal-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.support-section {
  border-top: 1px solid var(--border, #333);
  padding-top: 14px;
}

.support-section h4 {
  margin: 0 0 8px 0;
  font-size: 1rem;
}

.support-label {
  display: block;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
}

.support-section input,
.support-section select,
.support-section textarea {
  margin-top: 4px;
  margin-bottom: 4px;
  border-radius: 10px;
  border: 1px solid var(--border, #2e3442);
  background: var(--bg-secondary, #171d2a);
  color: var(--text, #ffffff);
  padding: 10px 12px;
}

.support-section .row {
  flex-wrap: wrap;
}

.support-status {
  margin: 2px 0 10px 0;
  border-radius: 10px;
  border: 1px solid #1f3e2d;
  background: rgba(34, 197, 94, 0.12);
  color: #89efb3;
  padding: 9px 11px;
  font-size: 0.84rem;
  line-height: 1.35;
}
.support-status.is-error {
  border-color: #5f2020;
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}
.support-status.is-success {
  border-color: #1f5539;
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
}

/* Dashboard widget layout helpers */
.dashboard-widget.hidden { display: none !important; }
.dashboard-widget.size-small { grid-column: span 1; }
.dashboard-widget.size-medium { grid-column: span 2; }
.dashboard-widget.size-large { grid-column: span 3; }

/* Business Snapshot */
.snapshot-container { display: flex; flex-direction: column; gap: 16px; }
.snapshot-card { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.04); }
.snapshot-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 12px; }
.snapshot-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 12px; }
.card-title { font-weight: 600; color: #111827; margin-bottom: 8px; }
.kpi { font-size: 28px; font-weight: 700; color: #0a9f4d; }
.muted { color: #6b7280; }
.muted.small { font-size: 12px; }
.bar { height: 12px; border-radius: 6px; overflow: hidden; background: #e5e7eb; }
.bar-pair .bar div { height: 100%; border-radius: 6px; }
.stack-bar { height: 14px; border-radius: 8px; overflow: hidden; display: flex; background: #e5e7eb; }
.stack-seg { height: 100%; }
.stack-seg.assets { background: rgba(34,197,94,0.4); }
.stack-seg.liabilities { background: rgba(239,68,68,0.5); }
.stack-seg.equity { background: rgba(59,130,246,0.5); }
.snapshot-card .row.between { align-items: center; }
.ratio-card .kpi { font-size: 22px; }
.mini-chart { height: 60px; }
.snapshot-section { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.snapshot-list { display: flex; flex-direction: column; gap: 10px; }
.snapshot-list-row { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid #eef2f7; }
.snapshot-list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.snapshot-row { display: grid; grid-template-columns: minmax(120px, 1.5fr) minmax(120px, 2fr) auto; gap: 12px; align-items: center; margin: 4px 0; }
.snapshot-row-bar { min-width: 120px; }
.snapshot-expense-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(120px, 2fr);
  gap: 10px 14px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f7;
}
.snapshot-expense-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.snapshot-expense-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.snapshot-expense-name {
  font-weight: 600;
  color: #111827;
  word-break: break-word;
}
.snapshot-expense-amount {
  font-size: 13px;
  color: #475569;
  word-break: break-word;
}

#financialReviewTab .dashboard-grid,
#complianceWorkspaceTab .dashboard-grid {
  display: grid;
  height: auto;
  overflow: visible;
  padding: 0 16px 16px;
  gap: 16px;
}

#financialReviewTab .card,
#complianceWorkspaceTab .card {
  width: 100%;
  max-width: none;
}

/* Voice UI overrides to keep floating buttons on-brand green */
.voice-mic-btn,
.voice-text-btn {
  background: linear-gradient(135deg, #16a34a, #22c55e) !important;
  color: #fff !important;
  border: 2px solid rgba(34,197,94,0.35) !important;
  box-shadow: 0 8px 20px rgba(34,197,94,0.55) !important;
}
.voice-text-btn:hover:not(:disabled),
.voice-mic-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}
.voice-text-btn:disabled,
.voice-mic-btn:disabled {
  background: #9ca3af !important;
  box-shadow: none !important;
}


.ocr-line-row{display:grid;grid-template-columns:2fr 0.6fr 0.8fr 0.8fr;gap:8px;margin-bottom:8px}
.ocr-line-row .ocr-line-meta{grid-column:1 / -1;font-size:12px;color:#6b7280;margin-top:-2px}
.ocr-confidence-box{margin:10px 0;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:#f8fafc;font-size:13px;line-height:1.5}
.ocr-confidence-box.high{border-color:#86efac;background:#f0fdf4}
.ocr-confidence-box.medium{border-color:#facc15;background:#fefce8}
.ocr-confidence-box.low{border-color:#fca5a5;background:#fef2f2}

/* Legal modal styling */
#termsModal {
  align-items: center;
}
#termsModal .modal-content,
.terms-shell {
  width: min(720px, calc(100vw - 40px));
  max-width: 720px;
  max-height: min(78vh, 820px);
  overflow-y: auto;
  background: #f7f9fc;
  box-shadow: 0 22px 40px rgba(0,0,0,0.25);
  border-radius: 16px;
  padding: 24px;
}
.terms-hero {
  text-align: center;
  margin-bottom: 14px;
}
.terms-hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}
.terms-hero p {
  margin: 6px 0 0;
  font-size: 14px;
}
.terms-banner {
  background: #fff8e6;
  border: 1px solid #f59e0b;
  color: #7c2d12;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.terms-banner strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.terms-banner p {
  margin: 8px 0 0;
  color: #4b5563;
  font-size: 14px;
}
.terms-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.terms-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
}
.terms-option-required {
  border-color: #22c55e;
  background: #ecfdf3;
}
.terms-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}
.terms-option-body {
  min-width: 0;
}
.terms-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.terms-option-title {
  font-weight: 700;
  margin-bottom: 4px;
}
.terms-option-title .required {
  color: #c62828;
  font-weight: 800;
}
.terms-option-title .recommended {
  color: #c27b00;
  font-weight: 800;
}
.terms-option .btn {
  flex: 0 0 auto;
}
.terms-note {
  background: #fffbeb;
  border: 1px solid #facc15;
  border-radius: 12px;
  padding: 10px 12px;
  color: #7c2d12;
  margin-bottom: 14px;
  font-size: 13px;
}
.terms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
@media (max-width: 640px) {
  #termsModal .modal-content,
  .terms-shell {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 24px);
    padding: 18px;
  }
  .terms-option-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .terms-actions {
    flex-direction: column-reverse;
  }
  .terms-actions .btn {
    width: 100%;
  }
}

/* Notifications */
.badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 2px;
}
.hidden { display: none !important; }
.notify-panel {
  position: absolute;
  right: 16px;
  top: 52px;
  width: 320px;
  max-width: calc(100vw - 16px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 2000;
}
.notify-header {
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
}
.notify-list {
  max-height: 320px;
  overflow-y: auto;
}
.notify-section-heading {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #6b7280;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}
.notify-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.notify-item:last-child { border-bottom: none; }
.notify-item .title { font-weight: 700; margin-bottom: 4px; }
.notify-item .desc { color: #4b5563; font-size: 13px; }
.notify-item.notify-link {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  cursor: pointer;
}
.notify-item.notify-link:hover {
  background: #f8fafc;
}
.notify-item.warn { border-left: 4px solid #f59e0b; }
.notify-item.crit { border-left: 4px solid #ef4444; }
.notify-item.ok { border-left: 4px solid #10b981; }
.notify-target-highlight {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.45) !important;
  border-radius: 8px;
  transition: box-shadow .2s ease;
}

/* Tasks + Calendar (To Do tab) */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
.calendar-weekday {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 0 6px;
}
.calendar-day {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 8px 10px;
  min-height: 96px;
  cursor: pointer;
}
.calendar-day:hover {
  border-color: var(--primary);
}
.calendar-day.outside {
  opacity: 0.45;
}
.calendar-day.today {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}
.calendar-day.selected {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.65);
}
.calendar-day-num {
  font-weight: 700;
}
.calendar-day-count {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.calendar-task-preview {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(520px, 2fr);
  gap: 16px;
}
#projectsTab.detail-collapsed .projects-grid {
  grid-template-columns: minmax(0, 1fr);
}
.project-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow: auto;
}
.project-list-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--card);
}
.project-list-item.active {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
}
.project-list-title {
  font-weight: 600;
  color: var(--text);
}
.project-list-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
  .project-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  .project-section h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
  }
.project-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
    width: 100%;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
  color: var(--muted);
  font-size: 13px;
}
.project-detail-card.hidden {
  display: none;
}
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field .input,
.password-field input {
  width: 100%;
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.password-toggle:hover {
  color: var(--text);
}
  .project-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
  }
  .project-summary-item {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
  }
  .project-summary-label {
    font-size: 11px;
    color: var(--muted);
  }
  .project-summary-value {
    font-weight: 600;
    margin-top: 2px;
  }
.project-detail-card textarea {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.project-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(16,185,129,.12);
  color: #0f766e;
}
html[data-theme="dark"] .project-pill {
  background: rgba(16,185,129,.22);
  color: #a7f3d0;
}
@media (max-width: 1100px) {
  .projects-grid { grid-template-columns: 1fr; }
  .project-list { max-height: 40vh; }
}

@media (max-width: 900px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }
  .tabs { overflow-x: auto; overflow-y: visible; flex-wrap: nowrap; position: relative; }
  .tabs .tab { white-space: nowrap; }
  .tab-dropdown { position: static; }
  .tab-dropdown-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 120px;
    width: auto;
    min-width: 0;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    border-radius: 12px;
    z-index: 4000;
  }
  .appbar {
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
  }
  .appbar > * {
    min-width: 0;
  }
  .brand {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }
  .org-name-chip {
    max-width: calc(100vw - 110px);
  }
  .spacer {
    display: none;
  }
  #userInfo {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dropdown-content,
  .notify-panel {
    max-width: calc(100vw - 24px);
  }
  .toolbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    overflow-x: hidden;
  }
  .toolbar > * {
    min-width: 0;
  }
  .toolbar input,
  .toolbar select,
  .toolbar .btn {
    max-width: 100%;
  }
  .toolbar input,
  .toolbar select {
    flex: 1 1 220px;
  }
  .toolbar .btn {
    flex: 1 1 140px;
    white-space: normal;
    justify-content: center;
    text-align: center;
  }
  #dashboardTab > .toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
  #dashboardTab > .toolbar h2 {
    grid-column: 1 / -1;
  }
  #dashboardTab > .toolbar .spacer {
    display: none;
  }
  #dashboardTab > .toolbar > label.row {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    gap: 6px;
    min-width: 0;
    margin: 0;
  }
  #dashboardTab > .toolbar > button {
    flex: 0 0 auto;
    width: 100%;
  }
  .tabview { padding: 8px 12px 16px; }
  .card, .card.table-full { width: 100%; max-width: 100%; padding: 16px; }
  .row { flex-wrap: wrap; align-items: flex-start; }
  .row.between { gap: 8px; }
  .grid2 { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .list .row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .list .row > div { width: 100%; }
  .table-card, .list.table-grid, #paymentsListArea, #creditNotesListContainer, #expensesTableContainer {
    overflow-x: auto;
    max-width: 100%;
  }
  .table-card table, .aging-table table, .item-sales-table table {
    min-width: 680px;
  }
  .aging-report-table-wrap {
    max-width: 100%;
  }
  .aging-report-table-wrap table {
    min-width: 760px;
  }
  #tasksCalendarView {
    overflow-x: auto;
  }
  .calendar-grid {
    min-width: 640px;
    gap: 6px;
  }
  .calendar-weekday {
    font-size: 11px;
    padding: 0 4px;
  }
  .calendar-day {
    min-height: 88px;
    padding: 8px;
  }
  .calendar-task-preview {
    font-size: 11px;
  }
  .table-card,
  .list,
  .tabview,
  .drawer-body,
  .modal-content,
  .document-editor {
    max-width: 100%;
  }
  #clientsList {
    max-height: none;
  }
  .quote-row,
  .invoice-row,
  .payment-row,
  .credit-row,
  .expense-row,
  .service-row,
  .item-row,
  .row.task {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .quote-row.header,
  .invoice-row.header,
  .payment-row.header,
  .credit-row.header,
  .expense-row.header,
  .service-row.header,
  .item-row.header,
  .row.task.header {
    display: none;
  }
  .table-grid .actions,
  .item-actions {
    justify-content: stretch;
    width: 100%;
  }
  .table-grid .actions .btn,
  .item-actions .btn {
    flex: 1 1 auto;
  }
  .item-row .item-total,
  .totals {
    text-align: left;
  }
  .item-row .item-field-label {
    display: block;
  }
  .item-row .item-actions {
    flex-wrap: wrap;
  }
  .item-row .item-actions .btn {
    min-height: 42px;
  }
  #customDashboardPanel .panel-header {
    align-items: stretch;
  }
  #customDashboardPanel .panel-header .spacer {
    display: none;
  }
  #customDashboardPanel .panel-header .input,
  #customDashboardPanel .panel-header .btn {
    width: 100%;
  }
  .ocr-line-row {
    grid-template-columns: 1fr;
  }
  #invoiceModal .modal-content,
  #quoteModal .modal-content,
  #expenseModal .modal-content {
    width: min(96vw, 96vw);
    height: auto;
    max-height: 92vh;
  }
  #quoteModal .document-editor,
  #invoiceModal .document-editor,
  #quoteModal .modal-content,
  #invoiceModal .modal-content {
    padding: 16px 14px calc(140px + env(safe-area-inset-bottom, 0px));
  }
  .document-summary-row {
    align-items: stretch;
    gap: 10px;
  }
  #quoteModal .document-footer-actions,
  #invoiceModal .document-footer-actions {
    position: static;
    display: flex;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 10px;
    padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    background: transparent;
    border-top: 0;
    box-shadow: none;
  }
  #quoteModal .document-footer-actions .btn,
  #invoiceModal .document-footer-actions .btn,
  .document-summary-row .btn {
    min-height: 46px;
    width: 100%;
    flex: 1 1 calc(50% - 10px);
  }
  #quoteModal .document-footer-actions,
  #invoiceModal .document-footer-actions {
    margin-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  .first-value-options {
    grid-template-columns: 1fr;
  }
  .onboarding-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .onboarding-actions .btn {
    width: 100%;
  }
  .project-list { max-height: 35vh; }
  .snapshot-expense-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
  }
  .snapshot-row-bar {
    min-width: 0;
  }
  #financialReviewTab .dashboard-grid,
  #complianceWorkspaceTab .dashboard-grid {
    grid-template-columns: 1fr !important;
    padding: 0 0 16px;
  }
}

@media (max-width: 480px) {
  .tabview { padding: 6px 10px 14px; }
  .card, .card.table-full { padding: 12px; }
  .btn, .icon { padding: 8px 10px; }
  .project-summary-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar input,
  .toolbar select,
  .toolbar .btn {
    flex-basis: 100%;
  }
  #dashboardTab > .toolbar {
    grid-template-columns: 1fr;
  }
  .voice-mic-btn,
  .voice-text-btn {
    transform: scale(0.92);
    transform-origin: left bottom;
  }
}

.searchable-account-control {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.searchable-account-control > .global-account-search,
.searchable-account-control > select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}

.searchable-account-control > .global-account-search {
  margin: 0;
}

.searchable-account-control > select.account-select-filtered {
  border-color: #22c55e;
}

.account-search-empty {
  padding: 2px 4px;
  font-size: 12px;
}

.expense-form-status {
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 14px;
}

.expense-form-status[data-type="success"] {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.expense-form-status[data-type="info"] {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.expense-vat-policy-notice {
  margin: -4px 0 12px;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
  line-height: 1.4;
}

#expenseModal .expense-field-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}
.audit-json {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border, #dbe2ea);
  border-radius: 10px;
  background: var(--surface-soft, #f8fafc);
  color: var(--text, #111827);
  font-size: 12px;
  line-height: 1.5;
}
