/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a73e8;
  --orange: #e67e22;
  --red: #e74c3c;
  --green: #27ae60;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --border: #d0d0d0;
  --border-light: #e8e8e8;
  --text: #1a1a1a;
  --text-muted: #666;
  --text-light: #999;
  --row-hover: #eef4ff;
  --row-selected: #dbeafe;
  --row-selected-border: #1a73e8;
  --header-bg: #f0f0f2;
  --shadow: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Consolas', 'Monaco', monospace;
  --radius: 3px;
  --btn-h: 30px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.4;
}

/* Global input/select base styling — matches .field-row pattern */
select,
input[type="text"],
input[type="date"],
input[type="number"],
input[type="time"],
input[type="search"],
input[type="email"],
input[type="password"] {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 12px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.1s;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

/* ===== LAYOUT ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  background: #2c3e50;
  color: #fff;
  padding: 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.app-header h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.app-header .version {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.app-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: var(--btn-h);
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}

.btn:hover { background: #f0f0f0; border-color: #aaa; }
.btn:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
a.split-history-toggle:focus {
  outline: none;
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.25);
}
.btn:active { background: #e4e4e4; }

.btn-primary {
  background: var(--blue);
  border-color: #1557b0;
  color: #fff;
}
.btn-primary:hover { background: #1557b0; border-color: #0d47a1; }

.btn-danger {
  background: var(--red);
  border-color: #c0392b;
  color: #fff;
}
.btn-danger:hover { background: #c0392b; }

.btn-success {
  background: var(--green);
  border-color: #219a52;
  color: #fff;
}
.btn-success:hover { background: #219a52; }

.btn-sm {
  height: 24px;
  padding: 0 7px;
  font-size: 11px;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== MAIN WRAPPER ===== */
#main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Stable filter/search zone — never swapped by HTMX */
#stable-filters {
  flex-shrink: 0;
}

/* Swappable zone — replaced by HTMX on search/filter/select */
#swappable-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ===== MAIN SPLIT AREA ===== */
.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.list-pane {
  display: flex;
  flex-direction: column;
  width: 40%;
  min-width: 280px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* ===== LIST HEADER (column titles) ===== */
.list-header {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  background: var(--header-bg);
  border-bottom: 2px solid var(--border);
  border-left: 3px solid transparent;
  padding: 0;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.list-header-cell {
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-right: 1px solid var(--border-light);
  white-space: nowrap;
  overflow: hidden;
}

.list-header-cell:last-child { border-right: none; }

/* ===== LIST BODY ===== */
.list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* ===== LIST ROWS ===== */
.list-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}

.list-row:hover { background: var(--row-hover); }

.list-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

.list-row.main-client {
  background: var(--header-bg);
  font-weight: 600;
}

.list-row.main-client:hover { background: #e4e4e8; }
.list-row.main-client.selected { background: #c8d9f7; }

.list-row.sub-location .cell-name {
  padding-left: 28px;
}

.list-row, .tm-list-row, .contracts-list-row,
.ws-tm-row, .ws-job-row,
.pr-tm-row, .pr-job-row, .pr-element-row,
.sl-client-row, .sl-invoice-row,
.bi-location-row, .ie-contracts-row, .ie-jobs-row,
.km-key-row, .km-acc-row,
.xsl-client-row, .xsl-transaction-row,
.schedule-row {
  user-select: none;
}

.cell {
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid var(--border-light);
  font-size: 12px;
  display: flex;
  align-items: center;
}

.cell:last-child { border-right: none; }

.cell-idx {
  color: var(--text-light);
  font-size: 11px;
  justify-content: center;
}

/* Status colours */
.status-active { color: var(--blue); }
.status-hold { color: var(--orange); }
.status-inactive { color: var(--red); }

/* Type badges */
.type-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 600;
  background: #e8e8e8;
  color: #555;
}
.type-badge.commercial { background: #dbeafe; color: #1e40af; }
.type-badge.domestic { background: #dcfce7; color: #166534; }
.type-badge.holiday { background: #fef9c3; color: #854d0e; }

/* Sub-location indicator */
.sub-arrow {
  color: var(--text-light);
  font-size: 10px;
  margin-right: 4px;
}

/* ===== DETAIL PANEL ===== */
.detail-panel {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.detail-panel h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text);
}

.detail-panel .detail-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 3px 10px;
  font-size: 12px;
}

.detail-label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  color: var(--text);
}

.detail-contacts {
  margin-top: 12px;
}

.detail-contacts h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.contact-preview-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  padding: 2px 0;
  border-bottom: 1px solid var(--border-light);
}

.contact-preview-type {
  width: 75px;
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.contact-preview-detail { color: var(--text); }
.contact-preview-name { color: var(--text-muted); margin-left: auto; font-style: italic; }

/* Empty state */
.empty-detail {
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* ===== EDIT PANEL (fills right pane) ===== */
.edit-panel {
  width: 100%;
  background: var(--surface);
  border-top: 2px solid var(--blue);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.edit-panel-header {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--blue);
  color: #fff;
  flex-shrink: 0;
}

.edit-panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

/* The <form> inside .edit-panel must participate in the flex layout
   so the height chain reaches .edit-panel-body for scrolling */
.edit-panel > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.edit-panel-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 12px 14px;
}

.edit-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--header-bg);
}

/* ===== FORM SECTIONS ===== */
.form-section {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.form-section-title {
  background: var(--header-bg);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.form-section-body {
  padding: 10px;
}

/* ===== FORM FIELDS ===== */
.field-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.field-row label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

.field-row input,
.field-row select,
.field-row textarea {
  height: 26px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  transition: border-color 0.1s;
}

.field-row input:focus,
.field-row select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.field-row input:disabled,
.field-row select:disabled {
  background: #f5f5f5;
  color: var(--text-muted);
  cursor: not-allowed;
}

.field-row.field-2col {
  grid-template-columns: 110px 1fr 1fr;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  padding-left: 116px;
}

.field-checkbox input[type=checkbox] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.field-checkbox label {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

/* ===== CONTACTS SUB-TABLE ===== */
.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.contacts-table th {
  background: var(--header-bg);
  padding: 4px 6px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.contacts-table td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.contacts-table input,
.contacts-table select {
  height: 24px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 11px;
  width: 100%;
  font-family: var(--font);
}

.contacts-table input:focus,
.contacts-table select:focus {
  outline: none;
  border-color: var(--blue);
}

.contacts-table tr.email-inv-empty td { background: #fff0f0; }

.contacts-table tr:hover td { background: var(--row-hover); }

/* ===== FEEDBACK MESSAGE ===== */
.save-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--green);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
  animation: fadeout 3s forwards;
}

@keyframes fadeout {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.filter-bar label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-bar select,
.toolbar select {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--surface);
  cursor: pointer;
}

.filter-bar select:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.filter-bar .toggle-inactive {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.filter-bar .toggle-inactive input { cursor: pointer; }

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ===== STATUS BADGE ===== */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.active { background: #dbeafe; color: var(--blue); }
.status-badge.hold { background: #fef3c7; color: var(--orange); }
.status-badge.inactive { background: #fee2e2; color: var(--red); }

/* ===== REF DISPLAY ===== */
.ref-code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 2px;
  border: 1px solid var(--border-light);
  justify-self: start;
}

/* ===== UTILITIES ===== */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11px; }
.hidden { display: none !important; }

/* ===== CONFIRM DELETE ===== */
.confirm-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ===== HTMX INDICATORS ===== */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

/* ===== RIGHT PANE WRAPPER ===== */
.right-pane-inner {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 300px;
  max-width: 300px;
}

.search-input-wrap input[type="search"] {
  width: 100%;
  height: 26px;
  padding: 2px 28px 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.1s;
  /* hide native clear button */
  -webkit-appearance: none;
  appearance: none;
}

.search-input-wrap input[type="search"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

/* hide native clear button in Chrome/Edge */
.search-input-wrap input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  color: var(--text);
  background: var(--border-light);
}

.search-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  width: 100%;
  max-width: 380px;
  padding: 0 16px;
}

.login-header {
  background: #2c3e50;
  color: #fff;
  padding: 16px 24px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.login-header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.login-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-md);
}

.login-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
}

.login-error {
  background: #fdf0ef;
  border: 1px solid #f5c6c2;
  color: var(--red);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 16px;
}

.login-field {
  margin-bottom: 14px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.login-field input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.login-btn {
  width: 100%;
  height: 36px;
  margin-top: 8px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-btn:hover {
  background: #1558b0;
}

/* ===== HEADER USER / LOGOUT ===== */
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-username {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.logout-btn {
  height: 24px;
  padding: 0 10px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* ===== EDIT OVERLAY PANEL ===== */
#edit-overlay {
  position: fixed;
  top: 40px;          /* below .app-nav */
  right: 0;
  bottom: 0;
  left: 40%;          /* covers right 60% of screen */
  z-index: 500;
  display: none;       /* shown via JS */
  flex-direction: column;
  background: var(--surface);
  box-shadow: -4px 0 16px rgba(0,0,0,0.18);
  border-left: 2px solid var(--blue);
}

#edit-overlay-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Subtle backdrop to dim the area under the overlay */
#edit-overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.12);
  z-index: 499;
  display: none;
}

/* ===== TOP NAVIGATION BAR ===== */
.app-nav {
  background: #2c3e50;
  color: #fff;
  height: 40px;
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 100;
}

.nav-logo {
  display: flex;
  align-items: center;
  padding: 0 12px 0 10px;
  border-right: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}

.nav-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.nav-version {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  margin-left: auto;
  margin-right: 12px;
  white-space: nowrap;
  align-self: center;
}

.nav-menu {
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: stretch;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  padding: 0 12px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.82);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}

.nav-btn:hover,
.nav-item:hover > .nav-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-btn-active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-bottom: 2px solid var(--blue);
}

.nav-arrow {
  font-size: 8px;
  opacity: 0.6;
  margin-top: 1px;
}

/* Dropdown */
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #2c3e50;
  border: 1px solid rgba(255,255,255,0.15);
  border-top: 2px solid var(--blue);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 200;
}

/* x-cloak hides alpine elements before init */
[x-cloak] { display: none !important; }

.nav-dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 12.5px;
  font-family: var(--font);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.nav-dd-item:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-dd-active {
  background: rgba(26,115,232,0.2);
  color: #7ab8ff;
  border-left: 3px solid var(--blue);
  padding-left: 11px;
}

.nav-dd-active:hover {
  background: rgba(26,115,232,0.3);
  color: #a0ccff;
}

.nav-shortcut {
  font-size: 10px;
  color: rgba(255,255,255,0.38);
  font-family: var(--font-mono);
  margin-left: 16px;
  flex-shrink: 0;
}

/* User area on right */
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  margin-left: auto;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.12);
}

/* ===== PLACEHOLDER PAGE ===== */
.placeholder-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
  padding: 48px 24px;
  background: var(--bg);
  overflow-y: auto;
}

.placeholder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 36px 40px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.placeholder-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.placeholder-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.2;
}

.placeholder-shortcut {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.placeholder-shortcut-label {
  font-size: 12px;
  color: var(--text-muted);
}

.placeholder-kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--header-bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}

.placeholder-notice {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}

.placeholder-notice-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
}

.placeholder-notice strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.placeholder-notice p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Ensure .app-body fills remaining height below nav */
.app-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ===== TEAM MEMBERS WINDOW ===== */

/* TM list row — 4 column grid override via inline style */
.tm-list-row {
  display: grid;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.08s;
}

.tm-list-row:hover { background: var(--row-hover); }

.tm-list-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}


/* TM detail panel — full-height scrollable */
.tm-detail-panel {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}

.tm-detail-panel h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text);
}

/* TM detail sections with grouped borders */
.tm-detail-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.tm-detail-section-title {
  background: var(--header-bg);
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.tm-detail-section-body {
  padding: 8px 10px;
}

/* Flag badges (boolean fields shown as inline labels) */
.tm-flag-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.tm-flag-active  { background: #dcfce7; color: #166534; }
.tm-flag-warning { background: #fef3c7; color: #92400e; }
.tm-flag-info    { background: #dbeafe; color: #1e40af; }

/* ===== TEAM MEMBER EDIT FORM — Phase 2 ===== */

/* Two-column layout for paired fields inside form sections */
.tm-edit-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* Attributes checkbox grid — 2 columns, scrollable if many */
.tm-attributes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  max-height: 200px;
  overflow-y: auto;
}

/* Individual attribute / flag checkbox label */
.tm-attribute-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
}

.tm-attribute-checkbox input[type=checkbox] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== CONTRACT/JOB EDIT FORM — scoped input styles ===== */
/* Covers inputs inside inline flex rows that lack .field-row parent */
#contract-job-form input,
#contract-job-form select,
#contract-job-form textarea {
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  height: 26px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.1s;
}

#contract-job-form input[type=checkbox] {
  height: auto;
  padding: 0;
  width: 14px;
  border: none;
  background: none;
}

#contract-job-form textarea {
  height: auto;
}

#contract-job-form input:focus,
#contract-job-form select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

/* ===== CONTRACTS & JOBS SECTION (inside location detail panel) ===== */

.contracts-section {
  margin-top: 14px;
}

/* Column header for contracts list — 10 columns */
.contracts-list-header {
  display: grid;
  grid-template-columns: 75px 75px 180px 120px 35px 50px 45px 140px 80px 80px;
}

/* Contracts list body — max height, scrollable */
.contracts-list-body {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-top: none;
}

/* List row for contracts — 10 columns matching header */
.contracts-list-row {
  display: grid;
  grid-template-columns: 75px 75px 180px 120px 35px 50px 45px 140px 80px 80px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}

.contracts-list-row:hover { background: var(--row-hover); }

.contracts-list-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Ended/inactive jobs — muted text */
.contracts-list-row.job-ended .cell {
  color: var(--text-muted);
}

/* ===== WORKSHEETS WINDOW ===== */

/* Main wrapper fills height below nav */
#ws-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Two-pane area below toolbar */
.ws-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left pane: TM list (~25% width) */
.ws-tm-pane {
  display: flex;
  flex-direction: column;
  width: 28%;
  min-width: 260px;
  max-width: 340px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

/* TM search bar at top of left pane */
.ws-tm-search-bar {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  flex-shrink: 0;
}

/* TM list header — name + Updated + Sent columns */
.ws-tm-list-header {
  display: grid !important;
  grid-template-columns: 1fr 68px 80px;
}
.ws-tm-hdr-date {
  font-size: 11px;
  justify-content: flex-end;
  text-align: right;
}

/* Right pane: job list (~75%) */
.ws-job-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* TM row — name + Updated + Sent columns */
.ws-tm-row {
  display: grid;
  grid-template-columns: 1fr 68px 80px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.ws-tm-row > .cell {
  padding: 2px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ws-tm-row-alt { background: var(--row-alt, #f7f7f7); }
.ws-tm-row:hover { background: var(--row-hover); }

.ws-tm-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Name cell */
.ws-tm-cell-name {
  font-size: 12px;
}

/* Date cells — right-aligned, smaller font */
.ws-tm-cell-date {
  font-size: 11px;
  color: var(--text-muted);
  justify-content: flex-end;
  text-align: right;
}

/* Inactive TM name — red */
.ws-tm-inactive {
  color: var(--red);
}

/* TM needs attention — red text on name */
.ws-tm-needs-attention {
  color: var(--red);
}

/* Sent column highlighted when worksheet changed since last email */
.ws-tm-sent-attention {
  background: #f5b7b1;
}

/* TM list clash detection — Updated cell background colours */
.ws-tm-clash-job { background: #f5b7b1; color: #ffffff; }
.ws-tm-clash-absence-overlap { background: #ffe0b2; }
.ws-tm-clash-keys { background: #f8d7da; }
.ws-tm-clash-absence { background: #d6eaf8; }
.ws-tm-clash-absence-bh { background: #aed6f1; }
.ws-tm-clash-adjacent { background: #fff3cd; }

/* Job list inner container — fills right pane, flex column */
#ws-job-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ws-job-list-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Top bar: TM name + week label + total hours */
.ws-job-list-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ws-tm-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.ws-week-label {
  font-size: 12px;
  color: var(--text-muted);
}

.ws-total-hours {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
}

/* Job list column header */
.ws-job-list-header {
  display: flex !important;
  background: var(--header-bg);
  border-bottom: 2px solid var(--border);
  border-left: 3px solid transparent;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* Job list scrollable body */
.ws-job-list-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  min-height: 0;
}

/* Job row */
.ws-job-row {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.08s;
}
.ws-job-row > .cell {
  padding: 2px 5px;
}

.ws-job-row:hover { background: var(--row-hover); }

.ws-job-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Absence client cell (applied to Client Name cell only, not the whole row) */
.ws-absence-row {
  background: #d6eaf8;
}

.ws-absence-row:hover { background: #c3ddf0; }

.ws-absence-row-bh {
  background: #aed6f1;
}

.ws-absence-row-bh:hover { background: #9dc8e3; }

/* Day separator row */
.ws-day-separator {
    height: auto;
    padding: 2px 8px;
    line-height: 1.4;
    font-size: 13px;
    background: var(--header-bg, #f0f0f2);
    margin: 0;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

/* Time collision coloring */
.ws-time-overlap {
  background: #f5b7b1 !important;
  color: #ffffff !important;
  font-weight: 600;
}

.ws-time-adjacent {
  background: #fff3cd !important;
}

.ws-time-absence-overlap {
  background: #ffe0b2 !important;
}

.ws-keys-get {
  background: #f8d7da;
}

/* ===== COMPLETION PAGE ===== */

/* Main wrapper — full height flex column below toolbar */
#cmp-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Single-pane area — full width */
.cmp-main-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Two-row header wrapper */
.cmp-job-list-header-wrapper {
  flex-shrink: 0;
  border-bottom: 2px solid var(--border);
}

/* Group header row (row 1 — "Scheduled" / "Worked" labels) */
.cmp-header-group-row {
  background: var(--header-bg);
  font-size: 12px;
  padding: 0;
}

/* Sub-header row (row 2 — individual column names) */
.cmp-header-sub-row {
  background: var(--header-bg);
  font-size: 12px;
  padding: 0;
}

/* Scrollable body */
.cmp-job-list-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  min-height: 0;
}

/* Job row — 20-column grid matching Omnis layout */
.cmp-job-row {
  display: grid;
  grid-template-columns: 200px 130px 62px 35px 130px 75px 45px 75px 50px 50px 55px 47px 50px 50px 55px 55px 62px 55px 55px 1fr;
  border-bottom: 1px solid #94a3b8;
  border-left: 3px solid transparent;
  font-size: 12px;
}

/* Totals display in toolbar */
.cmp-totals {
  font-size: 12px;
  color: var(--text);
  padding: 0 6px;
  white-space: nowrap;
}

.cmp-job-row:hover { background: var(--row-hover); }

/* Completed row — light green tint */
.cmp-job-row.complete {
  background: #f0fdf4;
}

.cmp-job-row.complete:hover { background: #dcfce7; }

/* Actual hours cells — slightly different shade to distinguish from scheduled */
.cmp-act-cell {
  color: #1a73e8;
}

/* Variance cell — positive green, negative red */
.cmp-variance-cell {
  font-weight: normal;
}

/* Status filter button group */
.cmp-filter-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cmp-filter-btn {
  height: 24px;
  padding: 0 10px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}

.cmp-filter-btn:last-child { border-right: none; }

.cmp-filter-btn:hover { background: #f0f0f0; }

.cmp-filter-btn.active {
  background: var(--blue);
  color: #fff;
}

.cmp-filter-btn.active:hover { background: #1557b0; }

/* Status column — solid color cell (full cell background, white text) */
.cmp-status-pending {
  background: #d97706;
  color: white;
  font-weight: 600;
  text-align: center;
}

.cmp-status-complete {
  background: #16a34a;
  color: white;
  font-weight: 600;
  text-align: center;
}

/* Yellow highlight for worked cells that differ from scheduled */
.cmp-highlight {
  background: #fef08a !important;
}

/* Group header divider — right border on group label cells */
.cmp-group-divider {
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}

/* Multi-TM group borders — lighter within-group separator, normal border at group end */
.cmp-group-first,
.cmp-group-mid {
  border-bottom: 1px solid #e2e8f0;
}

/* Pending row — subtle yellow tint */
.cmp-job-row:not(.complete) {
  background: #fffdf0;
}

.cmp-job-row:not(.complete):hover {
  background: #fef9c3;
}

/* Selected row — blue highlight overrides status tints */
.cmp-job-row.cmp-row-selected {
  background: #dbeafe !important;
  border-left-color: var(--blue) !important;
}

.cmp-job-row.cmp-row-selected:hover {
  background: #bfdbfe !important;
}

/* Split job info-line — non-interactive context row, no background change */
.cmp-job-row.cmp-info-line {
  cursor: default !important;
}

.cmp-job-row.cmp-info-line:hover {
  background: inherit !important;
}

/* Grey text only on middle columns (cols 5-16: TM name through Worked Variance).
   Cols 1-4 (client, contract, job hrs, TMs) will be blank due to continuation.
   Cols 17-20 (Con Hrs, Wk Hrs, Job Total, Notes) must remain normal. */
.cmp-job-row.cmp-info-line .cell:nth-child(5),
.cmp-job-row.cmp-info-line .cell:nth-child(6),
.cmp-job-row.cmp-info-line .cell:nth-child(7),
.cmp-job-row.cmp-info-line .cell:nth-child(8),
.cmp-job-row.cmp-info-line .cell:nth-child(9),
.cmp-job-row.cmp-info-line .cell:nth-child(10),
.cmp-job-row.cmp-info-line .cell:nth-child(11),
.cmp-job-row.cmp-info-line .cell:nth-child(12),
.cmp-job-row.cmp-info-line .cell:nth-child(13),
.cmp-job-row.cmp-info-line .cell:nth-child(14),
.cmp-job-row.cmp-info-line .cell:nth-child(15),
.cmp-job-row.cmp-info-line .cell:nth-child(16) {
  color: #aaa !important;
}

/* cmp-highlight yellow must not appear on info-line cells */
.cmp-job-row.cmp-info-line .cell.cmp-highlight {
  background: transparent !important;
}

/* Info-line status cell — suppress solid amber/green badge colouring */
.cmp-job-row.cmp-info-line .cmp-status-pending,
.cmp-job-row.cmp-info-line .cmp-status-complete {
  background: transparent !important;
  color: #aaa !important;
  font-weight: normal !important;
}

/* Info-line actual-hours cells — suppress blue colour */
.cmp-job-row.cmp-info-line .cmp-act-cell {
  color: #aaa !important;
}

/* Action button group — separator + buttons to the right of filter group */
.cmp-action-group {
  display: inline-flex;
  gap: 6px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.cmp-action-btn {
  height: 24px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, opacity 0.1s;
}

.cmp-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Complete button — green */
.cmp-complete-btn {
  background: #16a34a;
  color: #fff;
  border: 1px solid #15803d;
}

.cmp-complete-btn:not(:disabled):hover {
  background: #15803d;
}

/* Un-Complete button — outline grey */
.cmp-uncomplete-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.cmp-uncomplete-btn:not(:disabled):hover {
  background: #f0f0f0;
}

/* Error toast — prominent red banner, centered */
.cmp-error-toast {
  background: #dc2626 !important;
  color: #fff !important;
  font-size: 14px !important;
  padding: 12px 28px !important;
  border-radius: 6px !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  top: 50% !important;
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35) !important;
  z-index: 9999 !important;
  animation: cmpErrorFade 5s forwards !important;
}

@keyframes cmpErrorFade {
  0%   { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== AMEND OVERLAY (completion window) ===== */
#amend-overlay {
  position: fixed;
  top: 40px;          /* below .app-nav */
  right: 0;
  bottom: 0;
  left: 35%;          /* covers right 65% of screen */
  z-index: 600;
  display: none;       /* shown via JS — flex when open */
  flex-direction: column;
  background: var(--surface);
  box-shadow: -4px 0 20px rgba(0,0,0,0.22);
  border-left: 2px solid var(--blue);
}

#amend-overlay-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#amend-overlay-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.15);
  z-index: 599;
  display: none;
}

/* Amend button in completion toolbar */
.cmp-amend-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.cmp-amend-btn:not(:disabled):hover {
  background: #f0f0f0;
}

.cmp-amend-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Disabled section style for TBA payroll */
.amend-section-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* Error display inside amendment form */
.amend-form-errors {
  color: #dc2626;
  font-size: 12px;
  padding: 6px 10px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  margin-bottom: 8px;
}

/* ===== AMENDMENT FORM — OMNIS-MATCH STYLES ===== */

/* Yellow editable fields — Omnis convention */
.amend-input-editable {
  background-color: #FFFFCC !important;
  height: 26px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  color: var(--text);
  font-weight: normal;
  transition: border-color 0.1s;
  min-width: 0;       /* allow grid items to shrink below intrinsic content size */
  width: 100%;        /* fill grid cell */
  box-sizing: border-box;
}
.amend-input-editable:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}
.amend-input-editable:disabled {
  background-color: #f5f5f5 !important;
  color: var(--text-muted);
  opacity: 0.6;
  cursor: not-allowed;
}

/* Read-only reference fields — greyed out, non-interactive.
   Always used together with amend-input-editable (which provides all base styles). */
.amend-input-readonly {
  background-color: #e8e8e8 !important;
  cursor: default;
}

/* Right-justify numeric/time readonly fields */
.amend-input-numeric {
  text-align: right;
}

/* Right-justify editable time and number fields */
.amend-input-editable[type="time"],
.amend-input-editable[type="number"] {
  text-align: right;
}

/* Payroll hours field: color set transparent via Alpine x-init when empty (see _amendment_form.html) */

/* Section legend with default behaviour hint */
.amend-section-legend {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  background: #f5f0d8 !important;  /* subtle olive/yellow tint to match Omnis */
  color: var(--text) !important;
}
.amend-section-hint {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #6b6020;
}

/* Complete-job checkbox box in footer — distinct background */
.amend-complete-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff8cc;
  border: 1px solid #e6c84a;
  border-radius: var(--radius);
  padding: 4px 12px;
}

/* ===== SIBLING JOB MINI TABLE ===== */
.amend-sibling-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
  table-layout: fixed;
}

.amend-sibling-table th,
.amend-sibling-table td {
  padding: 2px 6px;
  border: 1px solid var(--border);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Column widths — col 1-16 map to table columns */
.amend-sibling-table col:nth-child(1)  { width: 150px; } /* Team Member */
.amend-sibling-table col:nth-child(2)  { width: 65px; }  /* Status */
.amend-sibling-table col:nth-child(3)  { width: 42px; }  /* Day */
.amend-sibling-table col:nth-child(4)  { width: 75px; }  /* Date */
.amend-sibling-table col:nth-child(5)  { width: 48px; }  /* Sched Start */
.amend-sibling-table col:nth-child(6)  { width: 48px; }  /* Sched End */
.amend-sibling-table col:nth-child(7)  { width: 48px; }  /* Sched Hrs */
.amend-sibling-table col:nth-child(8)  { width: 42px; }  /* Rec */
.amend-sibling-table col:nth-child(9)  { width: 48px; }  /* Worked Start */
.amend-sibling-table col:nth-child(10) { width: 48px; }  /* Worked End */
.amend-sibling-table col:nth-child(11) { width: 48px; }  /* Worked Hrs */
.amend-sibling-table col:nth-child(12) { width: 50px; }  /* +/- */
.amend-sibling-table col:nth-child(13) { width: 60px; }  /* Con Hrs */
.amend-sibling-table col:nth-child(14) { width: 60px; }  /* Wk Hrs */
.amend-sibling-table col:nth-child(15) { width: 50px; }  /* +/- total */
.amend-sibling-table col:nth-child(16) { width: auto; }  /* Notes — takes remaining space */

/* Column text alignment — th (hdr2) and td data cells */
.amend-sibling-table th:nth-child(1),
.amend-sibling-table td:nth-child(1),
.amend-sibling-table th:nth-child(2),
.amend-sibling-table td:nth-child(2),
.amend-sibling-table th:nth-child(3),
.amend-sibling-table td:nth-child(3),
.amend-sibling-table th:nth-child(8),
.amend-sibling-table td:nth-child(8),
.amend-sibling-table th:nth-child(16),
.amend-sibling-table td:nth-child(16) {
  text-align: left;
}
/* Right-justify time/numeric columns: Date(4), Start(5), End(6), Hrs(7), Start(9), End(10), Hrs(11), +/-(12), Con Hrs(13), Wk Hrs(14), +/-(15) */
.amend-sibling-table th:nth-child(4),
.amend-sibling-table td:nth-child(4),
.amend-sibling-table th:nth-child(5),
.amend-sibling-table td:nth-child(5),
.amend-sibling-table th:nth-child(6),
.amend-sibling-table td:nth-child(6),
.amend-sibling-table th:nth-child(7),
.amend-sibling-table td:nth-child(7),
.amend-sibling-table th:nth-child(9),
.amend-sibling-table td:nth-child(9),
.amend-sibling-table th:nth-child(10),
.amend-sibling-table td:nth-child(10),
.amend-sibling-table th:nth-child(11),
.amend-sibling-table td:nth-child(11),
.amend-sibling-table th:nth-child(12),
.amend-sibling-table td:nth-child(12),
.amend-sibling-table th:nth-child(13),
.amend-sibling-table td:nth-child(13),
.amend-sibling-table th:nth-child(14),
.amend-sibling-table td:nth-child(14),
.amend-sibling-table th:nth-child(15),
.amend-sibling-table td:nth-child(15) {
  text-align: right;
}

.amend-sibling-hdr1 th,
.amend-sibling-hdr2 th {
  background: var(--header-bg);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Group header cells — top header row */
.amend-sibling-group-hdr {
  text-align: left !important;
  border-bottom: none;
}
.amend-sibling-job-hdr {
  background: #e8eef8 !important;
}

/* Data rows */
.amend-sibling-row td {
  font-size: 11px;
  color: var(--text);
}
.amend-sibling-row:hover td {
  background: #f5f5f5;
}

/* Highlighted row — current TM being amended */
.amend-sibling-current td {
  background: #dbeafe !important;  /* light blue */
  font-weight: 600;
}
.amend-sibling-current:hover td {
  background: #bfdbfe !important;
}

/* Status badges */
.amend-sibling-status {
  display: inline-block;
  padding: 0 5px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 600;
}
.amend-sibling-complete {
  background: #d1fae5;
  color: #065f46;
}
.amend-sibling-pending {
  background: #dbeafe;
  color: #1e40af;
}

/* Variance colour coding */
.amend-variance-neg {
  color: #dc2626;
  font-weight: 600;
}
.amend-variance-pos {
  color: #16a34a;
  font-weight: 600;
}

/* ===== STATUS FILTER DROPDOWN ===== */
.cmp-filter-select {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.cmp-filter-select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ===== TOTALS COUNT COLOURS ===== */
.cmp-count-pending {
  color: #b45309;  /* amber-700 — readable on white, matches pending badge hue */
  font-weight: 600;
}
.cmp-count-complete {
  color: #16a34a;  /* green-600 — matches complete badge */
  font-weight: 600;
}

/* ===== CONFIRM MODAL (replaces browser confirm()) ===== */
.cmp-confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 900;
  align-items: center;
  justify-content: center;
}
.cmp-confirm-dialog {
  background: var(--surface);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.30);
  padding: 24px 28px 20px;
  min-width: 340px;
  max-width: 460px;
  font-family: var(--font);
  border-top: 3px solid var(--blue);
}
.cmp-confirm-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.cmp-confirm-msg {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}
.cmp-confirm-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.cmp-confirm-yes {
  height: 28px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  border: 1px solid #1557b0;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.cmp-confirm-yes:hover { background: #1557b0; }
.cmp-confirm-yes.cmp-confirm-yes-green {
  background: #16a34a;
  border-color: #15803d;
}
.cmp-confirm-yes.cmp-confirm-yes-green:hover { background: #15803d; }
.cmp-confirm-yes.cmp-confirm-danger {
  background: #dc2626;
  border-color: #b91c1c;
}
.cmp-confirm-yes.cmp-confirm-danger:hover { background: #b91c1c; }
.cmp-confirm-cancel {
  height: 28px;
  padding: 0 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.cmp-confirm-cancel:hover { background: #f0f0f0; }

/* ===== TBA (UNALLOCATED) SECTION ===== */

/* TBA list body: height controlled by Alpine wrapper on #ws-tba-list */
.ws-tba-list-body {
  scrollbar-gutter: stable;
}

/* TBA day separator: half-height version of ws-day-separator */
.ws-tba-day-separator {
  height: auto;
  padding: 1px 8px;
  line-height: 1.4;
  font-size: 13px;
  background: var(--header-bg, #f0f0f2);
  margin: 0;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
}

/* ===== PAYROLL WINDOW ===== */

#pr-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.pr-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left pane: TM list (280px fixed) */
.pr-tm-pane {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.pr-tm-search-bar {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  flex-shrink: 0;
}

/* TM list header — 4 columns */
.pr-tm-list-header {
  display: grid !important;
  grid-template-columns: 60px 1fr 24px 24px;
}
.pr-tm-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* TM row — 4 columns */
.pr-tm-row {
  display: grid;
  grid-template-columns: 60px 1fr 24px 24px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.pr-tm-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pr-tm-row:hover { background: var(--row-hover); }
.pr-tm-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Right pane */
.pr-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* Job section (~60%) */
.pr-job-section {
  flex: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#pr-job-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Job list header — 14 columns */
.pr-job-list-header {
  display: grid !important;
  grid-template-columns: 24px 24px 250px 70px 90px 100px 60px 60px 60px 70px 70px 140px 140px 140px;
}
.pr-job-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Job row — 14 columns */
.pr-job-row {
  display: grid;
  grid-template-columns: 24px 24px 250px 70px 90px 100px 60px 60px 60px 70px 70px 140px 140px 140px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.pr-job-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-job-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* Elements section (~40%) */
.pr-elements-section {
  flex: 4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border-top: 2px solid var(--border);
}

.pr-elements-header-bar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#pr-pay-elements {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Pay Elements header — 4 columns */
.pr-elements-list-header {
  display: grid !important;
  grid-template-columns: 200px 80px 80px 1fr;
}
.pr-elements-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Pay Element row — 4 columns */
.pr-element-row {
  display: grid;
  grid-template-columns: 200px 80px 80px 1fr;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
}
.pr-element-row:hover { background: var(--row-hover); cursor: pointer; }
.pr-element-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}
.pr-element-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-elements-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* C/P status flags — small colored squares */
.pr-flag {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.pr-flag-green { background: var(--green); }
.pr-flag-red { background: var(--red); }

/* TM list clash colouring (Omnis Proc 102/112) */
.pr-clash-red { background-color: #f8d7da; }
.pr-clash-red:hover { background-color: #f1c0c5; }
.pr-clash-yellow { background-color: #fff3cd; }
.pr-clash-yellow:hover { background-color: #ffe9a0; }
.pr-clash-orange { background-color: #ffe0b2; }
.pr-clash-orange:hover { background-color: #ffd08a; }

/* Day spacer — same height as a data row, empty divider between days */
.pr-day-spacer {
  display: block;
  height: 22px;
  border-bottom: none;
  border-left: 3px solid transparent;
  background: var(--bg);
  pointer-events: none;
}

/* Job row hover + selection */
.pr-job-row:hover { background: var(--row-hover); cursor: pointer; }
.pr-job-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Absence rows in job list */
.pr-absence-row {
  background-color: #fef3e2;
}
.pr-absence-row:hover { cursor: default; }
.pr-absence-row.selected {
  background-color: #fef3e2;
  border-left: 3px solid transparent;
}

/* Truncatable text cells */
.pr-cell-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Bottom bar */
.pr-bottom-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== SALES LEDGER WINDOW ===== */

#sl-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sl-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left pane: Client list (280px fixed) */
.sl-client-pane {
  display: flex;
  flex-direction: column;
  width: 360px;
  min-width: 360px;
  max-width: 360px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.sl-client-search-bar {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  flex-shrink: 0;
}

/* Client list header — 2 columns */
.sl-client-list-header {
  display: grid !important;
  grid-template-columns: 1fr 100px;
}
.sl-client-list-header > .list-header-cell {
  padding: 2px 4px;
}

/* Client row — 2 columns */
.sl-client-row {
  display: grid;
  grid-template-columns: 1fr 100px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.sl-client-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sl-client-row:hover { background: var(--row-hover); }
.sl-client-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Right pane */
.sl-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* Invoice section (~60%) */
.sl-invoice-section {
  flex: 6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#sl-invoice-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Client info header bar */
.sl-client-info-bar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
}

/* Invoice list header — 8 columns */
.sl-invoice-list-header {
  display: grid !important;
  grid-template-columns: 100px 60px 100px 100px 100px 100px 100px 1fr;
}
.sl-invoice-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Invoice row — 8 columns */
.sl-invoice-row {
  display: grid;
  grid-template-columns: 100px 60px 100px 100px 100px 100px 100px 1fr;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.sl-invoice-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sl-invoice-row:hover { background: var(--row-hover); }
.sl-invoice-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

.sl-invoice-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* Summary/totals row at bottom of invoice list */
.sl-summary-row {
  display: grid;
  grid-template-columns: 100px 60px 100px 100px 100px 100px 100px 1fr;
  border-top: 2px solid var(--border);
  background: var(--header-bg);
  border-left: 3px solid transparent;
  flex-shrink: 0;
}
.sl-summary-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
}

/* Items section (~40%) */
.sl-items-section {
  flex: 4;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border-top: 2px solid var(--border);
}

.sl-items-header-bar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sl-invoice-items {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Invoice items header — 6 columns */
.sl-items-list-header {
  display: grid !important;
  grid-template-columns: 40px 1fr 80px 100px 100px 100px;
}
.sl-items-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Invoice item row — 6 columns */
.sl-item-row {
  display: grid;
  grid-template-columns: 40px 1fr 80px 100px 100px 100px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
}
.sl-item-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sl-items-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* Items totals row */
.sl-items-totals-row {
  display: grid;
  grid-template-columns: 40px 1fr 80px 100px 100px 100px;
  border-top: 2px solid var(--border);
  background: var(--header-bg);
  border-left: 3px solid transparent;
  flex-shrink: 0;
}
.sl-items-totals-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
}

/* Truncatable text cells */
.sl-cell-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ===========================================================================
   BATCH INVOICING (bi- prefix)
   =========================================================================== */

#bi-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.bi-list-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Header — 9 columns */
.bi-location-list-header {
  display: grid !important;
  grid-template-columns: 1fr 200px 60px 60px 70px 70px 100px 80px 100px;
}
.bi-location-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Location row — same 9 columns */
.bi-location-row {
  display: grid;
  grid-template-columns: 1fr 200px 60px 60px 70px 70px 100px 80px 100px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.bi-location-row:hover { background: var(--row-hover); }
.bi-location-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}
.bi-location-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Truncatable text in bi rows */
.bi-cell-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pending column — colour coding */
.bi-pending-cell.bi-pending-red {
  background: #f8d7da;
  color: #b71c1c;
  font-weight: 600;
}
.bi-pending-cell.bi-pending-green {
  background: #d4edda;
  color: #1b5e20;
}

/* Invoice count — red when 0 but location has jobs */
.bi-inv-red {
  color: var(--red);
  font-weight: 600;
}

/* Totals row — fixed at bottom */
.bi-totals-row {
  display: grid;
  grid-template-columns: 1fr 200px 60px 60px 70px 70px 100px 80px 100px;
  border-top: 2px solid var(--border);
  background: var(--header-bg);
  border-left: 3px solid transparent;
  flex-shrink: 0;
}
.bi-totals-row > .cell {
  padding: 4px 5px;
  font-size: 12px;
}


/* ===========================================================================
   INVOICE EDITOR (ie- prefix)
   =========================================================================== */

#ie-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Main 3-pane layout */
.ie-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left pane: Header + Items (50%) */
.ie-left-pane {
  display: flex;
  flex-direction: column;
  width: 50%;
  border-right: 2px solid var(--border);
  overflow: hidden;
}

/* Right pane: Contracts + Jobs (50%) */
.ie-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Invoice header fields area — compact, no scroll */
.ie-header-section {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Items section — fills remaining left pane */
.ie-items-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Section header bar (shared) */
.ie-section-header {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Contracts section (~30% of right pane) */
.ie-contracts-section {
  flex: 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Jobs section (~70% of right pane) */
.ie-jobs-section {
  flex: 7;
  display: flex;
  flex-direction: column;
  border-top: 2px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

/* ----- Items grid: 4 columns (Issue 7 — removed # column) ----- */
.ie-items-header, .ie-items-row, .ie-items-totals {
  display: grid !important;
  grid-template-columns: 1fr 90px 90px 90px;
}
.ie-items-header > .list-header-cell {
  padding: 2px 5px;
}
.ie-items-row {
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  min-height: 22px;
  align-items: start;
}
.ie-items-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
}
.ie-items-row > .cell:first-child {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: unset;
}
.ie-items-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
}
.ie-items-totals {
  background: var(--header-bg);
  border-top: 2px solid var(--border);
  flex-shrink: 0;
  border-left: 3px solid transparent;
}
.ie-items-totals > .cell {
  padding: 2px 5px;
  font-size: 12px;
}

/* ----- Contracts grid: 14 columns — sized to fit ~949px container (no horizontal scroll) ----- */
.ie-contracts-header, .ie-contracts-row {
  display: grid !important;
  grid-template-columns: 55px 55px 140px 70px 70px 110px 30px 50px 40px 120px 65px 65px 55px 65px;
}
.ie-contracts-header > .list-header-cell {
  padding: 2px 5px;
}
.ie-contracts-row {
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.ie-contracts-row:hover { background: var(--row-hover); }
.ie-contracts-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
}
.ie-contracts-list-body {
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* ----- Jobs grid: 13 columns (Issue 7 — Omnis layout) ----- */
.ie-jobs-header, .ie-jobs-row {
  display: grid !important;
  grid-template-columns: 50px 50px 80px 32px 45px 55px 120px 65px 70px 80px 55px 40px 1fr;
}
.ie-jobs-header > .list-header-cell {
  padding: 2px 5px;
}
.ie-jobs-row {
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.ie-jobs-row:hover { background: var(--row-hover); }
.ie-jobs-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ie-jobs-list-body {
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-gutter: stable;
  flex: 1;
}

/* Job row colour coding */
.ie-job-this {
  background: #e8f5e9;
}
.ie-job-other {
  color: #999;
}
.ie-job-noinv {
  color: var(--text-muted);
  font-style: italic;
}

/* Scrollbar gutter on headers to match list bodies */
.ie-items-header {
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.ie-contracts-header {
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
.ie-jobs-header {
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
/* ----- Invoice Editor: Edit Mode (Phase 5.3b) ----- */
.ie-items-header-edit {
  display: grid !important;
  grid-template-columns: 30px 1fr 90px 90px 90px 30px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.ie-items-header-edit > .list-header-cell {
  padding: 2px 5px;
}
.ie-items-row-edit {
  display: grid !important;
  grid-template-columns: 30px 1fr 90px 90px 90px 30px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  min-height: 22px;
  align-items: start;
}
.ie-items-row-edit > .cell {
  padding: 2px 5px;
  font-size: 12px;
}
.ie-items-totals-edit {
  display: grid !important;
  grid-template-columns: 30px 1fr 90px 90px 90px 30px;
  background: var(--header-bg);
  border-top: 2px solid var(--border);
  flex-shrink: 0;
  border-left: 3px solid transparent;
}
.ie-items-totals-edit > .cell {
  padding: 2px 5px;
  font-size: 12px;
}
.ie-item-detail-edit {
  width: 100%;
  min-height: 36px;
  resize: vertical;
  font-family: var(--font);
  font-size: 12px;
  border: 1px solid #999;
  border-radius: var(--radius);
  padding: 2px 4px;
  background: #fff;
}
.ie-item-detail-edit:focus {
  border-color: #4a90d9;
  outline: none;
}
.ie-item-net-edit {
  width: 80px;
  text-align: right;
  height: 24px;
  font-family: var(--font);
  font-size: 12px;
  border: 1px solid #999;
  border-radius: var(--radius);
  padding: 2px 4px;
  background: #fff;
}
.ie-item-net-edit:focus {
  border-color: #4a90d9;
  outline: none;
}
.ie-remove-btn {
  background: none;
  border: none;
  color: #c00;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.ie-remove-btn:hover {
  color: #f00;
}
.ie-add-item-btn {
  background: #f0f0f0;
  border: 1px solid #ccc;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius);
  font-family: var(--font);
}
.ie-add-item-btn:hover {
  background: #e0e0e0;
}
.ie-order-btn {
  background: none;
  border: 1px solid #ccc;
  cursor: pointer;
  font-size: 9px;
  padding: 0 4px;
  line-height: 14px;
  color: #666;
}
.ie-order-btn:hover:not(:disabled) {
  background: #e0e0e0;
  color: #333;
}
.ie-order-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Keys Master */
.km-main-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.km-key-list-header {
    display: grid !important;
    grid-template-columns: 180px 70px 1fr 100px 1fr 120px 180px;
}
.km-key-row {
    display: grid;
    grid-template-columns: 180px 70px 1fr 100px 1fr 120px 180px;
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.08s;
}
.km-key-row > .cell {
    padding: 2px 5px;
}
.km-key-row:hover {
    background: var(--row-hover);
}
.km-key-row.selected {
    background: var(--row-selected);
    border-left-color: var(--row-selected-border);
}
.km-status-inactive {
    color: #E07000;
    font-weight: 600;
}
.km-loc-issue {
    color: #E07000;
    font-weight: 600;
}
/* Access items overlay list — used by _location_access.html (Keys + Locations pages) */
.km-acc-header {
    display: grid !important;
    grid-template-columns: 100px 100px 1fr 120px 180px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    border-left: 3px solid transparent;
}
.km-acc-row {
    display: grid;
    grid-template-columns: 100px 100px 1fr 120px 180px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    cursor: pointer;
}
.km-acc-row > .cell {
    padding: 2px 5px;
}
.km-acc-row:hover { background: var(--row-hover); }
.km-acc-row.selected {
    background: var(--row-selected);
    border-left-color: var(--row-selected-border);
}
/* Key log list — used by _location_access.html (Keys + Locations pages) */
.km-log-header {
    display: grid !important;
    grid-template-columns: 90px 100px 160px 100px 160px 1fr;
    overflow-y: auto;
    scrollbar-gutter: stable;
    border-left: 3px solid transparent;
}
.km-log-row {
    display: grid;
    grid-template-columns: 90px 100px 160px 100px 160px 1fr;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
}

/* ===== SCHEDULE GRID (F7) ===== */
.schedule-page { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.schedule-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.schedule-toolbar label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.schedule-toolbar select { font-size: 12px; padding: 2px 4px; }
.schedule-toolbar button {
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
}
.schedule-toolbar button:hover { background: var(--row-hover); }

.schedule-grid-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.schedule-header {
    display: grid;
    grid-template-columns: 220px repeat(7, 1fr);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-gutter: stable;
    flex-shrink: 0;
}
.schedule-header-cell {
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid var(--border);
    white-space: pre-line;
    line-height: 1.3;
}
.schedule-header-cell:first-child { text-align: left; }
.schedule-header-cell:last-child { border-right: none; }

.schedule-grid-body { flex: 1; overflow-y: auto; scrollbar-gutter: stable; }

.schedule-row {
    display: grid;
    grid-template-columns: 220px repeat(7, 1fr);
    border-bottom: 1px solid var(--border-light);
    min-height: 56px;
    cursor: pointer;
    transition: background 0.08s;
}
.schedule-row:hover { background: var(--row-hover); }
.schedule-group-start { border-top: 1px solid var(--border); }

.schedule-detail-cell {
    padding: 3px 6px;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-right: 1px solid var(--border);
    background: var(--surface);
    align-self: stretch;
    display: flex;
    align-items: flex-start;
    padding-top: 4px;
}

.schedule-day-cell {
    display: flex;
    align-items: stretch;
    padding: 2px;
    border-right: 1px solid var(--border-light, #eee);
    background: #fafafa;
    min-height: 52px;
}
.schedule-day-cell:last-child { border-right: none; }

.schedule-job-box {
    flex: 1;
    border-radius: 2px;
    padding: 3px 5px;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    white-space: pre-line;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}
.schedule-job-box:hover { opacity: 0.85; }

.schedule-assigned { background: #7BA7D9; color: white; }
.schedule-tba { background: #D98A8A; color: white; }
.schedule-absence { background: #7BA7D9; color: white; }
.schedule-job-box.schedule-cell-selected { outline: 3px solid #E6A817; outline-offset: -3px; }


/* === Xero Sales Ledger (xsl- prefix) === */

#xsl-main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.xsl-main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left pane: Client list (360px fixed) */
.xsl-client-pane {
  display: flex;
  flex-direction: column;
  width: 360px;
  min-width: 360px;
  max-width: 360px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.xsl-client-search-bar {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  flex-shrink: 0;
}

/* Client list header — 2 columns */
.xsl-client-list-header {
  display: grid !important;
  grid-template-columns: 1fr 100px;
}
.xsl-client-list-header > .list-header-cell {
  padding: 2px 4px;
}

/* Client row — 2 columns */
.xsl-client-row {
  display: grid;
  grid-template-columns: 1fr 100px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.08s;
}
.xsl-client-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xsl-client-row:hover { background: var(--row-hover); }
.xsl-client-row.selected {
  background: var(--row-selected);
  border-left: 3px solid var(--row-selected-border);
}

/* Right pane: full width transactions */
.xsl-right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

#xsl-transactions-swappable {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Client info header bar */
.xsl-client-info-bar {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
}

/* Transaction list header — columns: Date Type DueDate InvNo Detail Debit Credit [Balance] Outs */
/* grid-template-columns is set inline in the template (adapts for running balance column) */
/* Default 8-col fallback (no running balance): */
.xsl-transaction-list-header {
  display: grid !important;
  grid-template-columns: 80px 90px 80px 90px 1fr 90px 90px 90px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.xsl-transaction-list-header > .list-header-cell {
  padding: 2px 5px;
}

/* Transaction row — default 8-col fallback (no running balance) */
/* grid-template-columns is set inline in the template */
.xsl-transaction-row {
  display: grid;
  grid-template-columns: 80px 90px 80px 90px 1fr 90px 90px 90px;
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
}
.xsl-transaction-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xsl-transaction-list-body {
  overflow-y: auto;
  scrollbar-gutter: stable;
  flex: 1;
  min-height: 0;
}

/* Summary totals row — grid-template-columns set inline in template */
/* Default 8-col fallback (no running balance): */
.xsl-summary-row {
  display: grid;
  grid-template-columns: 80px 90px 80px 90px 1fr 90px 90px 90px;
  border-top: 2px solid var(--border);
  background: var(--header-bg);
  border-left: 3px solid transparent;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.xsl-summary-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
}

/* Xero balance row (below summary) — grid-template-columns set inline in template */
/* Default 8-col fallback (no running balance): */
.xsl-xero-balance-row {
  display: grid;
  grid-template-columns: 80px 90px 80px 90px 1fr 90px 90px 90px;
  border-top: 1px solid var(--border-light);
  background: var(--header-bg);
  border-left: 3px solid transparent;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.xsl-xero-balance-row > .cell {
  padding: 2px 5px;
  font-size: 12px;
}

/* Row type colouring */
.xsl-type-payment {
  background: #f0fbf0;
}
.xsl-type-payment:hover {
  background: #e0f5e0;
}
.xsl-type-credit {
  background: #fff4f4;
}
.xsl-type-credit:hover {
  background: #ffe8e8;
}
.xsl-type-overpayment {
  background: #f0f4ff;
}
.xsl-type-overpayment:hover {
  background: #e4eaff;
}

/* Xero balance value colours */
.xsl-balance-match {
  color: var(--green, #2d7a2d);
}
.xsl-balance-mismatch {
  color: var(--red);
  font-weight: 600;
}

/* Xero connection indicator dot */
.xsl-connection-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 12px;
  flex-shrink: 0;
}
.xsl-connection-indicator.xsl-connected {
  background: #2d9e2d;
  box-shadow: 0 0 4px rgba(45,158,45,0.5);
}
.xsl-connection-indicator.xsl-disconnected {
  background: #c0392b;
}

/* Loading indicator */
.xsl-loading {
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Truncatable text cells */
.xsl-cell-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Xero balance figure */
.xsl-xero-balance {
  font-weight: 600;
}

/* ===== WORKING SPINNER OVERLAY ===== */
.working-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

.working-overlay.is-visible {
  display: flex;
}

.working-card {
  background: var(--surface);
  border-radius: 6px;
  padding: 28px 36px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 160px;
}

.working-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: working-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes working-spin {
  to { transform: rotate(360deg); }
}

.working-message {
  font-size: 14px;
  color: var(--text);
  text-align: center;
}
