* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #21252e;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #f5b800;
  --accent-2: #ffd24a;
  --border: #2a2e37;
  --radius: 14px;
  --danger: #f87171;
  --ok: #34d399;
}
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.screen { min-height: 100vh; }

/* ===== Логин ===== */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.logo { font-weight: 800; font-size: 20px; letter-spacing: -.02em; margin-bottom: 20px; }
.logo span { color: var(--accent); }
.logo.small { font-size: 16px; margin: 0; }
.login-box h1 { font-size: 22px; margin-bottom: 20px; }
.login-box [hidden] { display: none; }
#master-consent-field:not([hidden]) { display: block; margin: 0 0 12px; color: var(--muted); font-size: 13px; }
#master-consent-field a, #master-call-number { color: var(--accent); }
#master-call-number:not([hidden]) { display: block; margin-top: 12px; font-weight: 700; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.field {
  width: 100%;
  padding: 12px 14px;
  margin-top: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0b0d12;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,184,0,.15);
}
textarea.field { resize: vertical; }

.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius);
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #111;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(245,184,0,.4);
}
.btn-ghost {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-ghost.small { padding: 6px 10px; font-size: 12px; }
.msg { margin-top: 10px; font-size: 14px; }

/* ===== Кабинет ===== */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: rgba(15,17,21,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header-left { display: flex; align-items: center; gap: 12px; }
.master-name { font-size: 13px; color: var(--muted); }
.app-main { padding: 20px 16px 40px; max-width: 900px; margin: 0 auto; }
.master-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; padding: 5px; border: 1px solid var(--border); border-radius: 14px; }
.master-tabs button:not([hidden]) { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.master-tabs button:hover { color: var(--text); }
.master-tabs button[aria-selected="true"] { background: rgba(245,184,0,.12); border-color: var(--accent); color: var(--text); }
.master-tab-count:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding-inline: 4px; border-radius: 999px; background: var(--accent); color: #111; font-size: 11px; font-weight: 750; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-head h2 { font-size: 20px; letter-spacing: -.02em; }

.orders-list { display: flex; flex-direction: column; gap: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 15px; }

.order-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .15s ease;
}
.order-card:hover { border-color: rgba(245,184,0,.35); }
.order-top {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 8px;
}
.order-title { font-weight: 700; font-size: 16px; }
.order-price { color: var(--accent); font-weight: 800; white-space: nowrap; }
.order-desc { color: var(--muted); font-size: 14px; margin-bottom: 8px; line-height: 1.45; }
.order-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.order-meta a { color: #60a5fa; text-decoration: none; }
.order-meta a:hover { text-decoration: underline; }
.order-photo img { max-width: 100%; border-radius: 10px; margin-bottom: 12px; display: block; }
.order-actions { display: flex; gap: 10px; }
.order-assignment { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 12px 0; }
.order-max-status { color: var(--accent); font-size: 13px; }
.order-assignment .order-max-button { color: var(--accent); border-color: var(--accent); }
.order-dispatch-feedback { color: var(--danger); margin-top: 8px; }
#executorOrderPicker > select { margin-top: 8px; }
.order-settlement { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0; font-size: 14px; }
#assignment-fee-field[hidden] { display: none; }
#assignment-fee-field { margin-top: 12px; }
.order-actions .btn-primary { width: auto; flex: 1; margin: 0; }

/* ===== Модалка ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;   /* ← было center, стало flex-start */
  justify-content: center;
  padding: 16px; z-index: 100;
  overflow-y: auto;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;          /* ← добавь */
  overflow-y: auto;          /* ← добавь */
  margin: auto;              /* ← добавь, чтобы центрировался по вертикали */
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-box h3 { font-size: 18px; margin-bottom: 6px; }
.modal-note { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn-ghost { flex: 0 0 auto; }
.modal-actions .btn-primary { flex: 1; margin: 0; }
.client-map-dialog { width: min(680px, calc(100% - 24px)); max-width: 680px; color: var(--text); }
.client-map-dialog::backdrop { background: rgba(0,0,0,.72); }
.client-map-dialog iframe {
  display: block;
  width: 100%;
  height: min(52vh, 400px);
  border: 0;
  border-radius: 10px;
  background: var(--card);
}
.client-map-dialog .modal-actions a { display: grid; place-items: center; text-align: center; text-decoration: none; }

@media (max-width: 480px) {
  .app-header { padding: 12px; }
  .master-name { font-size: 12px; }
  .app-main { padding: 16px 12px 32px; }
  .order-card { padding: 14px; }
}
/* два блока */
.orders-section { margin-bottom: 28px; }
.count-badge {
  display: inline-block;
  background: var(--accent);
  color: #111;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* «Мои заказы» — визуально выделены */
.order-card--my {
  border-color: rgba(245,184,0,.45);
  background: linear-gradient(180deg, #221c0a 0%, var(--card) 100%);
}
.order-card--my::before {
  content: "Ваш заказ";
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.app-header-right { display: flex; align-items: center; gap: 10px; }

.online-toggle {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.online-toggle input { display: none; }

/* label — контейнер, внутри которого абсолютно позиционируем трек и кружок */
.online-toggle .online-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-left: 40px;          /* место под трек слева от текста */
  min-height: 20px;
  line-height: 20px;
}

/* трек */
.online-toggle .online-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 20px;
  background: #2a2e37;
  border-radius: 10px;
  transition: background .2s ease;
}

/* белый кружок внутри трека */
.online-toggle .online-label::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease, left .2s ease;
  z-index: 1;
}

/* включено */
.online-toggle input:checked + .online-label::before { background: var(--accent); }
.online-toggle input:checked + .online-label::after  { transform: translateY(-50%) translateX(14px); }
.online-toggle input:checked + .online-label         { color: var(--accent); }

/* ===== Выполненные (серые, потухшие) ===== */
.order-card--done {
  opacity: .55;
  background: #14161a;
  border-color: #20232a;
  cursor: default;
}
.order-card--done:hover {
  border-color: #20232a;
  transform: none;
  box-shadow: none;
}
.order-card--done .order-title { color: var(--muted); }
.order-card--done .order-price { color: var(--muted); }
.order-card--done .order-desc,
.order-card--done .order-meta { color: #5b616b; }
.order-card--done .order-photo img { filter: grayscale(1); opacity: .6; }
.order-card--done a { color: #5b616b; }
.order-done-badge {
  display: inline-block;
  padding: 8px 12px;
  background: rgba(52,211,153,.06);
  border: 1px solid rgba(52,211,153,.15);
  color: rgba(52,211,153,.55);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  width: 100%;
}
.count-badge--muted {
  background: #2a2e37;
  color: var(--muted);
}
/* ============================================================
   ГАМБУРГЕР СПРАВА + ВЫПАДАЮЩЕЕ МЕНЮ
   ============================================================ */
.master-menu-wrap {
  position: relative;
  display: inline-block;
}

.master-menu-btn {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
}
.master-menu-btn:hover { border-color: var(--accent); }
.master-menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: background .2s;
}
.master-menu-btn:hover span { background: var(--accent); }

.master-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  min-width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  overflow: hidden;
  z-index: 50;
}
.master-menu-dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.master-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: transparent;
  border: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  text-align: left;
}
.master-menu-item[hidden] { display: none; }

.master-menu-item svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.master-menu-item:hover {
  background: var(--card-2);
  color: var(--accent);
}
.tire-search-fields, .tire-search-results { display: grid; gap: 12px; }
.tire-search-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tire-search-fields label { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--card); font-size: 13px; }
.tire-search-fields select { padding-inline: 7px; color: var(--text); }
.tire-search-actions, .tire-search-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tire-search-actions .btn-primary { width: auto; margin: 0; }
.tire-search-results { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.tire-search-card { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: start; }
.tire-search-card.no-photo { grid-template-columns: minmax(0, 1fr); }
.tire-search-card img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.tire-search-card h3 { margin: 0 0 6px; font-size: 16px; overflow-wrap: anywhere; }
.tire-search-card h3 a, .tire-search-links a { color: var(--accent); }
.tire-search-card p, #tire-search-status { color: var(--muted); margin: 8px 0; }
#tire-search-more:not([hidden]) { margin-top: 12px; }

/* Кнопка "Выйти" в меню — красная, отделена линией сверху */
.master-menu-item--danger {
  border-top: 1px solid var(--border);
  color: #f87171;
}
.master-menu-item--danger:hover {
  background: rgba(248,113,113,.08);
  color: #f87171;
}
/* ============================================================
   МОИ ТОВАРЫ МАСТЕРА — компактный список
   ============================================================ */

/* #mpList — компактные строки вместо блочных карточек */
#mpList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: border-color .15s ease;
}
.mp-row:hover { border-color: rgba(245,184,0,.35); }

.mp-row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-row-title {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-row-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.mp-row-sub span { white-space: nowrap; }

.mp-row-price {
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  font-size: 15px;
}

.mp-row-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  font-weight: 700;
}
.mp-row-status--active {
  background: rgba(52,211,153,.10);
  color: var(--ok);
  border: 1px solid rgba(52,211,153,.25);
}
.mp-row-status--hidden {
  background: rgba(154,160,166,.08);
  color: var(--muted);
  border: 1px solid rgba(154,160,166,.2);
}
.mp-row-status--sold {
  background: rgba(248,113,113,.10);
  color: #f87171;
  border: 1px solid rgba(248,113,113,.3);
}
.mp-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.mp-row-actions .btn-primary,
.mp-row-actions .btn-ghost {
  padding: 6px 10px;
  font-size: 12px;
  margin: 0;
  width: auto;
}

/* На узких экранах — переносим действия на новую строку */
@media (max-width: 560px) {
  .mp-row {
    flex-wrap: wrap;
  }
  .mp-row-main { flex-basis: 100%; }
  .mp-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
.file-label {
  display: inline-block;
  padding: 10px 16px;
  border: 1px dashed #3a3f4b;
  border-radius: 10px;
  color: #9aa0a6;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .2s, color .2s;
  margin-top: 4px;
}
.file-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.master-import:not([hidden]) { display: grid; gap: 12px; }
.master-import__mapping {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 10px;
}
.master-import__mapping label { display: grid; gap: 5px; }
.master-import__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 10px; }
.master-import__table { overflow-x: auto; }
.master-import__table table { border-collapse: collapse; width: 100%; }
.master-import__table :is(th, td) { padding: 6px; border-bottom: 1px solid var(--border, #333); text-align: left; }
.master-import__table .field { min-width: 100px; }
.master-import__table textarea.field { min-width: 210px; }
.master-import__thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.master-store {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(240px, 2fr);
  gap: 18px;
  align-items: start;
}
.master-store__card {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: clamp(16px, 3vw, 24px);
}
.master-store__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.master-store__card .field-label { margin: 0; }
.master-store__location {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.master-store__location summary { cursor: pointer; }
.master-store__location .master-store__fields { margin-block: 14px; }
.master-store__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.master-store__actions button { width: auto; }
.master-store__manager { grid-column: 1 / -1; }
.master-store__manager .field-label { max-width: 340px; }
.master-store__manager p { color: var(--muted); }
.master-store__media { display: grid; gap: 9px; justify-items: start; }
.master-store__preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
}
.master-store__preview--logo { width: 112px; aspect-ratio: 1; text-align: center; }
.master-store__preview img { width: 100%; height: 100%; object-fit: cover; }
.master-store [hidden] { display: none; }
#masterStoreStatus:not(:empty) { margin-bottom: 12px; }
@media (max-width: 720px) {
  .master-store, .master-store__fields { grid-template-columns: minmax(0, 1fr); }
}
