:root {
  color-scheme: light;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: #f4f6f4;
  color: #172022;
  --ink: #172022;
  --muted: #607075;
  --line: #d8e0df;
  --paper: #ffffff;
  --soft: #eef3f1;
  --brand: #105f68;
  --brand-2: #1f7a62;
  --warm: #c66a32;
  --gold: #b48a1f;
  --blue: #346a92;
  --alert: #a43f3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

button:hover {
  border-color: #9db4b4;
  box-shadow: 0 4px 14px rgba(23, 32, 34, 0.08);
}

button.primary,
.login button,
.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
}

select {
  min-height: 39px;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 16px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 16px / 6px 6px no-repeat,
    white;
  appearance: none;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(31, 122, 98, 0.16), transparent 32%),
    linear-gradient(135deg, #e8f0ee, #f7f4ed);
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(15, 32, 36, 0.12);
}

.login-panel h1 {
  margin: 0;
  font-size: 32px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-bottom: 22px;
  text-align: center;
}

.login-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.login-panel label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #48575c;
}

.error {
  color: var(--alert);
  min-height: 20px;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background:
    linear-gradient(90deg, rgba(16, 95, 104, 0.08), rgba(198, 106, 50, 0.06)),
    rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.05;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(16, 95, 104, 0.16);
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 22px 0;
  color: var(--muted);
  font-size: 13px;
}

.user-kpi {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 45, 48, 0.06);
}

.user-kpi div,
.user-row-name div {
  display: grid;
  gap: 1px;
}

.user-kpi span,
.user-row-name span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-row-name .user-reset-badge {
  width: max-content;
  margin-top: 3px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fff3df;
  color: #8a4b03;
}

.user-kpi b,
.user-row-name b {
  color: var(--ink);
}

.initial-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.initial-avatar circle {
  fill: #105f68;
}

.initial-avatar text {
  fill: #fff;
  font-size: 13px;
  font-weight: 900;
  font-family: inherit;
}

.live-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e7f2ef;
  color: #145744;
  font-weight: 800;
}

.live-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-2);
}

.live-label.stale {
  background: #fff1e8;
  color: #9a4f25;
}

.live-label.stale::before {
  background: var(--warm);
}

.filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(130px, 1fr)) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 22px 2px;
}

.date-filter {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
  align-items: center;
  min-height: 39px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.date-filter input {
  min-width: 0;
  padding: 6px 7px;
}

.check-filter {
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.check-filter input {
  width: auto;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 520px) auto auto;
  gap: 8px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 22px 14px;
  overflow-x: auto;
}

.tabs.compact {
  padding: 12px 0;
}

.tab {
  white-space: nowrap;
  background: #f8faf9;
}

.tab span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(17, 94, 103, 0.12);
  color: inherit;
  font-size: 12px;
}

.panel,
.calendar,
.my-calls {
  margin: 0 22px 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 12px 30px rgba(31, 45, 48, 0.07);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head p {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.users-view {
  background: #f7f9f8;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.field-permission-form {
  grid-template-columns: minmax(220px, 1.6fr) minmax(180px, 1fr) auto auto auto auto auto;
}

.users-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(220px, auto) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 45, 48, 0.05);
}

.permission-row b,
.permission-row span {
  display: block;
}

.permission-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.permission-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.permission-flags span {
  min-width: 56px;
  margin: 0;
  padding: 5px 8px;
  border-radius: 999px;
  background: #f1f2f1;
  color: #778487;
  text-align: center;
}

.permission-flags span.enabled {
  background: #e7f2ef;
  color: #145744;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(150px, 1fr) minmax(190px, 1.1fr) 120px minmax(140px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(31, 45, 48, 0.05);
}

.user-row-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-row textarea {
  min-height: 42px;
  resize: vertical;
}

.user-active {
  justify-content: center;
}

.empty-state {
  margin: 0;
  padding: 20px;
  color: var(--muted);
  font-weight: 800;
}

.my-calls {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #f7f9f8;
}

.mobile-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.mobile-head h2 {
  margin: 0;
  font-size: 20px;
}

.mobile-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.my-call-metrics {
  padding: 0;
}

.my-call-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 8px;
}

.my-call-calendar {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
}

.call-bucket {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 190px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.call-bucket h3 {
  margin: 0;
  font-size: 15px;
}

.call-bucket p {
  margin: 0;
  color: var(--muted);
}

.bucket-call {
  width: 100%;
  min-height: 54px;
  display: grid;
  justify-items: start;
  gap: 3px;
  text-align: left;
  border-left: 4px solid var(--brand);
  background: #f8faf9;
}

.bucket-call b {
  font-size: 13px;
}

.bucket-call span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.call-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.call-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 18px rgba(31, 45, 48, 0.06);
  cursor: pointer;
}

.call-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.call-card-head span {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f2ef;
  color: #145744;
  font-size: 12px;
  font-weight: 800;
}

.call-card h3 {
  margin: 8px 0 2px;
  font-size: 18px;
}

.call-card p {
  margin: 0;
  color: var(--muted);
}

.call-card-head b {
  white-space: nowrap;
  color: var(--ink);
}

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

.call-facts div {
  padding: 9px;
  border-radius: 7px;
  background: #f8faf9;
}

.call-facts span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.call-facts b {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.step-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.step-strip span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f4f5;
  color: #5d7078;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.step-strip span.done {
  background: #e7f2ef;
  border-color: #badad0;
  color: #145744;
}

.call-concern {
  max-height: 72px;
  overflow: hidden;
}

.open-call {
  min-height: 42px;
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 22px 6px;
}

.metric {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(31, 45, 48, 0.06);
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
}

.metric:nth-child(2)::before {
  background: var(--brand-2);
}

.metric:nth-child(3)::before {
  background: var(--blue);
}

.metric:nth-child(4)::before {
  background: var(--warm);
}

.metric:nth-child(5)::before {
  background: var(--gold);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric b {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1f2;
  text-align: left;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #f8faf9;
  color: #506166;
  font-weight: 700;
}

th[data-sort-project],
th[data-sort-call] {
  cursor: pointer;
  user-select: none;
}

th[data-sort-project]::after,
th[data-sort-call]::after {
  content: "↕";
  margin-left: 6px;
  color: #9aacaf;
  font-size: 12px;
}

th.sorted::after {
  content: "↑";
  color: var(--brand);
}

th.sorted[data-direction="desc"]::after {
  content: "↓";
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #eef7f4;
}

.job-main {
  display: grid;
  gap: 2px;
}

.job-main b {
  font-size: 14px;
}

.job-main span {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 190px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7f2ef;
  color: #145744;
  font-size: 12px;
  font-weight: 700;
}

.pill.empty {
  background: #f1f2f1;
  color: #778487;
}

.pill[class*="status-"] {
  border: 1px solid rgba(31, 45, 48, 0.08);
}

.date-cell {
  color: #273538;
  font-variant-numeric: tabular-nums;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  padding: 14px;
}

.calendar-shell {
  margin: 0 22px 22px;
  display: grid;
  gap: 12px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 24px rgba(31, 45, 48, 0.06);
}

.calendar-toolbar h2 {
  margin: 0;
  font-size: 18px;
}

.calendar-toolbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.calendar-legend {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(31, 45, 48, 0.06);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 8px;
  border-left: 4px solid #778487;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.legend-item i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

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

.mode-toggle {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.mode {
  border: 0;
  background: transparent;
  padding: 7px 9px;
}

.mode.active {
  background: var(--brand);
  color: white;
}

.calendar-grid {
  display: grid;
  gap: 10px;
}

.calendar-grid.mode-month {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
}

.calendar-grid.mode-week {
  grid-template-columns: repeat(7, minmax(170px, 1fr));
}

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

.calendar-grid .day {
  min-height: 170px;
  box-shadow: 0 8px 18px rgba(31, 45, 48, 0.05);
}

.calendar-grid .day.today {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(16, 95, 104, 0.14);
}

.calendar-grid .day.drop-target {
  border-color: var(--brand-2);
  background: #f0faf6;
  box-shadow: inset 0 0 0 2px rgba(43, 155, 110, 0.2);
}

.calendar-grid .day.outside-month {
  background: #f8faf9;
}

.calendar-grid .day.outside-month h3 {
  color: #8b979a;
}

.calendar-grid.mode-day .day {
  min-height: 520px;
}

.day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 120px;
  overflow: hidden;
}

.day h3 {
  margin: 0;
  padding: 9px 10px;
  background: #f7f9fa;
  border-bottom: 1px solid #edf1f2;
  font-size: 14px;
}

.event {
  display: block;
  margin: 8px;
  padding: 8px;
  border-left: 4px solid #778487;
  background: #fff7f1;
  border-radius: 4px;
  color: #253235;
  text-decoration: none;
}

.event[draggable="true"] {
  cursor: grab;
}

.event[draggable="true"]:active {
  cursor: grabbing;
}

.event span {
  display: block;
  margin-top: 4px;
  color: #536368;
  font-size: 12px;
  font-weight: 700;
}

.status-new-job {
  border-left-color: #e7891a;
  background: #fff6e8;
  color: #7a4306;
}

.status-estimating-complete {
  border-left-color: #1398e5;
  background: #edf8ff;
  color: #07547d;
}

.status-purchasing-complete {
  border-left-color: #c7ad00;
  background: #fffbe3;
  color: #675a00;
}

.status-in-warehouse-not-ready {
  border-left-color: #e13535;
  background: #fff0f0;
  color: #8d1d1d;
}

.status-in-warehouse-ready {
  border-left-color: #19a852;
  background: #eefaf3;
  color: #0a6830;
}

.status-in-the-field {
  border-left-color: #111618;
  background: #eef0f0;
  color: #111618;
}

.status-rough-completed,
.status-complete {
  border-left-color: #00bcd4;
  background: #e8fbff;
  color: #056170;
}

.status-not-completed {
  border-left-color: #7a4a24;
  background: #f7f0e8;
  color: #4f2d13;
}

.status-invoiced {
  border-left-color: #ff3d8d;
  background: #fff0f7;
  color: #9d0d4b;
}

.status-paid {
  border-left-color: #8c3dff;
  background: #f6f0ff;
  color: #5220a1;
}

.status-future-order {
  border-left-color: #5d7078;
  background: #f1f4f5;
  color: #344248;
}

.status-trim-scheduled,
.status-startup-scheduled {
  border-left-color: #e7891a;
  background: #fff6e8;
  color: #7a4306;
}

.status-trim-completed,
.status-startup-completed {
  border-left-color: #00bcd4;
  background: #e8fbff;
  color: #056170;
}

.status-trim-not-completed {
  border-left-color: #7a4a24;
  background: #f7f0e8;
  color: #4f2d13;
}

.event.status-in-the-field {
  border-left-width: 7px;
  background: linear-gradient(90deg, #111618 0, #111618 7px, #f1f2f2 7px);
  box-shadow: inset 0 0 0 1px rgba(17, 22, 24, 0.08);
}

.event.status-in-the-field strong {
  color: #111618;
}

.event.status-rough-completed,
.event.status-trim-completed,
.event.status-complete {
  border-left-width: 8px;
  background: linear-gradient(90deg, rgba(0, 188, 212, 0.2), #f0fdff);
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.32), 0 6px 16px rgba(0, 123, 143, 0.12);
}

.event.status-rough-completed strong,
.event.status-trim-completed strong,
.event.status-complete strong {
  color: #044f5c;
}

.event.status-rough-completed span,
.event.status-trim-completed span,
.event.status-complete span {
  display: inline-flex;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #00a7bd;
  color: #fff;
}

.event.status-not-completed,
.event.status-trim-not-completed {
  border-left-width: 8px;
  background:
    repeating-linear-gradient(135deg, rgba(122, 74, 36, 0.12) 0 6px, transparent 6px 12px),
    linear-gradient(90deg, rgba(122, 74, 36, 0.18), #fbf6ef);
  box-shadow: inset 0 0 0 1px rgba(122, 74, 36, 0.3), 0 6px 16px rgba(79, 45, 19, 0.12);
}

.event.status-not-completed strong,
.event.status-trim-not-completed strong {
  color: #3f230e;
}

.event.status-not-completed span,
.event.status-trim-not-completed span {
  display: inline-flex;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: #7a4a24;
  color: #fff;
}

.status-not-started {
  border-left-color: #5d7078;
  background: #f1f4f5;
  color: #344248;
}

.status-started-not-complete {
  border-left-color: #1398e5;
  background: #edf8ff;
  color: #07547d;
}

.status-confirmed-ready {
  border-left-color: #19a852;
  background: #eefaf3;
  color: #0a6830;
}

.status-not-ready {
  border-left-color: #e13535;
  background: #fff0f0;
  color: #8d1d1d;
}

.status-partial-ac-completed,
.status-partial-gas-completed,
.status-partial-ac-only-ready,
.status-partial-gas-only-ready {
  border-left-color: #c7ad00;
  background: #fffbe3;
  color: #675a00;
}

.detail {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(860px, 100vw);
  background: #f7f9f8;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 45px rgba(20, 32, 36, 0.18);
  z-index: 4;
  overflow: auto;
  padding: 20px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(16, 95, 104, 0.12), rgba(198, 106, 50, 0.08)),
    #fff;
}

.detail h2 {
  margin: 0;
  font-size: 22px;
}

.detail p {
  margin: 4px 0 0;
  color: #647277;
}

.project-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 2px;
  padding: 14px;
  border: 1px solid #c8ddda;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #f1faf7, #fffaf5);
  box-shadow: 0 10px 24px rgba(31, 45, 48, 0.06);
}

.project-hero div {
  min-width: 0;
  padding: 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.68);
}

.project-hero span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.project-hero b {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.project-details {
  display: grid;
  gap: 12px;
  margin: 14px 0 4px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(31, 45, 48, 0.05);
}

.detail-section::before,
.friendly-record::before,
.photo-record::before,
.file-record::before,
.serial-record::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0;
}

.tone-green::before {
  background: var(--brand-2);
}

.tone-orange::before {
  background: var(--warm);
}

.tone-blue::before {
  background: var(--blue);
}

.tone-gold::before {
  background: var(--gold);
}

.tone-red::before {
  background: var(--alert);
}

.tone-gray::before {
  background: #778487;
}

.friendly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

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

.edit-grid::before {
  content: "Editable Project Fields";
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.edit-section-title {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 8px 10px;
  border-left: 4px solid var(--brand);
  border-radius: 6px;
  background: #f3f7f7;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field.full {
  grid-column: 1 / -1;
}

.field span {
  color: #4c5d62;
  font-size: 13px;
  font-weight: 700;
}

.field button {
  justify-self: start;
}

.related {
  display: grid;
  gap: 10px;
}

.photo-record {
  position: relative;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(90deg, #fff, #f8fbfa);
  overflow: hidden;
}

.file-record {
  position: relative;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(90deg, #fff, #fffaf6);
  overflow: hidden;
}

.file-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff1e8;
  color: #9a4f25;
  border: 1px solid #edcbb9;
  font-size: 13px;
  font-weight: 800;
}

.file-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 6px;
  background: var(--brand);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.open-project {
  justify-self: start;
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.serial-record {
  position: relative;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(90deg, #fff, #f7fbff);
  overflow: hidden;
}

.file-record::before {
  background: var(--warm);
}

.serial-record::before {
  background: var(--blue);
}

.serial-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f1;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.serial-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.serial-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.photo-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f1;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.friendly-field {
  min-width: 0;
}

.friendly-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.friendly-field b {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.map-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
}

.map-card iframe {
  width: 100%;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.map-card a {
  justify-self: start;
  color: var(--brand);
  font-weight: 700;
}

.map-link {
  display: inline-flex;
  margin-top: 6px;
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.related-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  background: #fff;
}

.friendly-record {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(90deg, #fff, #fbfcfc);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  overflow: hidden;
}

.missing-material-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.missing-material-list h3 {
  margin: 0;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.missing-material-list h3 span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 50%;
  background: #e8edf0;
  color: var(--muted);
  font-size: 12px;
}

.missing-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 130px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1f2;
}

.missing-row:last-child {
  border-bottom: 0;
}

.missing-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.missing-row b {
  display: block;
  margin-top: 3px;
}

.missing-row.fulfilled {
  background: #f2fbf5;
}

.missing-row.unfulfilled {
  background: #fffaf6;
}

.log-record {
  border-left: 4px solid var(--brand-2);
}

.log-record::before {
  background: var(--brand-2);
}

.kv {
  overflow-wrap: anywhere;
}

.kv b {
  display: block;
  color: #617176;
  font-size: 12px;
}

.thumb {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fa;
}

@media (max-width: 760px) {
  .topbar,
  .detail-head {
    display: grid;
  }

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

  .filters,
  .user-form,
  .field-permission-form,
  .calendar-toolbar,
  .calendar-actions {
    grid-template-columns: 1fr;
  }

  .calendar-actions {
    display: grid;
  }

  .calendar-grid.mode-month,
  .calendar-grid.mode-week {
    grid-template-columns: 1fr;
  }

  .toolbar input {
    grid-column: 1 / -1;
  }

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

  .summary,
  .project-hero {
    grid-template-columns: 1fr 1fr;
  }

  .photo-record,
  .photo-info,
  .file-record,
  .file-info,
  .serial-record,
  .serial-info {
    grid-template-columns: 1fr;
  }

  .my-calls {
    margin: 0 10px 18px;
    padding: 10px;
  }

  .mobile-head,
  .call-card-head {
    display: grid;
  }

  .call-cards,
  .call-facts,
  .step-strip,
  .my-call-filters,
  .my-call-calendar,
  .user-row,
  .permission-row,
  .missing-row {
    grid-template-columns: 1fr;
  }
}
