/* Invoice Management – compact admin layout */
:root {
  --bg: #f1f3f5;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-muted: #5c5f6b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --border: #e2e6f0;
  --error: #dc2626;
  --success: #16a34a;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 2px 6px rgba(0,0,0,.08);
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-width: 160px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

/* ========== Admin layout: header + sidebar + main ========== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  flex-shrink: 0;
  background: var(--theme-header-bg, #1e293b);
  color: #e2e8f0;
  padding: 8px 16px;
  font-size: 12px;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.app-header-left { color: #94a3b8; }
.app-header-left strong { color: #e2e8f0; }

.app-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.app-header-user {
  color: #e2e8f0;
  font-weight: 500;
}

.app-header-lang { display: inline-flex; align-items: center; gap: 6px; }
.app-header-lang-label { color: #94a3b8; margin: 0; font-weight: 400; }
.app-header-lang-select {
  padding: 4px 8px;
  font-size: 12px;
  background: #334155;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 4px;
  color: #f1f5f9;
  cursor: pointer;
  appearance: auto;
}
.app-header-lang-select:hover { background: #475569; }
.app-header-lang-select:focus { outline: none; border-color: rgba(255,255,255,.5); }
.app-header-lang-select option {
  background: #334155;
  color: #f1f5f9;
}

.app-header-logout { color: #e2e8f0; text-decoration: none; white-space: nowrap; }
.app-header-logout:hover { text-decoration: underline; }

.app-layout-body {
  display: flex;
  flex: 1;
  min-width: 0;
}

.app-layout.sidebar-hidden .sidebar {
  display: none;
}

.app-header-menu-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: #e2e8f0;
  width: 32px;
  height: 28px;
  padding: 0;
  margin-right: 10px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.app-header-menu-toggle:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.5);
  color: #fff;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--theme-menu-bg, var(--sidebar-bg));
  color: var(--sidebar-text);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 10px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}

.sidebar-tenant {
  padding: 6px 10px 8px;
  font-size: 11px;
  color: rgba(255,255,255,.85);
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 8px;
}

.sidebar-tenant strong {
  font-weight: 600;
  color: #fff;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0 6px;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 11px;
  transition: background .15s, color .15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-nav a.active:hover {
  background: var(--primary-hover);
  color: #fff;
}

.sidebar-group {
  margin-top: 4px;
}

.sidebar-group-label {
  display: block;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.6);
}

.sidebar-subnav {
  list-style: none;
  margin: 0 0 0 4px;
  padding: 0 0 0 8px;
  border-left: 1px solid rgba(255,255,255,.15);
}

.sidebar-subnav li { margin: 0; }

.sidebar-subnav a {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 11px;
  transition: background .15s, color .15s;
}

.sidebar-subnav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-subnav a.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-subnav a.active:hover {
  background: var(--primary-hover);
  color: #fff;
}

.logout-btn {
  display: block;
  padding: 4px 8px;
  text-align: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}

.logout-btn:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 12px 16px 16px;
  background: var(--bg);
  color: #000000;
}

/* Home page: customer filter list left + dashboard right */
.home-with-filter {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.home-customer-list {
  flex-shrink: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  position: sticky;
  top: 12px;
}
.home-customer-list-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.home-customer-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 70vh;
  overflow-y: auto;
}
.home-customer-item {
  display: block;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.home-customer-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.home-customer-item.is-selected {
  background: var(--primary);
  color: #fff;
}
.home-customer-item.is-selected:hover {
  background: var(--primary-hover);
  color: #fff;
}

/* Home filters: customer (scroll) + year + month */
.home-filters {
  flex-shrink: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 12px;
}
.home-filter-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.home-filter-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.home-filter-section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.home-filter-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.home-filter-customer-scroll {
  max-height: 50vh;
  max-height: min(50vh, 400px);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}
.home-filter-customer-scroll::-webkit-scrollbar {
  width: 6px;
}
.home-filter-customer-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.home-filter-customer-scroll::-webkit-scrollbar-track {
  background: var(--surface);
}
.home-filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.home-filter-checkbox-label:hover {
  background: var(--primary-light);
}
.home-filter-radio {
  flex-shrink: 0;
  margin: 0;
}
.home-filter-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.home-filter-select-deselect {
  margin: 6px 0 0;
  font-size: 12px;
}
.home-filter-select-deselect-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}
.home-filter-select-deselect-btn:hover {
  color: var(--primary-hover);
}
.home-filter-select-deselect-sep {
  margin: 0 6px;
  color: var(--text-muted);
}
.home-filter-apply {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 4px;
}
.home-filter-apply:hover {
  background: var(--primary-hover);
}

.home-dashboard {
  flex: 1;
  min-width: 0;
}

.page-header {
  margin-bottom: 12px;
}

.page-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== Cards & content ========== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 12px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.section-title {
  margin: 12px 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* ========== Forms ========== */
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #000000;
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}

/* Add/edit pages: same black border on edit boxes */
.card input[type="text"],
.card input[type="password"],
.card input[type="date"],
.card input[type="email"],
.card input[type="number"],
.card input[type="url"],
.card select,
.card textarea {
  border: 1px solid #000000;
}

select {
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}

input::placeholder {
  color: #9ca3af;
}

.form-row {
  margin-bottom: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

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

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}

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

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:focus {
  background: #f8fafc;
  border-color: var(--text-muted);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover, .btn-danger:focus {
  background: #b91c1c;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.link-btn:hover {
  text-decoration: none;
}

/* Icon-only action buttons in tables */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: color .15s, background .15s, border-color .15s;
}
.btn-icon:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary);
}
.btn-icon svg {
  flex-shrink: 0;
}
.btn-icon-edit:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary); }
.btn-icon-delete:hover, .btn-icon-delete:focus { color: #dc2626; background: #fef2f2; border-color: #dc2626; }
.btn-icon-print:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary); }
.btn-icon-cancel:hover { color: #b45309; background: #fffbeb; border-color: #b45309; }

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 5px solid #374151;
}

.tabs .tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}

.tabs .tab:hover {
  color: var(--text);
  background: #f8fafc;
  border-color: #9ca3af;
}

.tabs .tab.active {
  color: var(--primary);
  background: var(--surface);
  border: 3px solid #374151;
  border-bottom-color: var(--surface);
  margin-bottom: -5px;
}

.tab-panel {
  display: none;
}

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

.form-max {
  max-width: 520px;
}

/* ========== Messages ========== */
.msg-error {
  padding: 6px 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 11px;
  margin-bottom: 8px;
}

.msg-success {
  padding: 6px 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  color: var(--success);
  font-size: 11px;
  margin-bottom: 8px;
}

/* ========== Tables ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.table-wrap th,
.table-wrap td {
  padding: 4px 8px;
  text-align: left;
}

.table-wrap th {
  font-weight: 600;
  color: var(--text-muted);
  background: #f8fafc;
}

.table-wrap th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.table-wrap th a:hover { color: var(--primary); text-decoration: none; }
.table-wrap .sort-arrow { font-size: 10px; opacity: .8; }

.table-wrap tbody tr:hover td {
  /* row colors from theme override; lighten on hover could be added via JS if needed */
}

.table-wrap .actions {
  white-space: nowrap;
}

.table-wrap .contract-number-cell {
  font-size: 0.875em;
}

.table-wrap th.cell-numeric,
.table-wrap td.cell-numeric {
  text-align: right;
}

.table-wrap th.cell-narrow,
.table-wrap td.cell-narrow {
  max-width: 6em;
}

.contract-alert-icon-cell { text-align: center; vertical-align: middle; white-space: nowrap; width: 1%; min-width: 52px; max-width: 52px; padding-left: 4px; padding-right: 4px; }
.contract-alert-icons-wrap { display: inline-flex; align-items: center; gap: 4px; }
.contract-alert-icon { display: inline-flex; align-items: center; justify-content: center; color: inherit; text-decoration: none; padding: 2px; border-radius: var(--radius-sm); }
.contract-alert-icon:hover { opacity: 0.9; }
.contract-alert-icon .icon-alert,
.contract-alert-icon .icon-alert.icon-stop { color: #dc2626; }
.contract-alert-icon .icon-warning { color: #b45309; }
.contract-alert-icon-empty { color: var(--text-muted); font-size: 11px; min-width: 18px; display: inline-block; text-align: center; }
.contract-alert-icons-header { width: 1%; min-width: 52px; max-width: 52px; padding-left: 4px; padding-right: 4px; text-align: center; }

.table-wrap th.col-hidden,
.table-wrap td.col-hidden {
  display: none;
}

.kpi-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 12px 0;
}
.kpi-section-title:first-of-type {
  margin-top: 0;
}
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.kpi-card .kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.kpi-card .kpi-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-card .kpi-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
}
.kpi-card .kpi-link:hover {
  text-decoration: underline;
}

/* Home: first 4 indicators – same layout as KPI Payments (grid, card height/width) */
.home-indicators-card {
  margin-bottom: 24px;
}
.home-indicators-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.home-indicator-item {
  background: var(--indicators-card-bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.home-indicator-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 4px;
}
.home-indicator-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.home-indicator-value.is-negative {
  color: var(--error);
}
.home-indicator-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.home-indicator-pct {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.home-indicator-pct.is-negative {
  color: var(--error);
}
.home-indicator-with-icon {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 10px;
}
.home-indicator-with-icon .home-indicator-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}
.home-indicator-with-icon .home-indicator-label { flex-basis: 100%; margin-bottom: 0; }
.home-indicator-icon-alert { color: #dc2626; }
.home-indicator-icon-warning { color: #b45309; }
.home-indicator-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: underline;
  margin-top: 4px;
}

/* YTD / MTD comparison widgets – blue title, large value, last period + percent (layout like reference image) */
.kpi-compare-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
}
.kpi-compare-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  min-width: 260px;
  flex: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.kpi-compare-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 8px;
}
.kpi-compare-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi-compare-value.is-negative {
  color: var(--error);
}
.kpi-compare-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-compare-pct {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.kpi-compare-pct.is-negative {
  color: var(--error);
}

.dropdown-wrap {
  position: relative;
  display: inline-block;
}
.dropdown-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 100;
  padding: 4px 0;
}
.dropdown-menu.is-open {
  display: block;
}
.dropdown-menu .dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
}
.dropdown-menu .dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Number inputs: right-align and select-all on focus */
.input-number {
  text-align: right;
}

/* Invoice line: description + grid of numbers (no horizontal scroll) */
.invoice-lines-table { width: 100%; table-layout: fixed; max-width: 100%; border-collapse: collapse; }
.invoice-lines-table thead, .invoice-lines-table tbody, .invoice-lines-table tfoot { display: table-row-group; }
.invoice-lines-table tr { display: table-row; }
.invoice-lines-table th, .invoice-lines-table td { display: table-cell; }
.invoice-lines-table .line-no-header { width: 28px; padding: 4px 6px; text-align: center; }
.invoice-lines-table .line-no-cell { width: 28px; padding: 4px 6px; text-align: center; vertical-align: top; font-size: 11px; color: var(--text-muted); }
.invoice-lines-table .line-desc-header { width: 26%; }
.invoice-lines-table .line-um-header { width: 90px; padding: 4px 6px; }
.invoice-lines-table .line-grid-header { width: calc(74% - 198px); }
.invoice-lines-table .line-desc-cell { width: 26%; vertical-align: top; }
.invoice-lines-table .line-um-cell { width: 90px; vertical-align: top; padding: 4px 6px; }
.invoice-lines-table .line-grid-cell { width: calc(74% - 198px); vertical-align: top; min-width: 0; }
.invoice-lines-table .line-actions-header { width: 40px; padding: 4px; }
.invoice-lines-table .line-actions-cell { width: 40px; padding: 4px; vertical-align: middle; }

.invoice-lines-table .line-grid-inner {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  align-items: stretch;
  min-width: 0;
}
.invoice-lines-table .line-grid-inner > * {
  min-width: 0;
  box-sizing: border-box;
  border-radius: 0;
  border-right-width: 0;
}
.invoice-lines-table .line-grid-inner > *:nth-child(1) { flex: 0 0 44px; }   /* VAT % */
.invoice-lines-table .line-grid-inner > *:nth-child(2) { flex: 0 0 96px; }   /* Qty */
.invoice-lines-table .line-grid-inner > *:nth-child(3) { flex: 0 0 92px; }   /* Unit price - fits 999,999,999.99 */
.invoice-lines-table .line-grid-inner > *:nth-child(4) { flex: 0 0 108px; }  /* Value (qty×price) */
.invoice-lines-table .line-grid-inner > *:nth-child(5) { flex: 0 0 108px; } /* VAT value */
.invoice-lines-table .line-grid-inner > *:last-child { border-right-width: 1px; }
.invoice-lines-table .line-grid-inner.line-grid-labels {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.invoice-lines-table .line-grid-inner.line-grid-labels span {
  text-align: right;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.invoice-lines-table .line-grid-inner .input-number,
.invoice-lines-table .line-grid-inner input[type="text"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: right;
  font-size: 11px;
}
.invoice-lines-table .line-grid-inner .cell-numeric {
  text-align: right;
  padding: 4px 6px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border: 1px solid #000000;
  background: var(--surface);
}

/* Match qty input: 1px solid black border, no radius, same padding */
.invoice-lines-table .invoice-line-textarea {
  width: 100%;
  min-height: 2em;
  max-height: 3.5em;
  resize: none;
  overflow: hidden;
  padding: 4px 6px;
  font-size: 11px;
  font-family: inherit;
  border: 1px solid #000000;
  border-radius: 0;
  background: var(--surface);
  box-sizing: border-box;
}
.invoice-lines-table .invoice-line-textarea:focus {
  outline: none;
  border-color: #000000;
}

.invoice-lines-table .invoice-line-um-select {
  width: 100%;
  min-width: 0;
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid #000000;
  border-radius: 0;
  background: var(--surface);
  box-sizing: border-box;
}
.invoice-lines-table .invoice-line-um-select:focus {
  outline: none;
  border-color: #000000;
}

.invoice-lines-table tbody tr.line-row td { font-weight: 600; }
.invoice-lines-table tbody tr.line-row .invoice-line-textarea,
.invoice-lines-table tbody tr.line-row .invoice-line-um-select,
.invoice-lines-table tbody tr.line-row .line-grid-inner input,
.invoice-lines-table tbody tr.line-row .line-grid-inner .cell-numeric { font-weight: 600; }

.invoice-lines-table tbody tr.line-row .invoice-line-textarea,
.invoice-lines-table tbody tr.line-row .invoice-line-um-select,
.invoice-lines-table tbody tr.line-row .line-grid-inner input,
.invoice-lines-table tbody tr.line-row .line-grid-inner .cell-numeric { border-color: #000000; }
.invoice-lines-table tbody tr.line-row .invoice-line-textarea:focus,
.invoice-lines-table tbody tr.line-row .invoice-line-um-select:focus,
.invoice-lines-table tbody tr.line-row .line-grid-inner input:focus { border-color: #000000; outline: none; }

.invoice-lines-table tfoot .line-desc-cell { vertical-align: middle; }
.invoice-lines-table tfoot .line-grid-inner.line-grid-inner--totals { align-items: center; }
.invoice-lines-table tfoot .line-grid-inner--totals .line-total-label { font-weight: 600; justify-self: end; text-align: right; display: flex; align-items: center; min-height: 28px; padding-right: 6px; box-sizing: border-box; }
.invoice-lines-table tfoot .line-grid-inner--totals .cell-numeric { font-weight: 600; }
.invoice-lines-table tfoot tr.invoice-lines-tfoot-row td { border-top: 2px solid #374151; }
.invoice-lines-table tfoot tr.invoice-lines-tfoot-row--grand td { font-weight: 700; border-top: none; }

/* Invoice form: compact layout */
.card--invoice { padding: 8px 12px; }
.invoice-form .invoice-form-section {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.invoice-form .invoice-form-section--lines { margin-top: 12px; margin-bottom: 6px; }
.invoice-form .invoice-form-grid { margin-bottom: 6px; gap: 6px; }
.invoice-form .form-row { margin-bottom: 4px; }
.invoice-form .invoice-form-input-narrow { max-width: 120px; }
.invoice-form .invoice-form-notes-wrap {
  border: 1px solid #000000;
  border-radius: var(--radius-sm);
  padding: 8px;
  margin-bottom: 8px;
}
.invoice-form .invoice-form-notes {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid #000000;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.invoice-form .invoice-form-lines-wrap { border-top: 2px solid #374151; padding-top: 8px; }
.invoice-form .invoice-form-date { width: 14ch; min-width: 14ch; max-width: 14ch; box-sizing: border-box; }
.invoice-form .invoice-form-status { width: 15ch; min-width: 15ch; max-width: 15ch; box-sizing: border-box; }
.invoice-form .invoice-form-add-line { margin-top: 8px; margin-bottom: 8px; }
.invoice-form .invoice-form-add-line .btn { font-weight: bold; }
.invoice-form .invoice-form-actions { margin-top: 12px; }
.card--invoice .invoice-lines-table th,
.card--invoice .invoice-lines-table td { padding: 2px 6px; }
.card--invoice .invoice-lines-table .invoice-line-textarea,
.card--invoice .invoice-lines-table .invoice-line-um-select {
  min-height: 2em;
  padding: 4px 6px;
  border: 1px solid #000000;
  border-radius: 0;
  background: var(--surface);
}
.card--invoice .invoice-lines-table .invoice-line-textarea {
  max-height: 3.5em;
}
.card--invoice .invoice-lines-table .line-grid-inner .cell-numeric { padding: 4px 6px; }
.card--invoice .invoice-lines-table .line-grid-inner.line-grid-labels span { padding: 0 6px; }

.table-wrap .actions .link-btn {
  padding: 2px 5px;
  font-size: 11px;
}

/* ========== Filter bar ========== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 0;
}
.filter-bar .form-row { margin-bottom: 0; }
.filter-bar label { margin-bottom: 2px; }
.filter-bar input,
.filter-bar select {
  min-width: 0;
  width: auto;
}
.filter-bar .filter-field { width: 120px; }
.filter-bar .filter-field-date { width: 110px; }

.contract-template-select {
  max-width: 130px;
  min-width: 80px;
  padding: 2px 6px;
  font-size: 11px;
}

/* Single line between filter / actions / list sections (border top + bottom) */
.section-divider {
  border: none;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  margin: 12px 0;
}

/* Hide mobile card views – desktop tables only */
.doc-cards,
.customer-cards {
  display: none !important;
}

/* ========== Charts ========== */
.chart-container {
  width: 100%;
  height: 240px;
  margin: 8px 0;
}

.chart-age-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  max-width: 720px;
}
.chart-age-bar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px 0;
}
.chart-age-bar-wrap canvas {
  width: 100% !important;
  height: 280px !important;
}

.chart-ytd-month-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  max-width: 640px;
}
.chart-ytd-month-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px 0;
}
.chart-ytd-month-wrap canvas {
  width: 100% !important;
  height: 260px !important;
}

/* ========== Home: add document form ========== */
.add-doc-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

/* ========== Login page (standalone, no sidebar) ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border);
  padding: 32px;
}

.login-title {
  margin: 0 0 24px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.02em;
}

.login-msg {
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 12px;
  border-radius: 6px;
}
.login-msg-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.login-msg-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.login-form .form-row { margin-bottom: 16px; }
.login-form .form-row:last-of-type { margin-bottom: 20px; }
.login-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #000000;
  border-radius: 6px;
  box-sizing: border-box;
}
.login-form input:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}
.login-card .btn-block {
  margin-top: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.login-create-tenant {
  margin: 20px 0 0;
  text-align: center;
  font-size: 13px;
}
.login-create-tenant a {
  color: var(--primary);
  text-decoration: none;
}
.login-create-tenant a:hover {
  text-decoration: underline;
}

.wizard-step.active {
  color: var(--text);
  font-weight: 600;
}

/* Wizard: same black border as rest of project */
.login-card.wizard-card {
  border: 1px solid #000000;
}
.wizard-card input[type="text"],
.wizard-card input[type="password"],
.wizard-card input[type="date"],
.wizard-card input[type="email"],
.wizard-card input[type="number"],
.wizard-card input[type="url"],
.wizard-card select,
.wizard-card textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #000000;
  border-radius: 6px;
  box-sizing: border-box;
}
.wizard-card input:focus,
.wizard-card select:focus,
.wizard-card textarea:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}

/* ========== Modal ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 20px;
  min-width: 320px;
  max-width: 100%;
}
.modal-box h3 {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.modal-box .modal-options {
  margin-bottom: 20px;
}
.modal-box .modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.modal-box .modal-option:last-child {
  margin-bottom: 0;
}
.modal-box .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-box--large {
  max-width: 560px;
  width: 100%;
}
.new-customer-modal-form input[type="text"],
.new-customer-modal-form input[type="email"],
.new-customer-modal-form input[type="number"],
.new-customer-modal-form input[type="password"],
.new-customer-modal-form input[type="url"],
.new-customer-modal-form select,
.new-customer-modal-form textarea {
  border: 1px solid #000000;
  border-radius: var(--radius);
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
.new-customer-modal-form input:focus,
.new-customer-modal-form select:focus,
.new-customer-modal-form textarea:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 1px #000000;
}
.new-customer-modal-form input[type="checkbox"] {
  border-radius: var(--radius-sm);
}
.modal-body-scroll {
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}
.invoice-form-customer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.invoice-form-customer-wrap select {
  flex: 1;
  min-width: 140px;
}
.invoice-form-new-customer-btn {
  flex-shrink: 0;
  margin: 6px 8px 6px 0;
  font-weight: bold;
}

.confirm-modal-message {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

/* Dual view: list + detail (e.g. contract alerts from menu) */
.dual-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
/* Make contract alerts list area wider so columns have more space */
.dual-view.contract-alerts-dual-view {
  grid-template-columns: 2fr 1.2fr;
}
@media (max-width: 900px) {
  .dual-view {
    grid-template-columns: 1fr;
  }
}
.dual-view-list { min-width: 0; }
.dual-view-detail {
  min-width: 0;
  position: sticky;
  top: 16px;
}
.alert-row {
  cursor: pointer;
}
.alert-row:hover {
  background: var(--primary-light);
}
.alert-row.selected {
  background: var(--primary-light);
  outline: 1px solid var(--primary);
  outline-offset: -1px;
}
.alert-detail-placeholder,
.alert-detail-panel {
  padding: 16px;
}
.alert-detail-placeholder .text-muted {
  color: var(--text-muted);
  margin: 0;
}
.alert-detail-title {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
}
.alert-detail-dl {
  margin: 0 0 16px 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 12px;
}
.alert-detail-dl dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}
.alert-detail-dl dd {
  margin: 0;
  word-break: break-word;
}
.alert-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
