/* ==========================
   ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ
   ========================== */
:root {
  --bg-color: #ffffff;
  --bg-dots-color: rgba(0, 0, 0, 0.17);

  --text-main: #1f2937;
  --text-muted: #6b7280;

  --card-border: #ff8a00;
  --card-shadow: rgba(0, 0, 0, 0.16);

  --primary: #ff8a00;
  --primary-dark: #cc6c00;

  --radius-lg: 22px;
  --radius-sm: 14px;
}

/* Тёмная тема: переопределяем только переменные */
body.theme-dark {
  --bg-color: rgba(10, 10, 9, 0.8);         /* новый фон */
  --bg-dots-color: rgba(55, 55, 55, 0.5);   /* новые точки */

  --text-main: #f9fafb;
  --text-muted: #9ca3af;

  --card-border: #c0c0c0; /* серебро */
  --card-shadow: rgba(0, 0, 0, 0.7);
  --surface-dark: rgba(46, 59, 81, 1);   /* единый цвет всех поверхностей */
}

/* ==========================
   БАЗА
   ========================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-color);
  background-image: radial-gradient(var(--bg-dots-color) 2px, transparent 2px);
  background-size: 20px 20px;
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
}

/* Плавный переход цветов при смене темы */
/* Плавный переход цветов и фильтров при смене темы */
body,
.card,
.header,
.tile,
.order-card,
.map-section,
.help-section,
.modal-content,
.section-modal-content,
.profile-modal-content,
.support-modal .modal-content,
.header-menu,
.map-container,
.details-map {
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
}
.screen.visible {
  display: block;
}

/* ==========================
   ШАПКА
   ========================== */
.header {
  position: sticky;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 18px;
  top: 0;
  z-index: 30;
  background: #ff8a00;
  color: #111827;
  border-bottom: none;
  border-radius: 0 0 26px 26px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}

body.theme-dark .header-title {
  color: #f9fafb;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 40px;
  height: 40px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

/* Кнопка меню */
.icon-button {
  width: 38px;
  height: 38px;
  background: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.22);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.icon-button:active {
  transform: scale(0.92);
}

/* Выпадающее меню */
.header-menu {
  position: absolute;
  top: 60px;
  right: 16px;
  background: #fff;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.15);
  padding: 6px;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 40;
}

#header-menu.hidden {
  display: block;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.menu-item {
  padding: 10px 16px;
  font-size: 15px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
}

.menu-item:hover {
  background: #f8f8f8;
}

body.theme-dark .menu-item {
  color: var(--text-main);
}

body.theme-dark .menu-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* ==========================
   ГЛАВНЫЙ ЭКРАН, ПЛИТКИ, КАРТА
   ========================== */
#main-screen {
  padding-bottom: 24px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

.card {
  background: #fff;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 6px 6px 0 var(--card-shadow);
}

/* Карточки в тёмной теме */
body.theme-dark .card {
  background: #111827;
  border-color: var(--card-border);
}

/* Плитки */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 20px 10px 12px;   /* плитка стала ниже */
  margin-top: 22px;          /* место сверху для иконки, которая вылезает за край */
  text-align: center;
  transition: transform 0.1s ease;
}

.tile:active {
  transform: scale(0.96);
}

.tile-icon {
  position: absolute;
  top: -22px;                /* выталкиваем иконку наверх за пределы плитки */
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
}

/* Увеличенная иконка для "Интересные" */
#interesting-section .tile-icon {
  width: 48px;
  height: 48px;
}

.tile-title {
  margin-top: 10px;          /* отступ от иконки до текста */
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

/* Кружок-счётчик заказов на плитке */
.tile-badge {
  position: absolute;
  top: 8px;
  left: 10px;

  min-width: 22px;
  height: 22px;
  padding: 0 6px;

  display: none;                /* по умолчанию скрыт */
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;

  font-size: 12px;
  font-weight: 700;
  line-height: 1;

  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* Когда есть заказы — показываем кружок */
.tile-badge--visible {
  display: flex;
}

/* Для тёмной темы чуть корректируем тень, но сам цвет тот же */
body.theme-dark .tile-badge {
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
}

/* В тёмной теме glow чуть мягче и теплее */
body.theme-dark .tile-badge--visible::before {
  background: rgba(255, 170, 90, 0.9);
}

body.theme-dark .tile-badge--visible::after {
  background: rgba(255, 190, 120, 0.7);
}

/* КАРТА */
.map-section {
  margin: 0 16px 20px;
  padding: 16px;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.map-header h2 {
  font-size: 17px;
  margin: 0;
}

.chip {
  background: #f3f3f3;
  border: 1px solid #ddd;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.map-container {
  width: 100%;
  height: 260px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid #ddd;
  /* плавная смена фильтра */
  transition: filter 0.25s ease;
}

body.theme-dark .map-container {
  border-color: var(--card-border);
}

.help-section{
  position: relative;        /* ВАЖНО: не fixed и не sticky */
  z-index: 1;                /* ниже любых оверлеев */
  margin: 14px 16px 16px;
  padding: 12px 14px;
  background: #fff;          /* светлая поверхность */
  border: 2px solid var(--card-border);  /* фирменная рамка как у карточек */
  border-radius: 18px;
  box-sizing: border-box;
  box-shadow: 6px 6px 0 var(--card-shadow); /* чтобы было консистентно с .card */
}

.help-text {
  font-size: 14px;
  color: var(--text-main);
}

.help-btn {
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.help-btn:active {
  transform: scale(0.95);
}

/* ==========================
   СПИСКИ ЗАКАЗОВ
   ========================== */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.order-card {
  border-radius: 18px;
  padding: 10px 12px;
  background: #ffffff;
  border: 2px solid var(--card-border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
  transition: transform 0.08s ease-out, box-shadow 0.12s ease-out;
}

.order-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.order-card:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.order-status {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f3f3f3;
}

/* Назначен — Текущие заказы (оранжевый) */
.order-status--assigned {
  border-color: rgba(255, 138, 0, 0.6);
  background: rgba(255, 138, 0, 0.12);
  color: #b45309;
}

/* Доступен — Интересные заказы (голубой) */
.order-status--available {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.16);
  color: #075985;
}

/* Отложен */
.order-status--postponed {
  border-color: rgba(129, 140, 248, 0.7);
  background: rgba(129, 140, 248, 0.18);
  color: #3730a3;
}

/* Завершён */
.order-status--done {
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

/* Отменён */
.order-status--cancelled {
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(248, 113, 113, 0.14);
  color: #991b1b;
}

/* Статусы заказов в тёмной теме — делаем их ярче и читабельнее */
body.theme-dark .order-status--assigned,
body.theme-dark .details-status--assigned {
  background: rgba(251, 146, 60, 0.25);
  border-color: rgba(251, 191, 36, 0.9);
  color: #ffedd5;
}

body.theme-dark .order-status--available,
body.theme-dark .details-status--available {
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.9);
  color: #e0f2fe;
}

body.theme-dark .order-status--postponed,
body.theme-dark .details-status--postponed {
  background: rgba(129, 140, 248, 0.25);
  border-color: rgba(129, 140, 248, 0.9);
  color: #e0e7ff;
}

body.theme-dark .order-status--done,
body.theme-dark .details-status--done {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.9);
  color: #bbf7d0;
}

body.theme-dark .order-status--cancelled,
body.theme-dark .details-status--cancelled {
  background: rgba(248, 113, 113, 0.25);
  border-color: rgba(248, 113, 113, 0.9);
  color: #fee2e2;
}

.order-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.order-address {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================
   МОДАЛКИ
   ========================== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
}

.modal:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: #fff;
  border: 2px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: calc(100% - 40px);
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: 6px 6px 0 var(--card-shadow);
}

/* Модалка списка заказов */
.section-modal-header {
  position: relative;
  text-align: center;
  margin-bottom: 10px;
}

.section-modal-header .card-label {
  display: none;
}

.section-modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.section-modal-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: #f3f3f3;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Крестик в модалке деталей */
#details-x-close.section-modal-close {
  top: 10px;
  right: 10px;
}

body.theme-dark .section-modal-close {
  background: #111827;
  color: #f9fafb;
}

/* Пилюля статуса в модалке деталей */
.details-status-pill {
  display: inline-block;
  margin: 0 auto 12px auto;       /* центровка + отступ вниз */
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
  color: var(--text-main);
  background: rgba(0,0,0,0.15);
  position: relative;
}

/* Контейнер заголовка модалки — делаем вертикальный стек */
.details-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;          /* небольшой отступ между пилюлей и названием */
}

.details-status--assigned {
  background: rgba(255, 138, 0, 0.15);
  border-color: rgba(255, 138, 0, 0.6);
  color: #b45309;
}

.details-status--available {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.6);
  color: #075985;
}

.details-status--postponed {
  background: rgba(129, 140, 248, 0.22);
  border-color: rgba(129, 140, 248, 0.7);
  color: #3730a3;
}

.details-status--done {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.7);
  color: #166534;
}

.details-status--cancelled {
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.7);
  color: #991b1b;
}

.details-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.details-value {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 8px;
}

/* Карта в деталях */
.details-map-wrapper {
  position: relative;
  margin-top: 8px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--card-border);
  cursor: pointer;
}

.details-map {
  width: 100%;
  height: 180px;
  background: #f3f3f3;
  transition: filter 0.25s ease;
}

/* Карты в тёмной теме: имитируем ночной режим фильтром */
body.theme-dark .map-container,
body.theme-dark .details-map {
  filter: invert(0.9) hue-rotate(180deg) saturate(1.05) brightness(0.95);
}

/* Чтобы рамка вокруг карты оставалась аккуратной */
body.theme-dark .map-container {
  border-color: var(--card-border);
}

.details-map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0)
  );
  pointer-events: auto;
}

.details-map-overlay-text {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
}

/* Кнопки в модалках */
.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.modal-buttons.single {
  justify-content: flex-end;
}

.modal-buttons .btn {
  flex: 1 1 0;
  min-width: 0;
}

.modal-buttons .btn.ghost {
  flex: 0 0 auto;
  padding-inline: 14px;
  align-self: flex-end;
}

/* Кнопки */
.btn {
  border-radius: 999px;
  border: none;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.06s ease,
    box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn.primary {
  background: #ff8a00;
  color: #ffffff;
  font-weight: 600;
  border: none;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
}

.btn.primary:hover {
  filter: brightness(1.03);
}

.btn.secondary {
  background: #f3f3f3;
  border: 1px solid #d4d4d4;
  color: #111827;
  font-weight: 500;
}

.btn.ghost {
  background: transparent;
  border: none;
  color: #6b7280;
  font-weight: 500;
}

/* ==========================
   ПРОФИЛЬ / ПОДДЕРЖКА
   ========================== */
.profile-row {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.profile-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 3px;
}

.profile-input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #111827;
  padding: 9px 11px;
  font-size: 14px;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

.profile-input:focus {
  outline: none;
  border-color: #ff8a00;
  box-shadow: 0 0 0 1px rgba(255, 138, 0, 0.3);
  background: #ffffff;
}

.profile-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Фуллскрин карта */
.modal-fullscreen-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.fullscreen-map {
  width: 100%;
  height: 100%;
}

.fullscreen-back {
  position: absolute;
  top: 16px;
  left: 16px;
  background: #fff;
  border-radius: 20px;
  border: 1px solid #ddd;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

/* ====== Профиль ====== */

/* Поле ввода в поддержке */
#support-text {
  display: block;
  width: 100%;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #111827;
  padding: 9px 11px;
  font-size: 14px;
  resize: vertical;
  min-height: 80px;
}

.profile-modal-content {
  width: 90%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
}

.profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.text-btn {
  background: none;
  border: none;
  color: #2d8cff;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
}

.profile-block {
  margin-bottom: 16px;
}

.profile-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profile-value {
  font-size: 16px;
  color: var(--text-main);
  padding: 6px 0;
}

.profile-input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ddd;
  display: none; /* скрыты в режиме просмотра */
  font-size: 16px;
}

.profile-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

#profile-save-btn {
  display: none; /* появится только в режиме редактирования */
}

/* ===== Профиль: "Моя техника" (сворачиваемые карточки) ===== */

.tech-unit {
  cursor: pointer;
  user-select: none;
}

.tech-unit-type {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 2px;
}

.tech-unit-model {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 8px;
}

.tech-unit-row {
  font-size: 14px;
  line-height: 1.35;
}

/* по умолчанию скрываем "Работы" */
.tech-unit.is-collapsed .tech-unit-row--works {
  display: none;
}

/* когда открыто — показываем */
.tech-unit.is-open .tech-unit-row--works {
  display: block;
}

/* маленький индикатор раскрытия */
.tech-unit-type::after {
  content: " ▾";
  opacity: 0.6;
  font-weight: 600;
}

.tech-unit.is-open .tech-unit-type::after {
  content: " ▴";
}

/* Анимации */
@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =============  ТЁМНАЯ ТЕМА: ЕДИНЫЙ ФОН ПОВЕРХНОСТЕЙ  ============= */

/* ШАПКА */
body.theme-dark .header {
  background: var(--surface-dark);
}

/* Плитки */
body.theme-dark .tile {
  background: var(--surface-dark);
  border-color: var(--card-border);
}

/* Карточки заказов */
body.theme-dark .order-card {
  background: var(--surface-dark);
  border-color: var(--card-border);
}

/* Контейнер секции карты */
body.theme-dark .map-section.card {
  background: var(--surface-dark);
  border-color: var(--card-border);
}

/* Плашка "Заказов: N" */
body.theme-dark .chip {
  background: var(--surface-dark);
  color: var(--text-main);
  border-color: #4b5563;
}

/* Модалки (все) */
body.theme-dark .modal-content {
  background: var(--surface-dark);
  border-color: var(--card-border);
  color: var(--text-main);
}

/* Модалка профиля */
body.theme-dark .profile-modal-content {
  background: var(--surface-dark);
}

/* Меню (кнопка “≡” и выпадающее) */
body.theme-dark .header-menu {
  background: var(--surface-dark);
  border-color: var(--card-border);
}

body.theme-dark .icon-button {
  background: var(--surface-dark);
  color: var(--text-main);
  border: 1px solid rgba(255,255,255,0.35);
}

/* Блок помощи */
body.theme-dark .help-section {
  background: var(--surface-dark);
  border-color: var(--card-border);
}

/* Модалка помощи */
body.theme-dark .support-modal .modal-content {
  background: var(--surface-dark);
}

/* Кнопки ghost (например, “Закрыть”) */
body.theme-dark .btn.ghost {
  color: var(--text-main);
}

/* Перекрытие карты в деталях */
body.theme-dark .details-map-overlay {
  background: linear-gradient(
    to bottom,
    rgba(46,59,81,0.88),
    rgba(46,59,81,0)
  );
}

body.theme-dark .details-map-overlay-text {
  color: var(--text-main);
}

/* Секция списка заказов */
body.theme-dark .section-modal-content {
  background: var(--surface-dark);
  color: var(--text-main);
}

/* Минимальные стили для списка техники */
.profile-tech-units {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.tech-unit {
  padding: 12px;
}

.tech-unit-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.tech-unit-row {
  font-size: 14px;
  line-height: 1.35;
  margin-top: 4px;
}

.muted {
  opacity: 0.7;
}

#add-tech-mods-selected .tech-unit-row { padding: 6px 0; }

#add-tech-mods-selected .muted {
  padding: 6px 0;
  display: block;
}

#add-tech-mod-picker {
  width: 100%;
}

.help-section .help-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.help-section .help-text{
  margin:0;
  flex:1;
}