:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --text: #20242a;
  --muted: #69707a;
  --line: #dde2e7;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #16803d;
  --blue: #2454a6;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1,
.auth-card h2,
.modal-header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page {
  width: min(1480px, calc(100vw - 40px));
  margin: 24px auto 48px;
}

.status-strip,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: min(100%, 210px);
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-pill div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.status-pill strong,
.status-pill span {
  overflow-wrap: anywhere;
}

.status-pill > div > span {
  color: #39404a;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.status-pill.ok .dot,
.badge.ok {
  background: #e7f8ee;
  color: var(--ok);
}

.status-pill.warning .dot,
.badge.warning {
  background: #fff3df;
  color: var(--warning);
}

.status-pill.danger .dot,
.badge.danger {
  background: #fde8e6;
  color: var(--danger);
}

.status-pill.ok .dot {
  background: var(--ok);
}

.status-pill.warning .dot {
  background: var(--warning);
}

.status-pill.danger .dot {
  background: var(--danger);
}

.status-meta,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card,
.table-shell,
.auth-card,
.modal-panel,
.drawer-panel,
.detail-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.toolbar {
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: #39404a;
  font-size: 13px;
  font-weight: 650;
}

.search-field {
  flex: 1;
  min-width: 260px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cdd5df;
  border-radius: 7px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: var(--accent);
}

.primary-button,
.secondary-button,
.small-button,
.text-button,
.icon-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.small-button,
.text-button,
.icon-button {
  color: var(--text);
  background: #eef1f4;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.text-button {
  padding: 0 12px;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.table-shell {
  margin-bottom: 22px;
  overflow-x: auto;
}

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

.shops-table th,
.shops-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.shops-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.shops-table th:first-child,
.shops-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 170px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}

.shops-table th:first-child {
  z-index: 3;
}

.shop-name {
  font-weight: 800;
}

.disabled-row {
  opacity: 0.64;
}

.row-actions {
  width: 1%;
  white-space: nowrap;
}

.row-actions .small-button + .small-button {
  margin-left: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.muted {
  background: #edf0f3;
  color: #58606b;
}

.switch {
  display: inline-flex;
  width: 48px;
  height: 28px;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 48px;
  height: 28px;
  background: #c9d1db;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 150px);
  place-items: center;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
}

.notice {
  padding: 12px 14px;
  border-radius: 7px;
  font-size: 13px;
}

.notice.warning {
  color: var(--warning);
  background: #fff3df;
}

.notice.danger {
  color: var(--danger);
  background: #fde8e6;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 42px 20px;
  background: rgba(21, 27, 35, 0.36);
  overflow-y: auto;
}

.modal-panel,
.drawer-panel {
  width: min(720px, 100%);
  padding: 24px;
  box-shadow: var(--shadow);
}

.drawer-panel {
  width: min(980px, 100%);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.shop-form {
  display: grid;
  gap: 14px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.detail-card {
  padding: 14px;
}

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

.detail-card strong {
  display: block;
  margin-top: 6px;
  word-break: break-word;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 7px 10px;
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.history-status-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.history-status-grid > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.historical-data-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.jobs-list {
  display: grid;
  gap: 8px;
}

.data-point-groups {
  display: grid;
  gap: 14px;
}

.data-point-group {
  display: grid;
  gap: 6px;
}

.data-point-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.data-point-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(90px, auto) minmax(220px, 1.4fr);
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.data-point-row.disabled-data-point {
  opacity: 0.72;
}

.switch-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.switch-line input {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
}

.switch-line span {
  display: grid;
  gap: 2px;
}

.switch-line small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.job-row,
.checkpoint-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(90px, auto) minmax(180px, 1.6fr);
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.checkpoint-row {
  grid-template-columns: minmax(160px, 0.6fr) minmax(220px, 1fr);
}

.job-error {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.operation-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.schedule-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.schedule-summary div {
  min-height: 88px;
  padding: 14px;
  background: #f7faf9;
  border: 1px solid #dbe7e4;
  border-radius: 8px;
}

.schedule-summary span,
.schedule-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.schedule-summary strong {
  display: block;
  margin: 6px 0;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.configured-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.schedule-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 10px;
  align-items: end;
  padding-top: 12px;
}

.schedule-details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.schedule-details summary {
  cursor: pointer;
  font-weight: 800;
  color: #39404a;
}

.schedule-form-title {
  grid-column: 1 / -1;
}

.schedule-form-title strong,
.schedule-form-title span {
  display: block;
}

.schedule-form-title span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.schedule-form .primary-button {
  justify-self: end;
}

.attention-groups,
.attention-list {
  display: grid;
  gap: 12px;
}

.attention-group {
  padding: 14px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attention-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.attention-group-header span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.attention-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(132px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px 0 0;
  border-bottom: 1px solid var(--line);
}

.attention-row:first-child {
  padding-top: 0;
}

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

.attention-row div span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.attention-row p {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  margin: -2px 0 10px;
  color: #555e69;
  font-size: 13px;
}

.attention-row p strong,
.attention-row p span {
  overflow-wrap: anywhere;
}

.empty-note {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
}

code {
  padding: 2px 5px;
  background: #edf0f3;
  border-radius: 4px;
  color: #29313a;
}

@media (max-width: 920px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .status-strip,
  .operations-grid {
    align-items: stretch;
    flex-direction: column;
  }

  .operations-grid {
    display: flex;
  }

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

  .job-row {
    grid-template-columns: 1fr;
  }

  .schedule-form,
  .schedule-summary,
  .attention-row,
  .data-point-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 18px;
  }

  .page {
    width: calc(100vw - 24px);
  }

  .metric-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
