:root {
  color-scheme: light dark;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --border: #e5e7eb;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.site-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

@media (max-width: 960px) {
  .site-shell {
    grid-template-columns: 1fr;
  }
}

.app-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar .eyebrow {
  color: #94a3b8;
}

.sidebar h1 {
  color: #fff;
}

.sidebar .subtitle {
  color: #cbd5f5;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.nav-link {
  text-align: left;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.nav-link.is-active {
  background: #2563eb;
  color: #fff;
}

.sidebar .layout-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sidebar .toggle-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.sidebar .toggle-btn.is-active {
  color: #2563eb;
  background: #fff;
}

@media (max-width: 960px) {
  .sidebar {
    grid-row: 1;
  }
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
}

.header-copy {
  min-width: 260px;
  flex: 1;
}

.layout-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.toggle-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.25);
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.app-header h1 {
  margin: 0;
  font-size: 2.2rem;
}

.subtitle {
  color: var(--muted);
  max-width: 36rem;
}

.settings {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--card);
  border-radius: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 260px;
}

.select-field {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  font-size: 0.95rem;
}

.input-prefix {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
}

.input-prefix input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.75rem 0 0.75rem 0.25rem;
}

input,
button {
  font: inherit;
}

input[type="number"],
input[type="date"],
input[type="text"] {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: inherit;
}

input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.summary-lead {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.summary-card strong {
  display: block;
  font-size: 1.7rem;
  margin-top: 0.35rem;
}

.helper-subtle {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.summary-card.highlight {
  background: var(--accent-soft);
  border-color: transparent;
}

.backup-box {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.01));
}

.insights-card {
  padding: 1.5rem;
}

.insights-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.insights-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.insight-pill {
  border-radius: 0.9rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  background: var(--card);
}

.insight-pill strong {
  display: block;
  font-size: 1.1rem;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.insight-alerts {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

.alert-pill {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #fbbf24;
  background: #fef3c7;
  color: #92400e;
}

.card {
  background: var(--card);
  border-radius: 1.25rem;
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.form-card h2,
.table-card h2 {
  margin-top: 0;
}

.form-card__lead {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.lead-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field-notes {
  grid-column: span 2;
}

.inline-select {
  min-width: 200px;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card);
  font: inherit;
}

.lead-actions .helper-text {
  margin-bottom: 0;
}

.helper-text {
  margin: 0 0 1rem;
  color: var(--muted);
}

.quick-actions {
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  padding: 0.75rem;
  background: var(--bg);
}

.quick-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.primary,
.ghost {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}

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

.ghost {
  background: transparent;
  color: var(--accent);
}

.ghost.small {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.ghost.danger {
  color: #dc2626;
}

button:hover {
  filter: brightness(0.95);
}

.table-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.table-filters {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.field.compact span {
  font-size: 0.8rem;
}

.report-card {
  margin-top: 1rem;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.report-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-end;
}

.report-chart {
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.bar-card {
  padding: 0.75rem 0.75rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg);
}

.bar-stack {
  height: 96px;
  display: flex;
  gap: 0.25rem;
  align-items: flex-end;
}

.bar {
  flex: 1;
  border-radius: 0.4rem;
  background: var(--accent);
  min-width: 10px;
}

.bar.bonus {
  background: #f59e0b;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
}

td:last-child {
  width: auto;
}

.delete-btn {
  border: none;
  background: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1rem;
}

.edit-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 1rem;
  margin-right: 0.25rem;
}

.entry-actions {
  display: flex;
  gap: 0.25rem;
  min-width: 96px;
}

.empty {
  text-align: center;
  color: var(--muted);
}

@media (max-width: 720px) {
  .settings {
    flex-direction: column;
  }

  .card {
    padding: 1.25rem;
  }
}

.layout-toggle {
  margin-left: auto;
}

.housekeeper-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

fieldset:disabled {
  opacity: 0.6;
  pointer-events: none;
}

@media (min-width: 1100px) {
  .app-shell.layout-dashboard {
    display: grid;
    grid-template-columns: minmax(280px, 320px) 1fr;
    grid-template-areas:
      "summary summary"
      "form table"
      "report report";
  }

  .app-shell.layout-dashboard .summary-block {
    grid-area: summary;
  }

  .app-shell.layout-dashboard .form-card {
    grid-area: form;
  }

  .app-shell.layout-dashboard .table-card {
    grid-area: table;
  }

  .app-shell.layout-dashboard .report-card {
    grid-area: report;
  }

  .app-shell.layout-sidebar {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 1.5rem;
  }

  .app-shell.layout-sidebar .settings {
    grid-column: 1 / 2;
  }

  .app-shell.layout-sidebar .summary-block {
    grid-column: 1 / 2;
  }

  .app-shell.layout-sidebar .form-card,
  .app-shell.layout-sidebar .table-card,
  .app-shell.layout-sidebar .report-card {
    grid-column: 2 / 3;
  }
}
.app-shell [data-view-panel] {
  display: none;
}

.app-shell[data-active-view="housekeepers"] [data-view-panel="housekeepers"],
.app-shell[data-active-view="journal"] [data-view-panel="journal"],
.app-shell[data-active-view="reports"] [data-view-panel="reports"] {
  display: block;
}

/* Accessibility helper: visible to screen readers only. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  padding: 0.85rem 1.1rem;
  border-radius: 0.75rem;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  background: #047857;
}

.toast-error {
  background: #b91c1c;
}

/* Confirmation modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.primary.danger {
  background: #dc2626;
  color: #fff;
}

/* Report KPI cards */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  padding: 1rem 1.1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--card);
}

.kpi-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card strong {
  display: block;
  font-size: 1.4rem;
  margin-top: 0.3rem;
}

.kpi-card.highlight {
  background: var(--accent-soft);
  border-color: transparent;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
}

.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.badge-empty {
  background: #fee2e2;
  color: #991b1b;
}

/* Report daily detail */
.detail-toggle {
  white-space: nowrap;
}

.report-detail-row > td {
  background: var(--bg);
  padding: 0.5rem 1rem 1rem;
}

.detail-table {
  font-size: 0.85rem;
  background: var(--card);
  border-radius: 0.6rem;
  overflow: hidden;
}

.detail-table th {
  font-size: 0.68rem;
}

/* Recurring schedule card */
.schedule-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.schedule-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}

.schedule-day {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--bg);
}

.schedule-day.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.schedule-day__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.schedule-day__hours {
  background: var(--card);
}

.schedule-day__hours input {
  padding: 0.45rem 0 0.45rem 0.25rem;
}

.schedule-day__hours input:disabled {
  opacity: 0.5;
}

.schedule-generate {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.schedule-generate h3 {
  margin: 0 0 0.25rem;
}

.schedule-generate-controls {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.schedule-preview {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--bg);
}

.preview-summary {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.preview-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  max-height: 220px;
  overflow-y: auto;
  columns: 2;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .preview-list {
    columns: 1;
  }
}

/* Print: only the report, clean for PDF export */
@media print {
  .sidebar,
  .layout-toggle,
  .report-form,
  .report-actions,
  .report-chart,
  .detail-toggle-cell,
  .toast-stack,
  .modal-backdrop {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .site-shell {
    display: block;
  }

  .app-shell {
    max-width: none;
    padding: 0;
  }

  .app-shell [data-view-panel] {
    display: none !important;
  }

  .app-shell [data-view-panel="reports"] {
    display: block !important;
  }

  .card {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  .report-kpis {
    page-break-inside: avoid;
  }
}
