:root {
  --font-body: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-display: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --mm-white: #ffffff;
  --mm-ink: #121417;
  --mm-text: #1f2328;
  --mm-muted: #69707d;
  --mm-line: #e5e7eb;
  --mm-soft: #f4f5f7;
  --mm-red: #e30613;
  --mm-yellow: #f5c400;
  --mm-brand: #2f333a;
  --mm-green: #14934a;
  --mm-button: #eef1f5;
  --mm-button-strong: #2f333a;
  --mm-radius: 8px;
  --mm-shadow: 0 18px 46px rgba(16, 24, 40, 0.1);
}

.pwa-install-button,
.pwa-connection-status {
  position: fixed;
  right: 12px;
  z-index: 80;
  border-radius: var(--mm-radius);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.18);
}

.pwa-install-button {
  bottom: max(12px, env(safe-area-inset-bottom));
  min-height: 42px;
  padding: 0 14px;
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border: 1px solid var(--mm-button-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.pwa-connection-status {
  left: 12px;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 54px);
  padding: 11px 12px;
  color: var(--mm-ink);
  background: #fff7d6;
  border: 1px solid #ffe08a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.master-offline-queue {
  display: grid;
  gap: 8px;
  width: calc(100% - 28px);
  margin: 0 14px 10px;
  padding: 10px;
  color: var(--mm-ink);
  background: #fff7d6;
  border: 1px solid #ffe08a;
  border-radius: var(--mm-radius);
  font-size: 12px;
  font-weight: 800;
}

.master-offline-queue__head {
  display: grid;
  gap: 3px;
}

.master-offline-queue__head span,
.master-offline-queue__item {
  color: #5f4b00;
  font-weight: 650;
}

.master-offline-queue__list {
  display: grid;
  gap: 4px;
}

.master-offline-queue__item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.master-offline-queue__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.master-offline-queue__actions button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-radius: var(--mm-radius);
  font: inherit;
  font-size: 12px;
  font-weight: 850;
}

.master-offline-queue__actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  text-size-adjust: 100%;
}

body.master-mobile-page {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--mm-text);
  background: var(--mm-soft);
  font-family: var(--font-body);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.master-phone-shell {
  width: min(100%, 540px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--mm-white);
}

.master-login {
  display: grid;
  align-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 212, 0, 0.22), rgba(255, 255, 255, 0) 260px),
    var(--mm-white);
}

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

.master-login-brand span {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: transparent;
  background: url("./assets/remontkey-mark.svg") center / contain no-repeat;
  border-radius: var(--mm-radius);
  font-size: 0;
}

.master-login-brand span i {
  display: none;
}

.master-login h1,
.master-app h2 {
  margin: 0;
  color: var(--mm-ink);
  font-weight: 950;
  line-height: 1;
}

.master-login h1 {
  font-size: clamp(34px, 10vw, 48px);
  text-transform: uppercase;
}

.master-login p,
.master-app-status {
  margin: 0;
  color: var(--mm-muted);
  font-size: 14px;
  font-weight: 500;
}

.master-login p.is-error,
.master-app-status.is-error {
  color: var(--mm-red);
}

.master-login p.is-ok,
.master-app-status.is-ok {
  color: var(--mm-green);
}

.master-pin-form {
  display: grid;
  gap: 12px;
}

.master-pin-form label {
  color: var(--mm-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.master-pin-form input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  color: var(--mm-ink);
  background: var(--mm-white);
  border: 2px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-align: center;
  outline: 0;
}

.master-pin-form input:focus {
  border-color: var(--mm-red);
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.08);
}

.master-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.master-keypad button {
  display: grid;
  min-height: 58px;
  place-items: center;
  color: var(--mm-ink);
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 22px;
  font-weight: 950;
}

.master-keypad button[type="submit"] {
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-color: var(--mm-button-strong);
}

.master-app {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
}

.master-app-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 12px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--mm-line);
  backdrop-filter: blur(14px);
}

.master-app-head span {
  display: block;
  margin-bottom: 4px;
  color: var(--mm-brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.master-app-head small {
  display: block;
  max-width: 310px;
  margin-top: 4px;
  color: var(--mm-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.master-app h2 {
  font-size: 26px;
}

.master-head-actions {
  display: flex;
  gap: 8px;
}

.master-head-actions button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--mm-ink);
  background: var(--mm-button);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 16px;
}

.master-app-status {
  min-height: 20px;
  margin: 12px 0;
}

.master-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.master-stats article {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 12px;
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-left: 4px solid var(--mm-red);
  border-radius: var(--mm-radius);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}

.master-stats article:nth-child(3) {
  border-left-color: var(--mm-yellow);
}

.master-stats span {
  color: var(--mm-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.master-stats strong {
  color: var(--mm-ink);
  font-size: 30px;
  line-height: 1;
}

.master-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 12px 0;
}

.master-today-panel {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  padding: 12px;
  color: var(--mm-ink);
  background: linear-gradient(135deg, #fff8bf, #ffffff 72%);
  border: 1px solid #f0d94f;
  border-radius: var(--mm-radius);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}

.master-today-panel span {
  color: var(--mm-red);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.master-today-panel strong {
  color: var(--mm-ink);
  font-size: 17px;
  font-weight: 950;
  line-height: 1.15;
}

.master-today-panel p {
  margin: 0;
  color: var(--mm-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

.master-today-actions:empty {
  display: none;
}

.master-today-actions a {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border: 1px solid var(--mm-button-strong);
  border-radius: var(--mm-radius);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.master-schedule-panel {
  display: grid;
  gap: 9px;
  margin: 12px 0;
  padding: 12px;
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
}

.master-schedule-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.master-schedule-head strong {
  color: var(--mm-ink);
  font-size: 14px;
  font-weight: 750;
}

.master-schedule-head span {
  max-width: 230px;
  color: var(--mm-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-align: right;
}

.master-schedule-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.master-schedule-days {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.master-schedule-days label {
  display: grid;
  min-height: 34px;
  place-items: center;
  color: var(--mm-muted);
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 11px;
  font-weight: 700;
}

.master-schedule-days label:has(input:checked) {
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-color: var(--mm-button-strong);
}

.master-schedule-days input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.master-schedule-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--mm-ink);
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font: inherit;
  font-size: 13px;
  outline: 0;
}

.master-schedule-form input[type="text"],
.master-schedule-form button {
  grid-column: 1 / -1;
}

.master-schedule-form button {
  min-height: 40px;
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border: 1px solid var(--mm-button-strong);
  border-radius: var(--mm-radius);
  font-size: 13px;
  font-weight: 700;
}

.master-tabs button {
  min-height: 38px;
  padding: 0 4px;
  color: var(--mm-ink);
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 11px;
  font-weight: 650;
}

.master-tabs button.is-active {
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-color: var(--mm-button-strong);
}

.master-list {
  display: grid;
  gap: 10px;
}

.master-event-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  box-shadow: var(--mm-shadow);
}

.master-event-top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.master-event-card h3 {
  margin: 0;
  color: var(--mm-ink);
  font-size: 18px;
  font-weight: 750;
  line-height: 1.12;
}

.master-event-card time,
.master-event-card small,
.master-event-meta {
  color: var(--mm-muted);
  font-size: 12px;
  line-height: 1.35;
}

.master-badge {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 4px 7px;
  color: var(--mm-white);
  background: var(--mm-red);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}

.master-badge.is-in_progress {
  color: var(--mm-ink);
  background: var(--mm-yellow);
}

.master-badge.is-accepted,
.master-badge.is-en_route,
.master-badge.is-arrived,
.master-badge.is-started {
  color: var(--mm-ink);
  background: #eef1f5;
}

.master-badge.is-done {
  color: var(--mm-green);
  background: #eaf7ef;
}

.master-badge.is-declined {
  color: #6b7280;
  background: #eef1f5;
}

.master-event-details {
  display: grid;
  gap: 5px;
}

.master-event-details span {
  color: var(--mm-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

.master-card-actions:empty {
  display: none;
}

.master-card-actions a,
.master-card-actions button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  color: var(--mm-ink);
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.master-card-actions a:first-child {
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-color: var(--mm-button-strong);
}

.master-work-actions {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.master-payment-info,
.master-checklist,
.master-work-act {
  display: grid;
  gap: 7px;
  padding: 10px;
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
}

.master-payment-info strong,
.master-checklist strong,
.master-work-act strong {
  color: var(--mm-ink);
  font-size: 13px;
  font-weight: 800;
}

.master-payment-info span,
.master-work-act span {
  color: var(--mm-text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.master-checklist-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.master-checklist-list span {
  min-height: 30px;
  padding: 7px 8px;
  color: #5f4b00;
  background: #fff7d6;
  border: 1px solid #ffe08a;
  border-radius: var(--mm-radius);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
}

.master-checklist-list span.is-done {
  color: var(--mm-green);
  background: #eaf7ef;
  border-color: #bfe8cf;
}

.master-decline-reason {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--mm-text);
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font: inherit;
  font-size: 14px;
}

.master-work-act div {
  display: grid;
  gap: 4px;
}

.master-photo-report {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
}

.master-photo-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.master-photo-head strong,
.master-photo-slot strong {
  color: var(--mm-ink);
  font-size: 13px;
  font-weight: 750;
}

.master-photo-head span,
.master-photo-note {
  color: var(--mm-muted);
  font-size: 11px;
  font-weight: 500;
}

.master-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.master-photo-slot {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 9px;
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
}

.master-photo-slot a {
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: 6px;
}

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

.master-photo-upload {
  position: relative;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-radius: var(--mm-radius);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.master-photo-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.master-work-actions textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  padding: 10px;
  color: var(--mm-text);
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  outline: 0;
}

.master-work-actions textarea:focus {
  border-color: var(--mm-red);
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.08);
}

.master-work-actions button,
.master-work-buttons button {
  min-height: 40px;
  padding: 0 10px;
  color: var(--mm-ink);
  background: var(--mm-soft);
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius);
  font-size: 13px;
  font-weight: 700;
}

.master-work-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.master-work-buttons button:first-child,
.master-work-actions > button {
  color: var(--mm-white);
  background: var(--mm-button-strong);
  border-color: var(--mm-button-strong);
}

.master-empty {
  padding: 22px 14px;
  color: var(--mm-muted);
  background: var(--mm-white);
  border: 1px dashed var(--mm-line);
  border-radius: var(--mm-radius);
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

@media (min-width: 541px) {
  body.master-mobile-page {
    padding: 18px;
  }

  .master-phone-shell {
    overflow: hidden;
    border: 1px solid var(--mm-line);
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(16, 24, 40, 0.14);
  }
}
