/* ==========================================================================
   Midex ERP — Слой оформления «Воздух» (Air Shell)
   Основа: утверждённый дизайн-код (docs/design-code-air.md, UI-kit 20261109)
   ========================================================================== */

/* 1. Палитра и дизайн-токены */
:root {
  --bg: #f1f4f8;
  --card: #ffffff;
  --head: #f4f7fb;
  --ink: #151e29;
  --ink2: #2e3845;
  --mut: #4f5865;
  --line: #e3e7ec;
  --line2: #c7d0db;
  --navy: #0f2f57;
  --side: #0f2f57;
  --soft: #eef3f9;
  --sel: #dde6f1;
  --focus: #2a6fb5;
  --ok: #1f7a4c;
  --warn: #8a6412;
  --risk: #a8463f;
  --blue: #2a6fb5;
  --fill: #0f2f57;
  --on-fill: #ffffff;
  --pick: #fbf3d9;
  --r-s: 8px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow: 0 1px 2px rgba(15, 47, 87, 0.05), 0 6px 20px rgba(15, 47, 87, 0.05);
  --shadow-lg: 0 8px 30px rgba(15, 47, 87, 0.12);
  --row: 44px;
  --cell: 10px;

  /* Совместимость с переменными style.css */
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --line-soft: #e3e7ec;
  --line-strong: #c7d0db;
  --ink-2: #2e3845;
  --acc: #0f2f57;
  --acc-hover: #173d6d;
  --acc-bg: #eef3f9;
  --acc-line: #dde6f1;
  --err: #a8463f;
  --err-bg: #fdf2f2;
  --err-line: #f5c2c0;
  --warn-bg: #fdf9ee;
  --warn-line: #f4e3b5;
  --ok-bg: #eef8f2;
  --ok-line: #bfe3cc;
  --r: 16px;
  --r-box: 10px;
  --r-c: 8px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-h: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --side-w: 244px;
  --side-bg: #0f2f57;
  --side-hover: rgba(255, 255, 255, 0.08);
  --head-bg: #f4f7fb;
  --row-hover: #eef3f9;
  --row-sel: #dde6f1;
  --page-max: 1400px;
  --h-row: 44px;

  color-scheme: light;
  font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

:root[data-theme="dark"],
html[data-theme="dark"] {
  --bg: #0f1622;
  --card: #172131;
  --head: #1e2a3e;
  --ink: #e8edf4;
  --ink2: #c9d2de;
  --mut: #a3aebb;
  --line: #253246;
  --line2: #33425a;
  --navy: #8fb4e6;
  --side: #13263f;
  --soft: #22324a;
  --sel: #1d2c44;
  --focus: #8fc1ee;
  --ok: #6fcf97;
  --warn: #e6c46a;
  --risk: #f0a19a;
  --blue: #8fb4e6;
  --fill: #8fb4e6;
  --on-fill: #0f1622;
  --pick: #3a3320;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45);

  --surface: #172131;
  --surface-2: #1e2a3e;
  --line-soft: #253246;
  --line-strong: #33425a;
  --ink-2: #c9d2de;
  --acc: #8fb4e6;
  --acc-hover: #a3c4ed;
  --acc-bg: #22324a;
  --acc-line: #1d2c44;
  --err: #f0a19a;
  --err-bg: #2d1b1c;
  --err-line: #482627;
  --warn-bg: #2d281a;
  --warn-line: #483d21;
  --ok-bg: #162a20;
  --ok-line: #244634;
  --side-bg: #13263f;
  --side-hover: rgba(255, 255, 255, 0.08);
  --head-bg: #1e2a3e;
  --row-hover: #22324a;
  --row-sel: #1d2c44;

  color-scheme: dark;
}

:root[data-density="compact"] {
  --row: 32px;
  --cell: 8px;
  --h-row: 32px;
}
:root[data-density="compact"] :is(.m-tbl, .table, .bc-table, .fot-table, .msm-table, .et-table, table.dc-t, table.tc-t, table.wh-t) td {
  height: 32px !important;
  padding-block: 2px !important;
  font-size: 13px !important;
}
:root[data-density="compact"] :is(.m-tbl, .table, .bc-table, .fot-table, .msm-table, .et-table, table.dc-t, table.tc-t, table.wh-t) th {
  height: 32px !important;
  padding-block: 4px !important;
}
:root[data-density="compact"] .status,
:root[data-density="compact"] .m-chip {
  padding-block: 0;
}

/* 2. Общие основы */
* { box-sizing: border-box; }
html { scroll-padding-block: 24px 96px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

h1 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--navy);
  margin: 0;
}
h2 {
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
}
h3 {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  margin: 0;
}
p { margin: 4px 0 0; }
small { font-size: 12px; color: var(--mut); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1:focus, h1:focus-visible { outline: 0; }

/* Ссылка перехода к содержимому (skip-link для доступности) */
.m-skip-link,
.skip-link {
  position: fixed;
  left: 16px;
  top: -120px;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  min-height: 44px;
  max-width: calc(100vw - 32px);
  padding: 0 16px;
  font-family: var(--font, Inter, "Segoe UI", system-ui, -apple-system, sans-serif);
  font-size: var(--fs, 14px);
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  background: var(--navy, #0f2f57);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--r-c, 8px);
  box-shadow: var(--shadow-lg, 0 8px 30px rgba(15, 47, 87, 0.12));
  text-decoration: none;
  white-space: nowrap;
  outline: none;
  opacity: 0;
  pointer-events: none;
  transition: top 0.15s ease, opacity 0.15s ease;
}

.m-skip-link:visited,
.skip-link:visited {
  color: #ffffff;
}

.m-skip-link:focus,
.m-skip-link:focus-visible,
.skip-link:focus,
.skip-link:focus-visible {
  top: 16px;
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--focus, #2a6fb5);
  outline-offset: 2px;
}

:root[data-theme="dark"] .m-skip-link,
:root[data-theme="dark"] .skip-link,
html[data-theme="dark"] .m-skip-link,
html[data-theme="dark"] .skip-link {
  background: var(--surface-2, #1e2a3e);
  color: var(--ink, #e8edf4);
  border-color: var(--line2, #33425a);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] .m-skip-link:visited,
:root[data-theme="dark"] .skip-link:visited,
html[data-theme="dark"] .m-skip-link:visited,
html[data-theme="dark"] .skip-link:visited {
  color: var(--ink, #e8edf4);
}

:root[data-theme="dark"] .m-skip-link:focus,
:root[data-theme="dark"] .m-skip-link:focus-visible,
:root[data-theme="dark"] .skip-link:focus,
:root[data-theme="dark"] .skip-link:focus-visible,
html[data-theme="dark"] .m-skip-link:focus,
html[data-theme="dark"] .m-skip-link:focus-visible,
html[data-theme="dark"] .skip-link:focus,
html[data-theme="dark"] .skip-link:focus-visible {
  outline-color: var(--focus, #8fc1ee);
}

main.m-main:focus,
.m-main:focus {
  outline: none;
}

/* 3. Кнопки и поля ввода */
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

button, .btn, .link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line2);
  border-radius: var(--r-m);
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, filter 0.12s, color 0.12s;
  box-shadow: none;
}
button:hover, .btn:hover, .link-button:hover {
  background: var(--soft);
  text-decoration: none;
  border-color: var(--line2);
}

.primary, .btn.pri, .link-button.primary {
  background: var(--fill);
  border-color: var(--fill);
  color: var(--on-fill);
  font-weight: 600;
  min-height: 40px;
  padding-inline: 18px;
}
.primary:hover, .btn.pri:hover, .link-button.primary:hover {
  background: var(--fill);
  border-color: var(--fill);
  color: var(--on-fill);
  filter: brightness(1.15);
}
.primary[disabled], .btn.pri[disabled] { opacity: 0.6; cursor: progress; }

.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 12.5px; border-radius: var(--r-s); }
.btn.ghost, .quiet-button { background: transparent; border-color: transparent; color: var(--mut); }
.btn.ghost:hover, .quiet-button:hover { background: var(--soft); color: var(--ink); }
.btn.dang, .danger-link { color: var(--risk); border-color: var(--line2); }
.btn.dang:hover, .danger-link:hover { background: color-mix(in srgb, var(--risk) 11%, transparent); }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="hidden"]),
select, textarea, .inp,
.f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="hidden"]),
.f select, .f textarea {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line2);
  border-radius: var(--r-m);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 0.12s, outline 0.12s;
}
input:focus, select:focus, textarea:focus, .inp:focus {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input::placeholder, .inp::placeholder { color: var(--mut); }

/* Поле с иконкой оформляет контейнер, а не вложенный input второй раз. */
.m-search { min-height: 38px; }
.m-search > input {
  min-width: 0;
  min-height: 0 !important;
  height: 100% !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}
@media (max-width: 700px) {
  .m-search { min-height: 44px; }
}

input[type="checkbox"], input[type="radio"] {
  min-height: 0 !important;
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: var(--r-s);
  cursor: pointer;
}
.bc-table td input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  min-height: 16px !important;
  margin: 0 !important;
}

/* 4. Плавающая навигация Air для старого ERP shell */
@media (min-width: 900px) {
  .m-shell .m-side {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    height: calc(100vh - 24px);
    width: 244px;
    margin: 0;
    padding: 20px 10px 14px;
    background: var(--side);
    color: #dbe5f1;
    border-radius: var(--r-l);
    box-shadow: var(--shadow);
    border: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .m-shell .m-main {
    margin-left: 268px;
  }
  html.m-mini .m-side {
    width: 56px;
    padding: 16px 6px 12px;
  }
  html.m-mini .m-shell .m-main,
  html.m-mini .m-main {
    margin-left: 80px;
  }
}

.m-side-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 14px;
  text-decoration: none;
}
.m-side-logo .m-logo,
.m-side-logo .m-mark {
  filter: brightness(0) invert(1);
}
.m-side .brand-note {
  font-size: 12px;
  color: #a9bdd4;
  padding: 0 10px 12px;
}

.m-nav {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1;
  padding: 0 2px 8px;
  scrollbar-width: thin;
}

.m-nav-grp {
  font-size: 12px;
  color: #a9bdd4;
  margin: 16px 10px 4px;
  padding: 0;
  border-top: 0;
  font-weight: 500;
  text-transform: none;
}
.m-nav-grp:first-child { margin-top: 4px; }

.m-nav a, .m-nav-set {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: var(--r-m);
  font-size: 13.5px;
  color: #e8edf4;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s;
  box-shadow: none;
  border: 0;
  background: transparent;
}
.m-nav a svg, .m-nav a .ic, .m-nav-set svg, .m-nav-set .ic {
  width: 17px;
  height: 17px;
  opacity: 0.85;
  color: inherit;
  flex-shrink: 0;
}
.m-nav a:hover, .m-nav-set:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
}
.m-nav a.on, .m-nav a[aria-current="page"], .m-nav-set.on {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-weight: 600;
  box-shadow: none;
}
.m-nav a.on svg, .m-nav a[aria-current="page"] svg { opacity: 1; }

.nav-n {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  margin-left: auto;
}

.m-side-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 6px 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.m-side .m-me {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 6px;
  color: #e8edf4;
  font-size: 13px;
}
.m-me .m-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: #ffffff;
  flex-shrink: 0;
}
.m-me-t { min-width: 0; flex: 1; }
.m-side .m-me-t b { display: block; font-size: 13px; color: #e8edf4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-me-t small { display: block; font-size: 11.5px; color: #a9bdd4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-side .m-me-acts {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.m-side .m-me-a { position: relative; width: 36px; height: 36px; min-height: 36px; }
.m-me-a .nav-n {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  margin: 0;
  font-size: 9.5px;
  line-height: 15px;
  text-align: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
@media (max-width: 899px) {
  .m-side .m-me-a { width: 44px; height: 44px; }
  .m-side .m-fold { display: none; }
}
@media (min-width: 900px) {
  html.m-mini .m-side .m-me {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    padding-inline: 0;
  }
  html.m-mini .m-side .m-me-acts { flex-direction: column; }
}
.m-me-a {
  padding: 4px;
  border-radius: var(--r-s);
  color: #a9bdd4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.m-me-a:hover { color: #ffffff; background: rgba(255, 255, 255, 0.1); }
.m-me-a[aria-current="page"] {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}
.m-side :is(a, button, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid #8fc1ee;
  outline-offset: -2px;
}
.m-fold {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: #a9bdd4;
  font-size: 12px;
  background: transparent;
  border: 0;
  border-radius: var(--r-s);
  cursor: pointer;
}
.m-fold:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }

/* Дима: статус в подвале сайдбара — читаемый на тёмной подложке */
.m-dima {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 2px 8px;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.35;
  color: #a9bdd4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-dima .m-dot {
  flex: none;
  width: 8px;
  height: 8px;
}
.m-dima .m-dot.t-ok {
  --tm: #3ecf80;
  box-shadow: 0 0 0 3px rgba(62, 207, 128, 0.16);
}
.m-dima .m-dot.t-grey {
  --tm: #93a4b8;
}

/* Согласованная ссылка на Next Заявки */
.nav-next-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: var(--r-m);
  font-size: 13.5px;
  color: #8fc1ee;
  background: rgba(42, 111, 181, 0.12);
  text-decoration: none;
}
.nav-next-link:hover {
  background: rgba(42, 111, 181, 0.22);
  color: #ffffff;
  text-decoration: none;
}
.next-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--blue);
  color: #ffffff;
  letter-spacing: 0.05em;
}

/* 5. Общая рабочая область и заголовки */
.m-main {
  max-width: 1400px;
  margin: 0;
  padding: 20px 28px 48px;
  min-height: 100vh;
}
.wrap.m-page, .m-page {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.m-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.m-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.m-ph {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
  flex-wrap: wrap;
}
.m-ph-t h1, .m-ph h1 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--navy);
  margin: 0;
}
.m-ph-sub {
  font-size: 13.5px;
  color: var(--mut);
  margin-top: 4px;
}
.m-ph-act {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* 6. Карточки, блоки и панели */
.card, .panel, .m-box, .m-block, .sd-sheet, .slc-card, .request-facts {
  background: var(--card);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  border: 0;
  padding: 20px 22px;
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head, .sd-block-head, .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.panel-head h2, .sd-block-head h2, .card-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
}

/* Главный блок «Сегодня» / Hero */
.focus-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  margin-bottom: 20px;
  background: var(--card);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
}
.focus-strip.hero {
  background: var(--side);
  color: #ffffff;
  padding: 22px 24px;
}
.focus-strip.hero strong { font-size: 16px; font-weight: 600; }
.focus-strip.hero p { color: #c9d9ea; }
.focus-strip.hero .link-button, .focus-strip.hero .btn {
  background: #ffffff;
  border-color: #ffffff;
  color: #0f2f57;
  font-weight: 600;
}
:root[data-theme="dark"] .focus-strip.hero {
  background: #1c3250;
}

/* 7. Таблицы в стиле Air */
.m-tbl, .table, table.mx, table.clients {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.m-tbl th, .table th, table.mx th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  padding: 8px var(--cell);
  color: var(--mut);
  font-size: 12.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  background: var(--head);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.m-tbl td, .table td, table.mx td {
  height: var(--row);
  padding: 4px var(--cell);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.m-tbl tbody tr:last-child td, .table tbody tr:last-child td {
  border-bottom: 0;
}
.m-tbl tbody tr:hover > td, .table tbody tr:hover > td {
  background: var(--soft);
}
.m-tbl tr.sel > td, .table tr.sel > td {
  background: var(--sel);
}
.m-tbl .num, .m-tbl .r, .table .num, .table th.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.m-tbl tr.m-grp > td {
  height: 32px;
  background: var(--soft);
  color: var(--navy);
  font-weight: 600;
  border-top: 1px solid var(--line);
}

/* 8. Статусы и метки (Air pill badges с сохранением семантических цветов) */
.status, .m-chip, .st-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--tc, var(--blue));
  background: var(--tb, color-mix(in srgb, var(--blue) 10%, transparent));
  border: 0;
}
.m-chip.t-grey { color: var(--tc, #5f7186); background: var(--tb, #f1f4f8); }
.m-chip.t-teal { color: var(--tc, #0d766e); background: var(--tb, #e6f6f4); }
.status.good, .m-chip.t-ok, .st-chip.ok, .status[data-ok] {
  color: var(--tc, var(--ok));
  background: var(--tb, color-mix(in srgb, var(--ok) 12%, transparent));
}
.status.warn, .m-chip.t-warn, .st-chip.warn {
  color: var(--tc, var(--warn));
  background: var(--tb, color-mix(in srgb, var(--warn) 13%, transparent));
}
.status.risk, .m-chip.t-err, .st-chip.risk, .st-chip.err {
  color: var(--tc, var(--risk));
  background: var(--tb, color-mix(in srgb, var(--risk) 11%, transparent));
}

/* 9. Информационные плашки и предупреждения */
.gl-bar, .debt-bar {
  border-radius: var(--r-m);
  padding: 12px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  background: var(--card);
  border: 1px solid var(--line);
}
.gl-bar {
  background: var(--soft);
  border-color: var(--sel);
  color: var(--ink);
}
.debt-bar {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: var(--ink);
}

/* 10. Диалоги, модальные окна и шторки */
dialog, .dialog, .m-drawer, .section-settings-drawer {
  border-radius: var(--r-l);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.m-scrim {
  z-index: 55 !important;
  background: rgba(15, 22, 34, 0.45);
  backdrop-filter: blur(2px);
}
.section-settings-scrim {
  background: rgba(15, 22, 34, 0.45);
  backdrop-filter: blur(2px);
}

/* 11. Переключатели темы и плотности (Air Topbar Tools) */
.air-topbar-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.air-theme-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line2);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.air-theme-btn:hover {
  background: var(--soft);
}
.air-density-seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: 999px;
}
.air-density-seg button {
  min-height: 28px;
  padding: 2px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--mut);
  font-size: 12.5px;
  cursor: pointer;
}
.air-density-seg button[aria-pressed="true"] {
  background: var(--sel);
  color: var(--navy);
  font-weight: 600;
}
@media (min-width: 900px) {
  html.m-mini .nav-next-link {
    justify-content: center !important;
    padding: 8px 0 !important;
    width: 100% !important;
  }
  html.m-mini .nav-next-link .t {
    display: none !important;
  }
}

/* Быстрые настройки на странице «Оформление» (вне lk-root) */
.lk-quick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--card);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
}
body[data-page="look"] .lk-hint {
  white-space: normal;
  overflow-wrap: anywhere;
}
.lk-theme-quick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line2);
  border-radius: var(--r-m);
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.lk-theme-quick:hover {
  background: var(--soft);
}
.lk-theme-quick[aria-pressed="true"] {
  background: var(--sel);
  color: var(--navy);
  font-weight: 600;
}
.lk-theme-quick .ic {
  width: 16px;
  height: 16px;
  flex: none;
}

/* 12. Мобильный адаптив (1440 / 390 px) */
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .m-main { padding-inline: 20px; }
}

@media (max-width: 899px) {
  .m-shell .m-main {
    margin-left: 0;
  }
  .m-side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, calc(100vw - 40px));
    height: 100vh;
    border: 0;
    border-radius: 0 var(--r-l) var(--r-l) 0;
    z-index: 60;
    background: #0f2f57 !important;
    color: #ffffff !important;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.15s ease-out, visibility 0.15s;
    box-shadow: none;
  }
  :root[data-theme="clear"] .m-side {
    background: #0f2f57 !important;
    color: #ffffff !important;
  }
  :root[data-theme="dark"] .m-side {
    background: #111827 !important;
    color: #ffffff !important;
  }
  html.m-open .m-side {
    transform: none;
    visibility: visible;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  }

  .m-mtop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--side);
    color: #ffffff;
    margin-bottom: 12px;
    border-radius: var(--r-m);
  }
  .m-mtop-logo img {
    filter: brightness(0) invert(1);
  }
}

@media (max-width: 760px) {
  .m-shell .m-main {
    padding: 14px 14px 84px;
  }

  /* Сенсорные зоны 44px на мобильном */
  button, .btn, .link-button, .primary, .link-button.primary {
    min-height: 44px;
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select, textarea, .inp {
    min-height: 44px;
    font-size: 16px; /* Защита от автозума в мобильных браузерах */
  }

  /* Предотвращение переполнения карточек KPI и тулбаров */
  .m-kpis, .erp-kpis6.m-kpis {
    min-width: 0;
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .m-kpi {
    min-width: 0 !important;
    overflow: hidden;
  }
  .m-kpi-tx {
    min-width: 0 !important;
    overflow: hidden;
  }
  .m-kpi-v {
    font-size: 16px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-kpi-l {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fin-bar {
    max-width: 100%;
    overflow-x: auto;
  }

  .card, .panel, .m-box, .m-block, .focus-strip {
    margin-bottom: 14px;
    padding: 16px;
  }

  /* Мобильная нижняя панель навигации */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    justify-content: space-around;
    align-items: center;
    gap: 4px;
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
    z-index: 55;
    box-shadow: 0 -2px 10px rgba(15, 47, 87, 0.08);
  }
  .mobile-nav a, .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    min-width: 58px;
    padding: 4px;
    border: 0;
    border-radius: var(--r-m);
    background: none;
    color: var(--mut);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
  }
  .mobile-nav a[aria-current="page"], .mobile-nav a.on {
    color: var(--navy);
    font-weight: 600;
  }
  .mobile-nav svg, .mobile-nav .ic {
    width: 20px;
    height: 20px;
  }
}

/* 13. Доводка нестандартных экранов ERP под стандарт «Воздух» */

/* Продажи (Кабинет продавца, РОП, сделки) */
.sd-layout {
  gap: 16px;
  max-width: 1400px;
}
.sd-side {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 16px;
}
.sd-sheet {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
}
.sd-sheet.sd-current {
  border: 2px solid var(--navy);
  box-shadow: var(--shadow-lg);
}
.sd-block-head {
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}
.sd-block-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.sd-nav-item {
  border-radius: var(--r-m);
  padding: 7px 10px;
  font-size: 13px;
}
.sd-nav-item:hover {
  background: var(--soft);
}
.sd-nav-item[aria-current="location"] {
  background: var(--sel);
  color: var(--navy);
  font-weight: 600;
}
.slc-card {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
}

/* Закупки (Кабинет снабженца, контроль поставок, договоры) */
.bc-top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
}
.bc-card {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.bc-card h1 {
  font-size: 20px;
  color: var(--navy);
}
.bc-tboard .bc-col {
  background: var(--soft);
  border-radius: var(--r-m);
  padding: 8px;
}
.bc-tboard .bc-col-h {
  background: var(--head);
  border-radius: var(--r-s);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  padding: 8px 12px;
}

/* Склад и логистика */
.wh-sec {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.wh-sec > .m-sec-h {
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.wh-flt {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
}

/* Финансы и согласование платежей */
.msm-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.msm-kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.msm-kpi strong {
  font-size: 18px;
  color: var(--ink);
}
.msm-panel {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.msm-tabs button.on {
  background: var(--sel);
  color: var(--navy);
  font-weight: 600;
}
.pay-settings-drawer {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--line);
}
.pay-settings-head, .pay-settings-foot {
  background: var(--head);
  border-color: var(--line);
  color: var(--ink);
}
.pay-settings-tab.on {
  background: var(--fill);
  color: var(--on-fill);
}

/* Задачи (карточки и канбан) */
.mx-task-card.m-drawer, .mx-task-create.m-drawer {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-l);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.mx-task-card .tk-card {
  background: transparent;
}
.mx-task-card dl.tk-facts {
  background: var(--head);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
}
.mx-task-card .tk-step.done {
  color: var(--ok);
}
.mx-task-card .tk-step.done .tk-step-circle {
  background: var(--ok);
  border-color: var(--ok);
  color: #ffffff;
}

/* HR, Кабинеты отделов и сотрудников */
.hrs .m-sec, .staff-group, .dc-sec, .tr-blk, .al-is-blk {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.hrs .m-sec-h, .staff-group h2, .dc-h {
  background: transparent;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  color: var(--navy);
  font-size: 15px;
  font-weight: 600;
}
.staff-person .staff-avatar {
  background: var(--sel);
  color: var(--navy);
  font-weight: 600;
  border-radius: 50%;
}

/* База знаний и настройки */
.kb-learning-course {
  background: var(--card);
  border: 0;
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.kb-learning-number {
  background: var(--soft);
  color: var(--navy);
  border: 0;
  border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* 14. Экран «Сегодня» (/today) — финальные перекрытия слоя «Воздух» (по эталону Navy Air) */
body[data-page="today"] {
  --fs: 14px;
  --fs-s: 13px;
}

body[data-page="today"] .panel,
body[data-page="today"] .focus-strip,
body[data-page="today"] .focus-kpis a {
  border: none !important;
  box-shadow: var(--shadow) !important;
}

body[data-page="today"] table.table.registry {
  font-family: var(--font, Inter, sans-serif) !important;
  border: none !important;
}

body[data-page="today"] table.table.registry :is(th, td) {
  border-left: 0 !important;
  border-right: 0 !important;
}

body[data-page="today"] table.table.registry tbody td {
  border-bottom: 1px solid var(--line) !important;
}

body[data-page="today"] #today-new-req {
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 18px !important;
  font-size: 13.5px !important;
  border-radius: var(--r-m, 10px) !important;
  box-sizing: border-box !important;
}

body[data-page="today"] #td-pills .td-pill,
body[data-page="today"] .td-pbar .td-pill:is(#_, .td-pill),
body[data-page="today"] .td-pills .td-pill:is(#_, .td-pill),
body[data-page="today"] .td-pill:is(#_, .td-pill) {
  height: 32px !important;
  min-height: 32px !important;
  --h-ctl-sm: 32px !important;
  --h-ctl: 32px !important;
  padding: 4px 12px !important;
  border-radius: 999px !important;
  box-sizing: border-box !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}

:root[data-theme="dark"] body[data-page="today"] .td-bday,
html[data-theme="dark"] body[data-page="today"] .td-bday {
  background: color-mix(in srgb, #5eead4 12%, var(--card)) !important;
  border-color: color-mix(in srgb, #5eead4 30%, transparent) !important;
  color: #5eead4 !important;
}

:root[data-theme="dark"] body[data-page="today"] .td-bday .ic,
:root[data-theme="dark"] body[data-page="today"] .td-bday svg {
  color: #5eead4 !important;
}

@media (max-width: 768px) {
  body[data-page="today"] #today-new-req {
    height: 44px !important;
    min-height: 44px !important;
    font-size: 14px !important;
  }

  body[data-page="today"] #td-pills .td-pill,
  body[data-page="today"] .td-pbar .td-pill:is(#_, .td-pill),
  body[data-page="today"] .td-pills .td-pill:is(#_, .td-pill),
  body[data-page="today"] .td-pill:is(#_, .td-pill) {
    height: 44px !important;
    min-height: 44px !important;
    --h-ctl-sm: 44px !important;
    --h-ctl: 44px !important;
    padding: 6px 14px !important;
    font-size: 14px !important;
  }
}
