﻿:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0b3b8f;
  --brand-2: #0f56c6;
  --danger: #b91c1c;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: #ffffff;
}

.auth-locked #appRoot {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.22);
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
}

.auth-card h2 {
  margin: 0 0 12px;
}

.auth-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.auth-error {
  margin: 8px 0 10px;
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.topbar {
  background: #ffffff;
  color: #000000;
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.topbar-logo img {
  display: block;
  height: 70px;
  width: auto;
}

.topbar-copy {
  margin-left: 0;
  text-align: right;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user span {
  font-size: 13px;
  color: #111827;
}

.topbar-user button {
  padding: 6px 10px;
}

.topbar h1 { margin: 0 0 6px; font-size: 32px; }
.topbar p { margin: 0; color: #111827; }

.app-shell {
  padding: 16px;
  max-width: 1500px;
  margin: 0 auto;
}

.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-spacer {
  width: 14px;
  flex: 0 0 14px;
}

.tab-btn {
  border: 1px solid #94a3b8;
  background: #ffffff;
  color: #0f172a;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn-right {
  margin-left: auto;
  margin-right: 8px;
}

.tab-btn.active {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #ffffff;
  border-color: #1d4ed8;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.finance-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 14px;
}

#tabDashboard .finance-panel:first-of-type {
  background: #f8fafc;
}

.finance-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.finance-panel-head h2 {
  margin: 0;
}

.finance-period-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.finance-period-control select {
  width: auto;
  min-width: 130px;
  padding: 6px 8px;
}

.finance-custom-range {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 8px;
}

.finance-custom-range label {
  margin: 0;
  min-width: 170px;
}

.finance-custom-range.hidden {
  display: none;
}

.finance-period-text {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.finance-tile {
  border: 1px solid #dbe5f2;
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
}

.finance-value {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
}

.dashboard-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #c7ddf4;
}

.dashboard-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.dashboard-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

.dashboard-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
}

.dashboard-panel h3 {
  margin: 0;
  font-size: 15px;
}

.dashboard-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.dash-range-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.dash-range-control select {
  width: auto;
  min-width: 140px;
  padding: 6px 8px;
}

.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.dashboard-list li {
  display: grid;
  grid-template-columns: 170px 130px 170px 1fr;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.dashboard-empty {
  color: var(--muted);
  font-size: 13px;
}

.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

h2 { margin: 0 0 12px; font-size: 18px; }
label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
  font-weight: 500;
}
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: #60a5fa;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.booking-entry-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.booking-form {
  display: grid;
  gap: 10px;
}

.booking-form label {
  margin-bottom: 0;
}

.booking-form-fields {
  grid-column: 1 / span 2;
  display: grid;
  gap: 10px;
}

.booking-preview {
  grid-column: 3;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfd;
  padding: 12px;
  align-self: stretch;
}

.booking-preview h3 {
  margin: 0;
  font-size: 15px;
}

.booking-preview-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.booking-preview-note {
  margin-left: auto;
  text-align: right;
  color: #000000;
  font-size: 13px;
}

.booking-preview-body {
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.preview-block-title {
  font-weight: 700;
  margin-top: 6px;
}

.preview-spacer {
  height: 6px;
}

.booking-grid {
  display: grid;
  gap: 10px;
}

.booking-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.booking-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.booking-divider {
  border-top: 1px solid #cbd5e1;
  padding-top: 10px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: end;
}

#tabBookings .toolbar {
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
}

#tabBookings .toolbar button {
  white-space: nowrap;
}

#tabBookings #searchInput {
  flex: 0 0 260px;
  max-width: 260px;
  margin-right: auto;
}

#tabInstallation .toolbar {
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
}

#tabInstallation .toolbar button {
  white-space: nowrap;
}

#tabInstallation #installationSearchInput {
  flex: 0 0 320px;
  max-width: 320px;
  margin-right: auto;
}

.toolbar label {
  margin-bottom: 0;
  min-width: 170px;
}

#tabRunsheet .toolbar .runsheet-type-filter {
  margin-left: auto;
  min-width: 180px;
}

#tabRunsheet .toolbar .runsheet-type-filter select {
  min-width: 160px;
}
.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
button {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  cursor: pointer;
}
button.primary {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: #1d4ed8;
}
button:hover { filter: brightness(0.98); }
button.danger, .danger {
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

#bookingsTable th:nth-child(2),
#bookingsTable td:nth-child(2) {
  width: 120px;
}

th, td {
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #f8fafc;
}

.status-select {
  min-width: 130px;
  padding: 6px 8px;
}
.link-btn {
  border: none;
  background: none;
  padding: 0;
  margin-right: 8px;
  color: #1d4ed8;
  cursor: pointer;
}

#bookingsTable tbody tr.row-completed td,
#installationsTable tbody tr.row-completed td {
  color: #dc2626;
}

#bookingsTable tbody tr.row-completed .link-btn,
#installationsTable tbody tr.row-completed .link-btn {
  color: #dc2626;
}

#bookingsTable tbody tr.row-completed .status-select,
#installationsTable tbody tr.row-completed .status-select {
  color: #dc2626;
  border-color: #fca5a5;
}

#bookingsTable tbody tr.row-cancelled td,
#installationsTable tbody tr.row-cancelled td {
  text-decoration: line-through;
}

#bookingsTable tbody tr.row-cancelled .status-select,
#installationsTable tbody tr.row-cancelled .status-select {
  text-decoration: line-through;
}
.muted { color: var(--muted); font-size: 13px; }

#runSheetOutput {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 120px;
  padding: 10px;
  background: #fff;
}
.runsheet-empty {
  color: var(--muted);
  font-size: 14px;
}
.runsheet-header {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}
.runsheet-columns {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.day-group {
  break-inside: avoid;
  margin-bottom: 0;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
}
.day-title {
  margin: 0;
  padding: 7px 10px;
  background: #dbeafe;
  font-size: 14px;
  grid-column: 1 / -1;
}
.job-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font-size: 12px;
}
.job-ref {
  font-weight: 700;
  font-size: 12px;
}
.job-line {
  margin-top: 3px;
  color: #111827;
}

@media (max-width: 980px) {
  .booking-entry-layout { grid-template-columns: 1fr; }
  .booking-form-fields,
  .booking-preview { grid-column: auto; }
  .grid.two { grid-template-columns: 1fr; }
  .booking-grid.two,
  .booking-grid.three { grid-template-columns: 1fr; }
  .day-group { grid-template-columns: 1fr; }
  .finance-custom-range { flex-direction: column; align-items: stretch; }
  .finance-custom-range label { min-width: 0; width: 100%; }
  .finance-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-list li { grid-template-columns: 1fr; }
  #tabRunsheet .toolbar .runsheet-type-filter { margin-left: 0; }
}

@media print {
  body * {
    visibility: hidden;
  }
  #runSheetOutput,
  #runSheetOutput * {
    visibility: visible;
  }
  #runSheetOutput {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: none;
    padding: 0;
  }
  .day-group {
    break-inside: avoid;
    page-break-inside: avoid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}




.table-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.page-size-label select {
  width: auto;
  min-width: 70px;
  padding: 6px 8px;
}
