:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-muted: #eef3ef;
  --ink: #25312d;
  --muted: #64716b;
  --line: #d8dfd9;
  --primary: #126f68;
  --primary-strong: #0b504c;
  --primary-soft: #dcefeb;
  --accent: #d46a4c;
  --accent-soft: #f8e5dd;
  --warning: #a86d16;
  --warning-soft: #f8edd7;
  --danger: #b23b3b;
  --danger-soft: #f8dddd;
  --shadow: 0 16px 40px rgba(37, 49, 45, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(18, 111, 104, 0.08), rgba(18, 111, 104, 0) 240px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.topbar h1,
.panel-heading h2,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 2rem;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.connection-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.connection-panel strong {
  color: var(--ink);
}

.auth-panel {
  display: grid;
  min-height: 58vh;
  place-items: center;
}

.auth-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 800;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.button {
  min-height: 42px;
  gap: 8px;
  padding: 0 14px;
}

.button.compact {
  min-height: 38px;
  padding: 0 12px;
}

.button:hover,
.icon-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(18, 111, 104, 0.25);
  outline-offset: 2px;
}

.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(18, 111, 104, 0.18);
}

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.secondary:hover {
  border-color: rgba(18, 111, 104, 0.36);
  box-shadow: 0 8px 20px rgba(37, 49, 45, 0.06);
}

.icon-button {
  width: 38px;
  height: 38px;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.icon-button.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.icon-button.ghost {
  background: transparent;
}

.icon-button.danger:hover {
  color: var(--danger);
  border-color: rgba(178, 59, 59, 0.4);
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 auto;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.import-label {
  position: relative;
  overflow: hidden;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
  line-height: 1;
}

.metric.urgent {
  border-left-color: var(--accent);
}

.metric.due {
  border-left-color: var(--danger);
}

.metric.preventive {
  border-left-color: #476fa8;
}

.metric.guest {
  border-left-color: var(--warning);
}

.metric.spend {
  border-left-color: #4d7a3b;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.request-panel,
.tracker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.request-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 1.15rem;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field,
.checks {
  min-width: 0;
}

.field.full,
.checks.full,
.form-actions.full {
  grid-column: 1 / -1;
}

label,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

input,
select {
  padding: 0 10px;
}

textarea {
  min-height: 112px;
  padding: 10px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #8c9691;
}

.checks {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

.checks input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.helper-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.photo-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  gap: 8px;
  margin: 0;
  border: 1px dashed rgba(18, 111, 104, 0.42);
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.92rem;
  font-weight: 850;
  cursor: pointer;
}

.photo-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview,
.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
}

.photo-preview {
  margin-top: 10px;
}

.photo-thumb {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  aspect-ratio: 1;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-photo {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(37, 49, 45, 0.78);
  color: #ffffff;
}

.remove-photo .icon {
  width: 14px;
  height: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions .button {
  flex: 1;
}

.tracker {
  padding: 16px;
  min-width: 0;
}

.portfolio-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.portfolio-tab {
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.portfolio-tab:hover {
  color: var(--primary);
}

.portfolio-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary-strong);
}

.unit-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.unit-option {
  display: grid;
  gap: 2px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.unit-option:hover {
  border-color: rgba(18, 111, 104, 0.42);
  box-shadow: 0 8px 18px rgba(37, 49, 45, 0.06);
}

.unit-option.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.unit-option.has-open-request {
  border-color: rgba(178, 59, 59, 0.72);
  background: var(--danger-soft);
}

.unit-option.has-open-request.active {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(178, 59, 59, 0.22);
}

.unit-option strong {
  color: var(--primary-strong);
  font-size: 0.82rem;
}

.unit-option.has-open-request strong,
.unit-option.has-open-request .unit-count {
  color: #7f2020;
}

.unit-option span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.unit-option .unit-count {
  color: var(--primary-strong);
  font-weight: 850;
}

.tracker-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(5, minmax(120px, 160px)) auto;
  gap: 10px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.search-box input {
  min-height: auto;
  padding: 0;
  border: 0;
  outline: 0;
}

.search-box .icon {
  color: var(--muted);
}

.view-toggle {
  display: inline-flex;
  gap: 6px;
}

.active-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
}

.active-filter-row p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 12px;
}

.board-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9faf6;
}

.column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.column-heading h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0;
}

.column-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.column-body {
  display: grid;
  gap: 10px;
  min-height: 140px;
  padding: 10px;
}

.job-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(37, 49, 45, 0.05);
}

.job-card-top,
.job-tags,
.job-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.job-card-top,
.job-actions {
  justify-content: space-between;
}

.job-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.meta-line,
.details-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.details-line {
  display: -webkit-box;
  min-height: 2.5em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.photo-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.photo-strip .photo-thumb {
  border-color: transparent;
}

.photo-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 0;
  border-radius: var(--radius);
  background: rgba(37, 49, 45, 0.72);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 850;
  aspect-ratio: 1;
}

.priority-pill,
.due-pill,
.tag,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.priority-pill {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.priority-high {
  color: #7a331f;
  background: var(--accent-soft);
}

.priority-emergency {
  color: #7f2020;
  background: var(--danger-soft);
}

.priority-low {
  color: #44513f;
  background: #e6ecd9;
}

.due-pill {
  color: var(--muted);
  background: var(--surface-muted);
}

.due-overdue {
  color: #7f2020;
  background: var(--danger-soft);
}

.due-today {
  color: #744800;
  background: var(--warning-soft);
}

.tag {
  color: var(--muted);
  background: var(--surface-muted);
}

.tag.alert {
  color: #744800;
  background: var(--warning-soft);
}

.tag.blocked {
  color: #7f2020;
  background: var(--danger-soft);
}

.tag.preventive {
  color: #254a7a;
  background: #e0eaf7;
}

.job-tags {
  flex-wrap: wrap;
}

.status-select {
  min-width: 0;
  width: 100%;
  height: 38px;
}

.job-actions .icon-button {
  flex: 0 0 auto;
}

.list-view {
  overflow-x: auto;
}

.calendar-view {
  display: grid;
  gap: 12px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9faf6;
}

.calendar-header h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.calendar-header p:last-child {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 750;
}

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

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.calendar-weekdays span {
  padding: 0 6px;
}

.calendar-grid {
  gap: 8px;
}

.calendar-day {
  min-width: 0;
  min-height: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.calendar-day.outside-month {
  background: #f4f6f0;
  color: var(--muted);
}

.calendar-day.today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(18, 111, 104, 0.2);
}

.calendar-day.multi-assignment {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.86rem;
  font-weight: 850;
}

.calendar-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.calendar-day.multi-assignment .calendar-count {
  background: var(--accent);
  color: #ffffff;
}

.calendar-items {
  display: grid;
  gap: 5px;
}

.calendar-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 46px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  text-align: left;
}

.calendar-item strong,
.calendar-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-item strong {
  font-size: 0.78rem;
}

.calendar-item span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.calendar-more {
  color: var(--primary-strong);
  font-size: 0.76rem;
  font-weight: 850;
}

.request-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.request-table th,
.request-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.request-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.request-table td {
  font-size: 0.92rem;
}

.request-table .table-title {
  font-weight: 850;
}

.request-table .table-actions {
  display: flex;
  gap: 8px;
}

.status-chip {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.status-completed {
  color: #41602e;
  background: #e6efd8;
}

.status-waiting {
  color: #744800;
  background: var(--warning-soft);
}

.status-progress {
  color: #7a331f;
  background: var(--accent-soft);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 340px;
  padding: 44px 20px;
  border: 1px dashed #c4cec6;
  border-radius: var(--radius);
  background: #f9faf6;
  text-align: center;
}

.empty-state svg {
  width: 120px;
  height: 90px;
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.empty-state h2 {
  margin-top: 8px;
  font-size: 1.1rem;
}

.empty-state p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1200px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .request-panel {
    position: static;
  }

  .tracker-toolbar {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(130px, 1fr));
  }

  .view-toggle {
    justify-self: start;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1 1 140px;
  }

  .portfolio-tabs {
    overflow-x: auto;
  }

  .portfolio-tab {
    flex: 0 0 auto;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .board {
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: auto;
  }

  .calendar-day.outside-month {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar h1 {
    font-size: 1.6rem;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  form,
  .tracker-toolbar {
    grid-template-columns: 1fr;
  }

  .active-filter-row,
  .calendar-header,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-actions {
    justify-content: space-between;
  }

  .button,
  .form-actions .button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar-actions,
  .request-panel,
  .tracker-toolbar,
  .active-filter-row,
  .icon-button,
  .job-actions,
  .metrics {
    display: none !important;
  }

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

  .workspace,
  .board {
    display: block;
  }

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

  .board-column {
    break-inside: avoid;
    margin-bottom: 16px;
  }

  .job-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
