/* Веб-панель администрации рынка. Собственный CSS без фреймворка (ТЗ-02 п. 5.1).
   Адаптивная: ≥901px — сайдбар, ≤900px — шторка; ≤700px — таблицы-карточки. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f2f4f3; --card: #ffffff; --border: #e4e8e6; --border-strong: #d3dad6;
  --text: #1a2420; --muted: #67746e;
  --accent: #0b6e4f; --accent-dark: #095c42; --accent-soft: #e7f1ec;
  --danger: #b42318; --warn: #b25e09; --ok: #0b6e4f;
  --radius: 12px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 32, 26, .05), 0 1px 6px rgba(16, 32, 26, .04);
}
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5;
  min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ================= Каркас ================= */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: #0f221a; color: #c8dcd3; flex-shrink: 0;
  display: flex; flex-direction: column; }
.sidebar .brand { padding: 20px 18px 16px; font-size: 16px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: .01em;
  display: flex; justify-content: space-between; align-items: center; }
.sidebar nav { padding: 12px 8px; flex: 1; }
.sidebar nav a { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; margin: 1px 0; color: #c8dcd3; font-size: 14px; border-radius: 8px; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar .section { padding: 16px 12px 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .1em; color: #6f8a7f; font-weight: 600; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08);
  display: none; justify-content: space-between; font-size: 13.5px; color: #9db3a9; }
.sidebar-footer a { color: #fff; }
.drawer-close { display: none; background: none; border: none; color: #9db3a9;
  font-size: 17px; cursor: pointer; padding: 4px 8px; }
.drawer-overlay { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 24px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30; }
.topbar .user { color: var(--muted); font-size: 13.5px; margin-left: auto; }
.topbar-title { font-weight: 700; font-size: 15.5px; display: none; }
.burger { display: none; position: relative; background: none; border: none;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 4.5px; }
.burger span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.burger:hover { background: #f0f3f1; }
.burger-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: #d64541; }
.content { padding: 26px 30px 70px; max-width: 1280px; width: 100%; }

.badge { display: inline-block; min-width: 21px; text-align: center; padding: 2px 7px;
  border-radius: 999px; background: #d64541; color: #fff; font-size: 11.5px;
  font-weight: 700; }
.badge.zero { background: rgba(255,255,255,.14); color: #9db3a9; }

/* ================= Типографика ================= */
h1 { font-size: 23px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 18px;
  text-wrap: balance; }
h2 { font-size: 16px; font-weight: 650; margin: 24px 0 10px; }

.page-head { display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 0; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ================= Карточки-показатели ================= */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card .label { color: var(--muted); font-size: 12.5px; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.card .value { font-size: 25px; font-weight: 700; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .value.danger { color: var(--danger); }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 20px 14px; margin-bottom: 22px; overflow-x: auto; box-shadow: var(--shadow); }
.panel > h2:first-child { margin-top: 16px; }
.panel > form { margin-top: 14px; }

/* ================= Таблицы ================= */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7faf8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ================= Статусы ================= */
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap; }
.status.unpaid, .status.pending { background: #fdf3e5; color: var(--warn); }
.status.partial { background: #e7effc; color: #1d4fa1; }
.status.paid, .status.confirmed, .status.active, .status.free { background: var(--accent-soft); color: var(--ok); }
.status.overdue, .status.rejected, .status.archived { background: #fceceb; color: var(--danger); }
.status.cancelled, .status.withdrawn, .status.reversed, .status.suspended,
.status.repair { background: #eef1f0; color: var(--muted); }
.status.occupied { background: #e7effc; color: #1d4fa1; }

/* ================= Кнопки и формы ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; height: 40px;
  padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .12s ease; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; }
.btn:hover { background: #f2f5f3; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; box-shadow: 0 1px 2px rgba(11, 110, 79, .35); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #edcac7; }
.btn.danger:hover { background: #fceceb; }
.btn.small { height: 32px; padding: 0 11px; font-size: 13px; }

form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.toolbar .spacer { flex: 1; }

input[type=text], input[type=number], input[type=date], input[type=month],
input[type=password], select, textarea {
  height: 40px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 15px; background: #fff;
  font-family: inherit; color: var(--text); max-width: 100%; }
input[type=file] { font-size: 13.5px; max-width: 100%; }
select { -webkit-appearance: none; appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2367746e' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
textarea { height: auto; min-height: 90px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, .14); }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

/* ================= Сообщения ================= */
.messages { margin-bottom: 16px; }
.messages .msg { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 8px;
  font-size: 14px; border: 1px solid transparent; }
.msg.success { background: var(--accent-soft); color: var(--ok); border-color: #cbe5da; }
.msg.error { background: #fceceb; color: var(--danger); border-color: #f2d2cf; }
.msg.warning { background: #fdf3e5; color: var(--warn); border-color: #f1ddbe; }

/* ================= Пагинация ================= */
.pagination { display: flex; gap: 6px; margin: 14px 0 4px; align-items: center;
  font-size: 13.5px; flex-wrap: wrap; }
.pagination a, .pagination span.current { padding: 6px 12px; border: 1px solid var(--border-strong);
  border-radius: 7px; background: #fff; }
.pagination span.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .muted { border: none; }

/* ================= Чеки и модалка ================= */
.receipt-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: zoom-in; }
.receipt-full { max-width: 100%; max-height: 75vh; border-radius: var(--radius);
  border: 1px solid var(--border); }
.modal { display: none; position: fixed; inset: 0; background: rgba(10, 20, 16, .8);
  z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal img { max-width: 96%; max-height: 92vh; border-radius: 8px; }

/* ================= Вход ================= */
.login-page { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px; }
.login-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 34px 30px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-box h1 { text-align: center; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 8px; }

/* ================= Разное ================= */
.muted { color: var(--muted); font-size: 13px; }
.amount-input { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }

/* Вкладки раздела «Финансы» */
.fin-tabs { display: flex; gap: 2px; margin-bottom: 20px;
  background: #e8ecea; border-radius: 10px; padding: 3px; width: fit-content;
  max-width: 100%; overflow-x: auto; }
.fin-tabs a { padding: 9px 20px; font-size: 14px; font-weight: 600; color: var(--muted);
  border-radius: 8px; white-space: nowrap; }
.fin-tabs a:hover { color: var(--text); text-decoration: none; }
.fin-tabs a.is-active { color: var(--accent); background: var(--card);
  box-shadow: 0 1px 3px rgba(16, 32, 26, .12); }

/* ================= Настройки: внутренняя навигация ================= */
.st-layout { display: grid; grid-template-columns: 224px minmax(0, 640px); gap: 22px;
  align-items: start; }
.st-nav { position: sticky; top: 76px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; }
.st-nav button { display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 12px; border: none; background: none; border-radius: var(--radius-sm);
  font: 500 14px/1.3 inherit; font-family: inherit; color: var(--muted); cursor: pointer;
  text-align: left; white-space: nowrap; }
.st-nav button svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .75; }
.st-nav button:hover { background: #f2f5f3; color: var(--text); }
.st-nav button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.st-nav button.is-active svg { opacity: 1; }
.st-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.st-section { display: none; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); }
.st-section.is-active { display: block; }
.st-section header { margin-bottom: 22px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border); }
.st-section header h2 { margin: 0 0 6px; font-size: 18px; }
.st-section header p { color: var(--muted); font-size: 13.5px; }

.st-field { margin-bottom: 18px; }
.st-field label { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.st-field input[type=text], .st-field input[type=number] { width: 100%; height: 42px; }
.st-field textarea { min-height: 96px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.st-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.day-input { display: flex; align-items: center; gap: 10px; }
.day-input input { width: 90px !important; text-align: center; font-weight: 600; font-size: 16px; }
.day-input span { color: var(--muted); font-size: 13px; white-space: nowrap; }

.qr-block { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 20px;
  flex-wrap: wrap; }
.qr-preview { width: 132px; height: 132px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  text-align: center; background: #fafcfb; flex-shrink: 0; overflow: hidden;
  color: var(--muted); font-size: 12.5px; }
.qr-preview img { width: 100%; height: 100%; object-fit: contain; }
.file-btn { cursor: pointer; }

.switch-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px;
  font-size: 14.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.switch-row .hint { font-weight: 400; }
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; display: inline-block;
  margin-top: 1px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: #cfd6d2;
  transition: background .15s ease; }
.switch .slider::before { content: ''; position: absolute; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(11,110,79,.25); }

.st-save { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }

/* =========================================================
   Планшет: ≤1024px
   ========================================================= */
@media (max-width: 1024px) {
  .content { padding: 20px 20px 60px; }
  .sidebar { width: 212px; }
}

/* =========================================================
   Шторка вместо сайдбара: ≤900px
   ========================================================= */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 84vw);
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,.25); overflow-y: auto; }
  body.drawer-open .sidebar { transform: translateX(0); }
  .drawer-overlay { display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(12, 22, 18, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s ease; }
  body.drawer-open .drawer-overlay { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .drawer-close { display: block; }
  .sidebar-footer { display: flex; }
  .sidebar nav a { padding: 13px 14px; font-size: 15px; }

  .burger { display: flex; }
  .topbar { padding: 8px 14px; }
  .topbar-title { display: block; }
  .topbar .user { display: none; }

  .st-layout { grid-template-columns: 1fr; }
  .st-nav { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; }
  .st-nav button { width: auto; flex-shrink: 0; }
}

/* =========================================================
   Телефон: ≤700px
   ========================================================= */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .content { padding: 16px 12px 56px; }
  h1 { font-size: 20px; margin-bottom: 14px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 14px 16px; }
  .card .value { font-size: 21px; }
  .panel { padding: 4px 14px 10px; border-radius: 10px; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { width: 100%; }
  .page-head .actions form { flex: 1; display: flex; }
  .page-head .actions .btn { flex: 1; width: 100%; }

  .toolbar { padding: 10px; }
  .toolbar > input, .toolbar > select { flex: 1 1 46%; min-width: 130px; }
  .toolbar > .btn { flex: 1 1 100%; }
  .filters { gap: 8px; }
  .filters input[type=text], .filters select { flex: 1 1 46%; min-width: 120px; }

  .fin-tabs { width: 100%; }
  .fin-tabs a { flex: 1; text-align: center; padding: 9px 8px; }

  .st-section { padding: 18px 16px; }
  .st-row { grid-template-columns: 1fr; }
  .st-save .btn { width: 100%; }

  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }

  /* --- Таблицы-карточки: таблица с классом t-cards раскладывается в карточки.
         Подписи ячеек берутся из data-label. --- */
  table.t-cards, table.t-cards tbody { display: block; }
  table.t-cards tr:first-child:not([data-card]) { display: none; }
  table.t-cards tr { display: block; border: 1px solid var(--border);
    border-radius: 10px; margin: 10px 0; padding: 6px 12px; background: #fff; }
  table.t-cards tr:hover td { background: none; }
  table.t-cards td { display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f3f1; text-align: right; }
  table.t-cards td:last-child { border-bottom: none; }
  table.t-cards td::before { content: attr(data-label); color: var(--muted);
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    text-align: left; flex-shrink: 0; }
  table.t-cards td:not([data-label]) { justify-content: flex-end; }
  table.t-cards td:not([data-label])::before { content: none; }
  table.t-cards td.t-title { justify-content: flex-start; text-align: left;
    font-weight: 600; font-size: 15px; padding-top: 10px; }
  table.t-cards td.t-title::before { content: none; }
  table.t-cards td:empty { display: none; }
}

/* Тач-устройства: увеличенные зоны нажатия */
@media (pointer: coarse) {
  .btn.small { height: 36px; }
  .receipt-thumb { width: 54px; height: 54px; }
}

/* ================= Карта рынка: редактор в стиле Figma ================= */
.map-app { display: flex; flex-direction: column;
  height: calc(100vh - 130px); min-height: 480px; }

.map-topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 0 0 12px; }
.map-topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.map-topbar-right { display: flex; align-items: center; gap: 10px; }
.map-search-box input { width: 250px; max-width: 100%; }

.map-zoom-group { display: flex; align-items: center; background: var(--card);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.map-zoom-group button { height: 38px; min-width: 38px; padding: 0 10px; border: none;
  background: none; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer;
  font-family: inherit; }
.map-zoom-group button + button { border-left: 1px solid var(--border); }
.map-zoom-group button:hover { background: #f2f5f3; }
#map-zoom-level { font-size: 12.5px; color: var(--muted); min-width: 52px;
  font-variant-numeric: tabular-nums; }
#map-fit { font-size: 13px; }

.map-body { display: flex; gap: 0; flex: 1; min-height: 0; position: relative;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: #e7ebe9; box-shadow: var(--shadow); }

/* Сцена: серое поле вокруг белого листа плана (лист рисует Konva) */
.map-stage { position: relative; flex: 1; min-width: 0; }
#map-canvas { position: absolute; inset: 0; cursor: grab; }
#map-canvas:active { cursor: grabbing; }
.map-drop-ready #map-canvas { outline: 2px dashed var(--accent); outline-offset: -6px; }

.map-tooltip { position: absolute; z-index: 5; pointer-events: none;
  background: #10281f; color: #eaf3ee; font-size: 12.5px; line-height: 1.5;
  padding: 8px 11px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  max-width: 260px; }

.map-empty-hint { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; pointer-events: none;
  color: var(--muted); font-size: 14.5px; text-align: center; padding: 20px; }
.map-empty-icon { font-size: 30px; opacity: .5; }

.map-drop-glow { display: none; }

/* Мини-подтверждение swap */
.map-confirm { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 6; background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 8px 30px rgba(16,32,26,.25);
  padding: 13px 16px; display: flex; align-items: center; gap: 14px; font-size: 14px;
  max-width: 92%; }
.map-confirm-actions { display: flex; gap: 8px; }

/* Список мест внутри панели свойств */
.map-list-title { font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 12px 0 6px;
  display: flex; justify-content: space-between; }
.map-list-title span { color: var(--accent); }
.map-list { max-height: 46vh; overflow-y: auto; }
.map-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 7px; font-size: 13.5px; min-height: 34px; }
.map-item b { font-weight: 600; }
.map-item-sub { color: var(--muted); font-size: 12px; margin-left: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 84px; }
.map-item--drag { cursor: grab; border: 1px solid var(--border); background: #fbfcfb;
  margin-bottom: 5px; }
.map-item--drag:hover { border-color: var(--accent); background: var(--accent-soft); }
.map-item--drag:active { cursor: grabbing; }
.map-item-grip { color: #b3bfb9; font-size: 12px; letter-spacing: -1px; }
.map-item-none { color: var(--muted); font-size: 13px; padding: 8px 0; }
.map-drag-hint { font-size: 12px; padding-top: 6px; }

/* Правая панель: свойства выбранного — колонка макета, канвас не перекрывает */
.map-props { width: 236px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; }
.map-props-empty { padding-top: 8px; font-size: 13px; }
.map-props-body { display: flex; flex-direction: column; gap: 10px; }
.map-props-title { font-weight: 700; font-size: 15px; }
.map-prop-row { display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 2px 0; }
.map-prop-row span { color: var(--muted); }
.map-props-size { display: flex; gap: 10px; }
.map-props-size label { flex: 1; font-size: 12px; }
.map-props-size input { width: 100%; height: 34px; text-align: center;
  font-variant-numeric: tabular-nums; }
.map-props .btn { width: 100%; }

.map-legend { display: flex; gap: 16px; align-items: center; font-size: 13px;
  color: var(--muted); flex-wrap: wrap; padding-top: 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cell-demo { width: 15px; height: 15px; border-radius: 4px; display: inline-block; }
.cell-demo.free { background: #fff; border: 1.5px solid #9aa7a1; }
.cell-demo.repair { background: #cfd6d2; }

@media (max-width: 900px) {
  .map-app { height: calc(100vh - 120px); }
  .map-search-box input { width: 100%; }
  .map-props { width: 170px; padding: 10px; }
}

/* ================= Настройки: внутренняя навигация ================= */
.st-layout { display: grid; grid-template-columns: 224px minmax(0, 640px); gap: 22px;
  align-items: start; }
.st-nav { position: sticky; top: 76px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; }
.st-nav button { display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 12px; border: none; background: none; border-radius: var(--radius-sm);
  font: 500 14px/1.3 inherit; font-family: inherit; color: var(--muted); cursor: pointer;
  text-align: left; white-space: nowrap; }
.st-nav button svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .75; }
.st-nav button:hover { background: #f2f5f3; color: var(--text); }
.st-nav button.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.st-nav button.is-active svg { opacity: 1; }
.st-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.st-section { display: none; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); }
.st-section.is-active { display: block; }
.st-section header { margin-bottom: 22px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border); }
.st-section header h2 { margin: 0 0 6px; font-size: 18px; }
.st-section header p { color: var(--muted); font-size: 13.5px; }

.st-field { margin-bottom: 18px; }
.st-field label { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.st-field input[type=text], .st-field input[type=number] { width: 100%; height: 42px; }
.st-field textarea { min-height: 96px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.st-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.day-input { display: flex; align-items: center; gap: 10px; }
.day-input input { width: 90px !important; text-align: center; font-weight: 600; font-size: 16px; }
.day-input span { color: var(--muted); font-size: 13px; white-space: nowrap; }

.qr-block { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 20px;
  flex-wrap: wrap; }
.qr-preview { width: 132px; height: 132px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  text-align: center; background: #fafcfb; flex-shrink: 0; overflow: hidden;
  color: var(--muted); font-size: 12.5px; }
.qr-preview img { width: 100%; height: 100%; object-fit: contain; }
.file-btn { cursor: pointer; }

.switch-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px;
  font-size: 14.5px; font-weight: 600; color: var(--text); cursor: pointer; }
.switch-row .hint { font-weight: 400; }
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; display: inline-block;
  margin-top: 1px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: #cfd6d2;
  transition: background .15s ease; }
.switch .slider::before { content: ''; position: absolute; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(11,110,79,.25); }

.st-save { display: flex; align-items: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }

/* =========================================================
   Планшет: ≤1024px
   ========================================================= */
@media (max-width: 1024px) {
  .content { padding: 20px 20px 60px; }
  .sidebar { width: 212px; }
}

/* =========================================================
   Шторка вместо сайдбара: ≤900px
   ========================================================= */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 84vw);
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,.25); overflow-y: auto; }
  body.drawer-open .sidebar { transform: translateX(0); }
  .drawer-overlay { display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(12, 22, 18, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s ease; }
  body.drawer-open .drawer-overlay { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  .drawer-close { display: block; }
  .sidebar-footer { display: flex; }
  .sidebar nav a { padding: 13px 14px; font-size: 15px; }

  .burger { display: flex; }
  .topbar { padding: 8px 14px; }
  .topbar-title { display: block; }
  .topbar .user { display: none; }

  .st-layout { grid-template-columns: 1fr; }
  .st-nav { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; }
  .st-nav button { width: auto; flex-shrink: 0; }
}

/* =========================================================
   Телефон: ≤700px
   ========================================================= */
@media (max-width: 700px) {
  body { font-size: 15px; }
  .content { padding: 16px 12px 56px; }
  h1 { font-size: 20px; margin-bottom: 14px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 14px 16px; }
  .card .value { font-size: 21px; }
  .panel { padding: 4px 14px 10px; border-radius: 10px; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { width: 100%; }
  .page-head .actions form { flex: 1; display: flex; }
  .page-head .actions .btn { flex: 1; width: 100%; }

  .toolbar { padding: 10px; }
  .toolbar > input, .toolbar > select { flex: 1 1 46%; min-width: 130px; }
  .toolbar > .btn { flex: 1 1 100%; }
  .filters { gap: 8px; }
  .filters input[type=text], .filters select { flex: 1 1 46%; min-width: 120px; }

  .fin-tabs { width: 100%; }
  .fin-tabs a { flex: 1; text-align: center; padding: 9px 8px; }

  .st-section { padding: 18px 16px; }
  .st-row { grid-template-columns: 1fr; }
  .st-save .btn { width: 100%; }

  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }

  /* --- Таблицы-карточки: таблица с классом t-cards раскладывается в карточки.
         Подписи ячеек берутся из data-label. --- */
  table.t-cards, table.t-cards tbody { display: block; }
  table.t-cards tr:first-child:not([data-card]) { display: none; }
  table.t-cards tr { display: block; border: 1px solid var(--border);
    border-radius: 10px; margin: 10px 0; padding: 6px 12px; background: #fff; }
  table.t-cards tr:hover td { background: none; }
  table.t-cards td { display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f3f1; text-align: right; }
  table.t-cards td:last-child { border-bottom: none; }
  table.t-cards td::before { content: attr(data-label); color: var(--muted);
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    text-align: left; flex-shrink: 0; }
  table.t-cards td:not([data-label]) { justify-content: flex-end; }
  table.t-cards td:not([data-label])::before { content: none; }
  table.t-cards td.t-title { justify-content: flex-start; text-align: left;
    font-weight: 600; font-size: 15px; padding-top: 10px; }
  table.t-cards td.t-title::before { content: none; }
  table.t-cards td:empty { display: none; }
}

/* Тач-устройства: увеличенные зоны нажатия */
@media (pointer: coarse) {
  .btn.small { height: 36px; }
  .receipt-thumb { width: 54px; height: 54px; }
}

/* ================= Интерактивная карта рынка (Konva) ================= */
.map-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.map-toolbar .spacer { flex: 1; }
.map-toolbar input[type=text] { width: 240px; }
.map-wrap { position: relative; margin-bottom: 12px; }
#map-canvas { height: calc(100vh - 320px); min-height: 440px; background: #eef2f0;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: grab; }
#map-canvas:active { cursor: grabbing; }
.map-tooltip { position: absolute; z-index: 5; pointer-events: none;
  background: #10281f; color: #eaf3ee; font-size: 12.5px; line-height: 1.5;
  padding: 8px 11px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  max-width: 260px; }
.map-legend { display: flex; gap: 16px; align-items: center; font-size: 13px;
  color: var(--muted); flex-wrap: wrap; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cell-demo { width: 15px; height: 15px; border-radius: 4px; display: inline-block; }
.cell-demo.free { background: #fff; border: 1.5px solid #9aa7a1; }
.cell-demo.repair { background: #cfd6d2; }
@media (max-width: 700px) {
  #map-canvas { height: calc(100vh - 300px); min-height: 360px; }
  .map-toolbar input[type=text] { width: 100%; }
}

/* Сворачиваемые блоки под картой */
.collapse { margin-bottom: 16px; }
.collapse > summary { cursor: pointer; padding: 13px 18px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); font-weight: 600;
  font-size: 14.5px; box-shadow: var(--shadow); list-style: none;
  display: flex; align-items: center; gap: 10px; user-select: none; }
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::before { content: '▸'; color: var(--muted); transition: transform .15s ease; }
.collapse[open] > summary::before { transform: rotate(90deg); }
.collapse[open] > summary { border-radius: var(--radius) var(--radius) 0 0; margin-bottom: 0; }
.collapse > summary:hover { background: #f7faf8; }
.collapse > .toolbar, .collapse > .panel { border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); margin-bottom: 0; }
.collapse > .toolbar { border-radius: 0; }

@media (max-width: 700px) {
}

.empty-state { padding: 34px; text-align: center; }
.empty-state p { margin-bottom: 8px; }
.empty-state .btn { margin-top: 10px; }

/* Страница добавления мест */
.manage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px; max-width: 1000px; }
.mcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); }
.mcard h2 { margin: 0 0 6px; font-size: 16px; }
.mcard > p { margin-bottom: 16px; }
.mcard input, .mcard select { width: 100%; }
.mcard .btn { margin-top: 4px; }
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Атрибут hidden всегда побеждает display:flex/grid у компонентов */
[hidden] { display: none !important; }

/* Список мест в левой панели (режим просмотра) */
#map-view-list { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#map-view-list .map-props-title { margin-bottom: 0; }
#map-view-list input { height: 34px; font-size: 13.5px; }
.map-list--tall { flex: 1; max-height: none; overflow-y: auto; }
.map-item--placed { cursor: pointer; }
.map-item--placed:hover { background: #f2f5f3; }
.map-item--placed.is-active { background: var(--accent-soft); }
#map-edit-panel { display: flex; flex-direction: column; gap: 10px; min-height: 0; }

/* Модалки карты: создание раздела и места */
.map-modal { position: fixed; inset: 0; z-index: 90; background: rgba(12,22,18,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px); }
.map-modal-card { background: var(--card); border-radius: 12px; width: 100%;
  max-width: 360px; box-shadow: 0 18px 60px rgba(0,0,0,.3); padding: 18px;
  display: flex; flex-direction: column; gap: 10px; }
.map-modal-head { display: flex; justify-content: space-between; align-items: center; }
.map-modal-head b { font-size: 15.5px; }
.map-modal-close { border: none; background: none; font-size: 15px; cursor: pointer;
  color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.map-modal-close:hover { background: #f2f5f3; }
.map-modal-card label { margin-bottom: 0; }
.map-modal-card input, .map-modal-card select { width: 100%; }
.map-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* Панель раздела на карте */
.map-zone-field label { margin-bottom: 4px; }
.map-zone-field input { width: 100%; }

/* В редакторе общий список идёт под блоком «Не размещены» */
.map-props.is-editing #map-view-list { order: 2; border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 4px; }
.map-props.is-editing #map-edit-panel { order: 1; }
.map-list-title.is-link { cursor: pointer; }
.map-list-title.is-link:hover { color: var(--accent); }

/* Окошко информации о месте (режим просмотра) */
.map-info { position: absolute; z-index: 7; min-width: 200px; max-width: 270px;
  background: var(--card); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 10px 32px rgba(16,32,26,.24); padding: 12px 14px; }
.map-info-close { position: absolute; top: 6px; right: 6px; border: none; background: none;
  color: var(--muted); font-size: 13px; cursor: pointer; padding: 3px 7px; border-radius: 5px; }
.map-info-close:hover { background: #f2f5f3; }
.map-info-title { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; padding-right: 20px; }
.map-info-row { display: flex; justify-content: space-between; gap: 12px;
  font-size: 13px; padding: 2px 0; }
.map-info-row span { color: var(--muted); }
.map-info-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.map-info-actions .btn { flex: 1; white-space: nowrap; }

/* Цвета категорий пользователя (легенда карты) */
.cell-demo.green { background: #0b6e4f; }
.cell-demo.blue { background: #1d4fa1; }
.cell-demo.yellow { background: #e2b93b; }
.cell-demo.purple { background: #5b3d8f; }

/* Свёрнутый блок «Дополнительно» в формах */
.form-extra { margin: 4px 0 14px; }
.form-extra > summary { cursor: pointer; color: var(--muted); font-size: 13.5px;
  padding: 8px 0; list-style: none; user-select: none; }
.form-extra > summary::before { content: '▸ '; }
.form-extra[open] > summary::before { content: '▾ '; }
.form-extra > summary:hover { color: var(--accent); }

/* Действия страницы в шапке (рядом с пользователем) */
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-actions:empty { display: none; }
.topbar-actions + .user { margin-left: 14px; }

/* Модальные окна панели (замена системных confirm/prompt) */
.pmodal { position: fixed; inset: 0; z-index: 120; background: rgba(12,22,18,.5);
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px); }
.pmodal.open { display: flex; }
.pmodal-card { background: var(--card); border-radius: 12px; width: 100%;
  max-width: 400px; box-shadow: 0 18px 60px rgba(0,0,0,.32); padding: 20px;
  display: flex; flex-direction: column; gap: 14px; }
.pmodal-text { font-size: 15px; line-height: 1.5; color: var(--text); }
.pmodal-input textarea { width: 100%; min-height: 64px; }
.pmodal-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pmodal-presets:empty { display: none; }
.pmodal-preset { border: 1px solid var(--border-strong); background: #fbfcfb;
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
  color: var(--text); font-family: inherit; }
.pmodal-preset:hover { border-color: var(--accent); background: var(--accent-soft); }
.pmodal-error { color: var(--danger); font-size: 13px; margin-top: 5px; }
.pmodal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pmodal-ok.danger-solid { background: var(--danger); border-color: var(--danger); }
.pmodal-ok.danger-solid:hover { background: #96190f; }

.inline-check { display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); margin: 0; }
