:root {
  --ink: #101828;
  --muted: #667085;
  --soft: #f5f8fb;
  --panel: #ffffff;
  --line: #d9e2ea;
  --nav: #071526;
  --nav-soft: #0d2236;
  --teal: #10a99f;
  --teal-soft: #d7fbf5;
  --orange: #f97316;
  --blue: #316dca;
  --green: #24a871;
  --red: #d6453d;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.10);
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--soft);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(180deg, #0b2234, #050b18 82%);
  color: #d5e7f3;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 16px 24px;
  text-decoration: none;
}

.brand span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 12px;
  background: linear-gradient(135deg, #0a8f7c, #14b8a6);
  color: #fff;
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: #fff;
  font-size: 16px;
}

.brand small {
  margin-top: 2px;
  color: #8bb5ca;
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 5px;
  padding: 12px 10px;
}

.side-nav a {
  border-radius: 12px;
  padding: 12px 14px;
  color: #b9d3e4;
  text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(16, 169, 159, 0.18);
  color: #32e4d2;
  box-shadow: inset 3px 0 0 #1ee3d2;
}

.collapse-button {
  margin: auto 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 11px 14px;
  background: transparent;
  color: #b9d3e4;
  text-align: left;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.page-label {
  font-size: 18px;
  font-weight: 850;
}

.global-search {
  position: relative;
  min-width: 0;
}

.global-search span,
.field-row label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.global-search input,
.field-row input,
.field-row select,
.intake-panel input,
.intake-panel select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 13px;
  background: #fff;
  color: var(--ink);
}

.ghost-button,
.icon-button,
.primary-button,
.availability-button {
  min-height: 40px;
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 800;
}

.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}

.availability-button {
  border: 1px solid #b9f1df;
  background: #cff8e5;
  color: #08745f;
}

.primary-button {
  border: 0;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 24px rgba(16, 169, 159, 0.26);
}

.profile-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.profile-chip > span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 13px;
  font-weight: 950;
}

.profile-chip strong,
.profile-chip small {
  display: block;
  white-space: nowrap;
}

.profile-chip small {
  color: var(--muted);
  font-size: 12px;
}

main {
  display: grid;
  gap: 24px;
  padding: 32px clamp(18px, 4vw, 42px) 48px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 7px;
  font-size: 22px;
}

.page-head p,
.intake-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
}

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

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

.metrics article {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
}

.metrics span {
  display: block;
  color: #52627a;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 28px;
}

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

.filter-panel,
.table-shell,
.job-detail,
.intake-panel,
.app-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.filter-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.4fr) minmax(160px, 0.8fr) minmax(160px, 0.8fr) minmax(190px, 0.9fr);
  gap: 12px;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-tabs button {
  min-height: 38px;
  border: 1px solid #eef2f6;
  border-radius: 12px;
  padding: 8px 14px;
  background: #fff;
  color: #475467;
  font-weight: 800;
}

.status-tabs button.active {
  background: #050915;
  color: #fff;
}

.status-tabs span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  place-items: center;
  margin-left: 6px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
}

.status-tabs button.active span {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.hide-completed {
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
  color: #475467;
}

.jobs-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.32fr);
  gap: 18px;
  align-items: start;
}

.table-shell {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid #eef2f6;
  padding: 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #667085;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.active {
  background: #f6fffd;
}

.job-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.job-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #a8eee7;
  border-radius: 12px;
  background: #e9fffb;
  color: var(--teal);
  font-weight: 950;
}

.job-title strong,
.job-title small,
.customer-cell strong,
.customer-cell small,
.tech-cell strong,
.tech-cell small,
.invoice-cell strong,
.invoice-cell small {
  display: block;
}

.job-title small,
.customer-cell small,
.tech-cell small,
.invoice-cell small,
.scheduled-cell {
  color: var(--muted);
  line-height: 1.45;
}

.avatar {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 950;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
}

.status-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  content: "";
  background: currentColor;
}

.status-scheduled {
  background: #eaf2ff;
  color: var(--blue);
}

.status-in-progress {
  background: #fff7e8;
  color: #bc650d;
}

.status-pending {
  background: #f2f4f7;
  color: #475467;
}

.status-completed,
.status-invoiced,
.status-paid {
  background: #dcfae6;
  color: #087443;
}

.status-cancelled {
  background: #fee4e2;
  color: var(--red);
}

.job-detail {
  position: sticky;
  top: 90px;
  padding: 20px;
}

.job-detail h3 {
  margin-bottom: 8px;
  font-size: 21px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f8fbfd;
}

.detail-grid span,
.timeline-title {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.timeline {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  border-left: 3px solid var(--teal);
  padding-left: 10px;
  color: #475467;
  line-height: 1.45;
}

.intake-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(240px, 0.55fr) minmax(0, 1fr);
  gap: 20px;
  padding: 22px;
}

.intake-panel form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.intake-panel label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #475467;
  font-weight: 800;
}

.intake-panel button {
  grid-column: 1 / -1;
}

.app-panel {
  padding: 22px;
}

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

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.calendar-day {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #f8fbfd;
}

.calendar-day header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: #475467;
  font-weight: 850;
}

.calendar-job {
  display: grid;
  gap: 5px;
  border-left: 4px solid var(--teal);
  border-radius: 12px;
  margin-bottom: 10px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.04);
}

.calendar-job strong,
.calendar-job span {
  display: block;
}

.calendar-job span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.report-table,
.inventory-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.report-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(220px, 1.25fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f6;
  background: #fff;
}

.inventory-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.2fr) minmax(120px, 0.5fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f6;
  background: #fff;
}

.report-row:last-child,
.inventory-row:last-child {
  border-bottom: 0;
}

.report-row.header,
.inventory-row.header {
  color: #667085;
  background: #f8fbfd;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.service-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

.service-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.material-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.material-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fbfd;
}

.stock-ok {
  color: var(--green);
  font-weight: 850;
}

.stock-low {
  color: #bc650d;
  font-weight: 850;
}

.stock-out {
  color: var(--red);
  font-weight: 850;
}

.order-link {
  color: var(--teal);
  font-weight: 850;
  text-decoration: none;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.crew-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

.crew-grid strong,
.crew-grid span,
.crew-grid small {
  display: block;
}

.crew-grid span {
  margin-top: 6px;
  color: var(--ink);
  font-weight: 800;
}

.crew-grid small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.tech-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.tech-meta span {
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(7, 21, 38, 0.62);
}

.modal-backdrop.open {
  display: grid;
}

.storage-modal {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(7, 21, 38, 0.34);
}

.restriction-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.restriction-grid article {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #f8fbfd;
}

.restriction-grid strong,
.restriction-grid span {
  display: block;
}

.restriction-grid span {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.upload-simulator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.4fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.upload-simulator label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #475467;
  font-weight: 850;
}

.upload-simulator input,
.upload-simulator select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 13px;
}

.document-list {
  display: grid;
  gap: 9px;
}

.document-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.document-item span {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 14px;
  padding: 14px 16px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: auto minmax(220px, 1fr) auto auto;
  }

  .icon-button,
  .profile-chip {
    display: none;
  }

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

  .jobs-board,
  .intake-panel {
    grid-template-columns: 1fr;
  }

  .calendar-grid,
  .service-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .job-detail {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .side-nav a {
    text-align: center;
  }

  .collapse-button {
    display: none;
  }

  .topbar,
  .page-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .head-actions {
    justify-content: flex-start;
  }

  .field-row,
  .intake-panel form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  table {
    min-width: 860px;
  }
}

@media (max-width: 560px) {
  main {
    padding: 24px 14px 38px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .field-row,
  .intake-panel form,
  .crew-grid,
  .detail-grid,
  .calendar-grid,
  .service-grid,
  .restriction-grid,
  .upload-simulator,
  .report-row,
  .inventory-row {
    grid-template-columns: 1fr;
  }

  .status-tabs button,
  .head-actions button {
    flex: 1 1 auto;
  }
}
