:root {
  font-family: Arial, sans-serif;
  color: #243449;
  background: #fff;
  font-synthesis: none;
}

.login-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
  background: #fff;
}

.login-card {
  width: min(100%, 24rem);
  box-sizing: border-box;
  padding: 2rem;
  background: #fff;
}

.login-card h1 {
  margin: 0 0 2rem;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 500;
}

.form-field {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.form-field label {
  font-size: 0.92rem;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 2.75rem;
  box-sizing: border-box;
  padding: 0.65rem 0.8rem;
  border: 1px solid #ccd8e5;
  border-radius: 7px;
  font: inherit;
  color: inherit;
  background: #fff;
}

input[type="checkbox"] {
  display: inline-block;
  flex: 0 0 1.1rem;
  width: 1.1rem;
  height: 1.1rem;
  min-height: 1.1rem;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  accent-color: #2586c8;
  vertical-align: middle;
  cursor: pointer;
}

.form-field textarea {
  resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid #91c9ef;
  border-color: #2586c8;
}

.input-wrap {
  position: relative;
}

.input-wrap input[name="password"] {
  padding-right: 5.5rem;
}

.password-toggle {
  position: absolute;
  inset: 0.25rem 0.35rem 0.25rem auto;
  border: 0;
  border-radius: 5px;
  padding: 0 0.5rem;
  color: #287fb8;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  box-sizing: border-box;
  padding: 0.65rem 1rem;
  border: 1px solid #2586c8;
  border-radius: 7px;
  color: #fff;
  background: #2586c8;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.primary-button:hover {
  background: #176fae;
}

.full-width {
  width: 100%;
  margin-top: 0.5rem;
}

.login-error,
.field-error {
  color: #bd2838;
  font-size: 0.9rem;
}

.login-error {
  margin-top: 1rem;
  text-align: center;
}

.field-error {
  margin: 0;
}

.app-body {
  min-height: 100vh;
  margin: 0;
  background: #f4f8fc;
}

.app-header {
  min-height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem clamp(1rem, 4vw, 3rem);
  background: #fff;
  border-bottom: 1px solid #e2ebf4;
}

.app-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header a,
.link-button {
  color: #287fb8;
  text-decoration: none;
}

.brand {
  font-size: 1.15rem;
  font-weight: 600;
}

.inline-form {
  display: inline;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.page-content {
  width: min(100% - 2rem, 70rem);
  margin: 2rem auto;
}

.panel {
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid #e2ebf4;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgb(31 66 100 / 4%);
}

.panel h1 {
  margin-top: 0;
  color: #2586c8;
  font-weight: 500;
  font-size: 1.35rem;
}

.welcome-panel {
  text-align: center;
}

.narrow-panel {
  max-width: 38rem;
  margin-inline: auto;
}

.form-layout {
  display: grid;
  gap: 0.5rem;
}

.form-layout .primary-button {
  justify-self: start;
}

.profile-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-details div {
  overflow-wrap: anywhere;
}

.profile-details dt {
  margin-bottom: 0.25rem;
  color: #66788a;
  font-size: 0.9rem;
}

.profile-details dd {
  margin: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.button-link {
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
}

.employees-table {
  min-width: 44rem;
}

.employees-panel {
  min-height: clamp(24rem, calc(100vh - 16rem), 34rem);
}

.employees-table th,
.employees-table td {
  padding: 0.7rem 0.8rem;
}

.actions-column {
  width: 4.5rem;
  text-align: center;
}

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.status-active {
  color: #286548;
  background: #e9f6ee;
}

.status-blocked {
  color: #9a3140;
  background: #fff0f1;
}

.row-actions {
  position: relative;
  display: inline-block;
  text-align: left;
}

.row-actions summary {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #53677b;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.row-actions summary:hover,
.modal-close:hover {
  color: #2586c8;
}

.row-actions summary:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid #2586c8;
  outline-offset: 2px;
}

.row-actions summary::-webkit-details-marker {
  display: none;
}

.row-actions-menu {
  position: absolute;
  z-index: 3;
  top: calc(100% + 0.25rem);
  right: 0;
  display: grid;
  min-width: 9rem;
  padding: 0.3rem;
  border: 1px solid #e2ebf4;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 5px 18px rgb(31 66 100 / 12%);
}

.row-actions-menu.is-floating {
  position: fixed;
  z-index: 1000;
  top: 0;
  right: auto;
  bottom: auto;
  left: 0;
  max-height: calc(100vh - 1rem);
  max-height: calc(100dvh - 1rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.row-actions-menu a,
.row-actions-menu button {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 2.25rem;
  border: 0;
  border-radius: 5px;
  padding: 0.55rem 0.65rem;
  color: #243449;
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.row-actions-menu a:hover,
.row-actions-menu button:hover {
  background: #f2f8fc;
}

.empty-row {
  padding-block: 1.5rem;
  color: #66788a;
  text-align: center;
}

.modal-dialog {
  width: min(100% - 2rem, 34rem);
  max-height: min(86vh, 48rem);
  box-sizing: border-box;
  padding: 1.5rem;
  overflow: auto;
  border: 1px solid #e2ebf4;
  border-radius: 10px;
  color: #243449;
  background: #fff;
  box-shadow: 0 16px 48px rgb(25 53 80 / 20%);
}

.modal-dialog::backdrop {
  background: rgb(26 43 59 / 38%);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.modal-heading h2 {
  margin: 0;
  color: #2586c8;
  font-size: 1.25rem;
  font-weight: 500;
}

.modal-close {
  display: grid;
  width: 2rem;
  height: 2rem;
  box-sizing: border-box;
  place-items: center;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #53677b;
  background: transparent;
  font-family: Arial, sans-serif;
  font-size: 1.4rem;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.modal-form {
  gap: 0.3rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.modal-actions .secondary-button {
  min-height: 2.75rem;
}

.readonly-role {
  color: #66788a;
  line-height: 1.6;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid #e6edf3;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #53677b;
  font-weight: 500;
}

.secondary-button {
  min-height: 2.25rem;
  color: #287fb8;
  background: #fff;
}

.notice {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 7px;
  background: #eaf5fc;
}

.notice-success {
  color: #205c3c;
  background: #e9f6ee;
}

@media (max-width: 600px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header nav {
    flex-wrap: wrap;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .employees-panel {
    min-height: 24rem;
  }

  th,
  td {
    padding: 0.6rem;
  }
}

/* Общая оболочка CRM */
:root {
  --workspace-bg: #f4f8fc;
  --surface: #fff;
  --text-main: #243449;
  --text-muted: #66788a;
  --line: #e2ebf4;
  --sidebar-bg: #eaf4fc;
  --sidebar-text: #29445a;
  --accent: #2586c8;
}

.app-body.crm-shell { color: var(--text-main); background: var(--workspace-bg); }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.crm-sidebar { position: sticky; top: 0; z-index: 20; display: flex; height: 100vh; min-height: 0; flex-direction: column; background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--line); }
.brand { display: flex; min-height: 64px; align-items: center; gap: .7rem; padding: 0 1.15rem; color: var(--sidebar-text); text-decoration: none; font-size: 1.03rem; font-weight: 700; letter-spacing: .02em; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: #2586c8; color: #fff; }
.brand-mark svg { width: 17px; height: 17px; fill: currentColor; }
.main-navigation { overflow-y: auto; padding: .35rem .55rem 1rem; }
.nav-link { position: relative; display: flex; min-height: 39px; align-items: center; gap: .7rem; box-sizing: border-box; padding: .48rem .65rem; border-radius: 7px; color: inherit; text-decoration: none; font-size: .88rem; line-height: 1.25; cursor: pointer; }
.nav-link > svg, .icon-button svg, .global-search svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover, .nav-group[open] > summary:hover { background: rgb(255 255 255 / 58%); }
.nav-link.is-active { background: rgb(255 255 255 / 72%); color: #176fae; font-weight: 600; }
.nav-link.is-active::before { position: absolute; top: 7px; bottom: 7px; left: -9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); content: ""; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-chevron { width: 14px !important; height: 14px !important; margin-left: auto; transition: transform .15s ease; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
.nav-children { display: grid; gap: 1px; margin: .05rem 0 .3rem 1.18rem; padding-left: .45rem; border-left: 1px solid #bdd5e8; }
.nav-children .nav-link { min-height: 34px; padding-left: .5rem; font-size: .84rem; }
.nav-placeholder { cursor: default; }
.nav-placeholder.is-locked { color: #74889a; }
.nav-lock { width: 14px !important; height: 14px !important; margin-left: auto; }
.app-main { min-width: 0; }
.crm-topbar { position: sticky; top: 0; z-index: 10; display: flex; height: 60px; align-items: center; gap: 1rem; box-sizing: border-box; padding: 0 1.5rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.global-search { display: flex; width: min(24rem, 48vw); align-items: center; gap: .55rem; padding: .47rem .75rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-muted); background: var(--workspace-bg); }
.global-search-button { display: grid; flex: 0 0 auto; place-items: center; padding: 0; border: 0; color: var(--text-muted); background: transparent; cursor: pointer; }
.global-search-button:hover { color: var(--accent); }
.global-search-results { display: grid; min-width: 0; gap: .8rem; }
.global-search-results h1, .global-search-group h2 { margin: 0; color: var(--text-main); font-weight: 500; }
.global-search-results h1 { font-size: 1.25rem; }
.global-search-group { display: grid; min-width: 0; gap: .45rem; }
.global-search-group h2 { font-size: 1rem; }
.global-search-group ul { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.global-search-group li a { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: .8rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 8px; color: var(--text-main); background: var(--surface); text-decoration: none; }
.global-search-group li a:hover { border-color: var(--accent); }
.global-search-group li a strong, .global-search-group li a span { min-width: 0; overflow-wrap: anywhere; }
.global-search-group li a span { color: var(--text-muted); font-size: .82rem; }
.global-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text-main); background: transparent; font: inherit; font-size: .86rem; }
.global-search input::placeholder { color: var(--text-muted); }
.global-search input:disabled { cursor: default; }
.topbar-actions { display: flex; align-items: center; gap: .55rem; margin-left: auto; }
.icon-button { position: relative; display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid transparent; border-radius: 8px; color: var(--text-muted); background: transparent; cursor: pointer; }
.icon-button:hover { border-color: var(--line); background: var(--workspace-bg); }
.notification-count { position: absolute; top: 0; right: -2px; display: grid; min-width: 15px; height: 15px; place-items: center; border: 2px solid var(--surface); border-radius: 9px; color: #fff; background: #8a9aaa; font-size: .58rem; }
.profile-menu { position: relative; }
.profile-trigger { display: flex; align-items: center; gap: .55rem; max-width: 15rem; padding: .2rem .35rem; border-radius: 8px; list-style: none; cursor: pointer; }
.profile-trigger::-webkit-details-marker { display: none; }
.profile-trigger-name { overflow: hidden; max-width: 11rem; color: var(--text-main); font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; color: #fff; background: #2586c8; font-size: .78rem; font-weight: 600; }
.profile-dropdown { position: absolute; top: calc(100% + .55rem); right: 0; z-index: 30; width: 13rem; padding: .4rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 8px 24px rgb(31 66 100 / 14%); }
.profile-dropdown-summary { display: grid; gap: .2rem; padding: .65rem .7rem; border-bottom: 1px solid var(--line); font-size: .83rem; }
.profile-dropdown-summary span { color: var(--text-muted); font-size: .77rem; }
.profile-dropdown a, .profile-dropdown button { display: block; width: 100%; box-sizing: border-box; padding: .62rem .7rem; border: 0; border-radius: 6px; color: var(--text-main); background: transparent; font: inherit; font-size: .84rem; text-align: left; text-decoration: none; cursor: pointer; }
.profile-dropdown a:hover, .profile-dropdown button:hover { background: var(--workspace-bg); }
.profile-dropdown form { margin: 0; }
.page-content { width: auto; max-width: none; margin: 0; padding: 1.35rem clamp(1rem, 2.5vw, 2rem); }
.panel { border-color: var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 3px 14px rgb(31 66 100 / 5%); }
.panel h1, .panel h2 { color: var(--accent); }
.mobile-menu-button, .sidebar-backdrop { display: none; }

body.crm-shell[data-theme="dark"] { --workspace-bg: #151d27; --surface: #1e2935; --text-main: #e6edf4; --text-muted: #a2b1c0; --line: #344352; --sidebar-bg: #1b2b39; --sidebar-text: #d6e4ef; --accent: #69b9ec; }
body.crm-shell[data-theme="dark"] .nav-link.is-active { color: #8ccdf2; background: #263b4d; }
body.crm-shell[data-theme="dark"] .nav-link:hover, body.crm-shell[data-theme="dark"] .nav-group[open] > summary:hover { background: #263746; }
body.crm-shell[data-theme="dark"] .nav-children { border-color: #46647a; }
body.crm-shell[data-theme="dark"] .global-search, body.crm-shell[data-theme="dark"] .icon-button:hover { background: #18232e; }
body.crm-shell[data-theme="dark"] .row-actions-menu, body.crm-shell[data-theme="dark"] .modal-dialog { color: var(--text-main); background: var(--surface); border-color: var(--line); }
body.crm-shell[data-theme="dark"] .row-actions-menu a, body.crm-shell[data-theme="dark"] .row-actions-menu button { color: var(--text-main); }
body.crm-shell[data-theme="dark"] .modal-close { color: var(--text-main); background-color: transparent; }
body.crm-shell[data-theme="dark"] .row-actions summary { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .form-field input, body.crm-shell[data-theme="dark"] .form-field select, body.crm-shell[data-theme="dark"] .form-field textarea { color: var(--text-main); background: #18232e; border-color: var(--line); }
body.crm-shell input[type="checkbox"] { accent-color: var(--accent); }
body.crm-shell[data-theme="dark"] th { color: var(--text-muted); border-color: var(--line); }
body.crm-shell[data-theme="dark"] select { color: var(--text-main); background-color: #18232e; border-color: var(--line); color-scheme: dark; }
body.crm-shell[data-theme="dark"] input[type="date"],
body.crm-shell[data-theme="dark"] input[type="datetime-local"],
body.crm-shell[data-theme="dark"] input[type="time"],
body.crm-shell[data-theme="dark"] input[type="month"] { color-scheme: dark; }
body.crm-shell[data-theme="dark"] td { border-color: var(--line); }
body.crm-shell[data-theme="dark"] .secondary-button { color: var(--accent); background: var(--surface); }

@media (max-width: 960px) {
  .app-shell { display: block; }
  .crm-sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: min(290px, 86vw); height: 100dvh; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 8px 0 24px rgb(20 40 60 / 12%); }
  body.sidebar-open .crm-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; z-index: 19; display: block; background: rgb(19 32 45 / 38%); }
  .mobile-menu-button { display: grid; }
  .crm-topbar { padding-inline: 1rem; }
  .global-search { width: min(22rem, 48vw); }
}
@media (max-width: 600px) {
  .crm-topbar { height: 56px; gap: .45rem; padding-inline: .6rem; }
  .global-search { flex: 1; width: auto; padding: .42rem .5rem; }
  .global-search input { font-size: .8rem; }
  .topbar-actions { gap: .15rem; }
  .icon-button { width: 32px; height: 34px; }
  .profile-trigger { padding-inline: .1rem; }
  .profile-trigger-name, .profile-trigger > .nav-chevron { display: none; }
  .page-content { padding: .9rem .65rem; }
  .panel { padding: 1rem; }
  .section-heading { align-items: flex-start; }
  .employees-panel { min-height: 24rem; }
}
@media (prefers-reduced-motion: reduce) { .crm-sidebar, .nav-chevron { transition: none; } }

/* Главная панель */
.dashboard-stack { display: grid; min-width: 0; gap: .9rem; }
.dashboard-card { min-width: 0; padding: 1.1rem 1.25rem; }
.dashboard-heading, .dashboard-heading-title { display: flex; min-width: 0; align-items: center; gap: .65rem; }
.dashboard-heading { justify-content: space-between; margin-bottom: .9rem; }
.dashboard-heading-title { justify-content: flex-start; }
.dashboard-heading > svg, .dashboard-heading-title > svg { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dashboard-heading h1, .dashboard-heading h2 { min-width: 0; margin: 0; color: var(--text-main); font-size: 1rem; font-weight: 600; line-height: 1.35; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.dashboard-metric { display: flex; min-width: 0; min-height: 4.1rem; align-items: center; justify-content: space-between; gap: .8rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--workspace-bg); }
.dashboard-metric-label { color: var(--text-muted); font-size: .86rem; }
.dashboard-metric-value { color: var(--text-main); font-size: 1.15rem; font-weight: 600; }
.dashboard-note, .dashboard-empty-note { margin: .7rem 0 0; color: var(--text-muted); font-size: .8rem; line-height: 1.5; }
.dashboard-income-heading { flex-wrap: wrap; }
.dashboard-period { display: inline-flex; gap: .2rem; padding: .2rem; border: 1px solid var(--line); border-radius: 8px; background: var(--workspace-bg); }
.dashboard-period a { padding: .38rem .75rem; border-radius: 6px; color: var(--text-muted); font-size: .82rem; text-decoration: none; }
.dashboard-period a:hover { color: var(--accent); }
.dashboard-period a[aria-current="true"] { color: #fff; background: var(--accent); }
.dashboard-income-amount { margin: .2rem 0 0; color: var(--text-main); font-size: 1.65rem; font-weight: 600; }
.dashboard-income-amount span { color: var(--text-muted); font-size: 1rem; font-weight: 400; }
.dashboard-table-scroll { max-width: 100%; overflow-x: auto; }
.dashboard-table { min-width: 35rem; font-size: .84rem; }
.dashboard-table th, .dashboard-table td { padding: .58rem .7rem; }
.dashboard-table th { color: var(--text-muted); font-size: .78rem; }
.dashboard-table .dashboard-empty-cell { height: 2.9rem; color: var(--text-muted); text-align: center; }
body.crm-shell[data-theme="dark"] .dashboard-metric, body.crm-shell[data-theme="dark"] .dashboard-period { background: #18232e; }
body.crm-shell[data-theme="dark"] .dashboard-period a[aria-current="true"] { color: #14212c; }
@media (max-width: 600px) {
  .dashboard-stack { gap: .7rem; }
  .dashboard-card { padding: .9rem; }
  .dashboard-metrics { grid-template-columns: 1fr; gap: .45rem; }
  .dashboard-metric { min-height: 3.4rem; padding: .55rem .7rem; }
  .dashboard-heading { align-items: flex-start; }
  .dashboard-income-heading { align-items: center; }
  .dashboard-period a { padding-inline: .58rem; }
  .dashboard-table { min-width: 34rem; }
}

/* Updated live dashboard */
.dashboard-metrics-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-metrics-overview .dashboard-metric { text-decoration: none; }
.dashboard-metrics-overview a.dashboard-metric,
.dashboard-metrics-overview a.dashboard-metric .dashboard-metric-label,
.dashboard-metrics-overview a.dashboard-metric .dashboard-metric-value { text-decoration: none !important; }
.dashboard-extra-metrics a.dashboard-metric,
.dashboard-extra-metrics a.dashboard-metric .dashboard-metric-label,
.dashboard-extra-metrics a.dashboard-metric .dashboard-metric-value { text-decoration: none !important; }
.dashboard-metrics-overview a.dashboard-metric { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.dashboard-metrics-overview a.dashboard-metric:hover { border-color: var(--accent); transform: translateY(-1px); }
.dashboard-finance-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-metric-primary { border-color: var(--accent); }
.dashboard-table-responsive { width: 100%; min-width: 0; table-layout: fixed; }
.dashboard-table-responsive th, .dashboard-table-responsive td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.dashboard-section-link { color: var(--accent); font-size: .82rem; text-decoration: none; white-space: nowrap; }
.dashboard-section-link:hover { text-decoration: underline; }
.dashboard-heading-links { display: flex; flex-wrap: wrap; gap: .8rem; }
.dashboard-attention-list { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.dashboard-attention-item { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; padding: .65rem .75rem; border-left: 3px solid var(--line); border-radius: 6px; background: var(--workspace-bg); }
.dashboard-attention-item a { display: grid; min-width: 0; gap: .18rem; color: var(--text-main); text-decoration: none; }
.dashboard-attention-item a:hover .dashboard-attention-title { color: var(--accent); }
.dashboard-attention-title { font-size: .86rem; font-weight: 600; }
.dashboard-attention-description, .dashboard-attention-item time { color: var(--text-muted); font-size: .78rem; line-height: 1.4; }
.dashboard-attention-item time { flex: 0 0 auto; }
.dashboard-attention-critical { border-left-color: #d65757; }
.dashboard-attention-warning { border-left-color: #d99b2b; }
.dashboard-attention-new { border-left-color: var(--accent); }
.dashboard-attention-info { border-left-color: #3f9c69; }
.dashboard-quick-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.dashboard-quick-actions .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.45rem; padding: .5rem .8rem; text-decoration: none; font-size: .84rem; font-weight: 400; }
.dashboard-priority { display: inline-flex; align-items: center; border-radius: 999px; padding: .2rem .5rem; background: var(--workspace-bg); font-size: .76rem; }
.dashboard-priority-high, .dashboard-priority-urgent { color: #a13434; background: #fce8e8; }
.dashboard-priority-normal { color: #246e99; background: #e5f3fb; }
.dashboard-priority-low { color: #5d6974; background: #edf0f2; }
body.crm-shell[data-theme="dark"] .dashboard-attention-item { background: #18232e; }
body.crm-shell[data-theme="dark"] .dashboard-priority-high, body.crm-shell[data-theme="dark"] .dashboard-priority-urgent { color: #ffd1d1; background: #512e35; }
body.crm-shell[data-theme="dark"] .dashboard-priority-normal { color: #b9e4ff; background: #183b50; }
body.crm-shell[data-theme="dark"] .dashboard-priority-low { color: #d0d8df; background: #36414d; }
@media (max-width: 760px) {
  .dashboard-quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .dashboard-quick-actions .secondary-button { display: flex; min-width: 0; min-height: 3rem; box-sizing: border-box; padding: .5rem .55rem; text-align: center; line-height: 1.25; white-space: normal; }
  .dashboard-metrics-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-finance-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-table { min-width: 0; }
  .dashboard-table-responsive thead { display: none; }
  .dashboard-table-responsive, .dashboard-table-responsive tbody { display: block; }
  .dashboard-table-responsive tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: .6rem; padding: .65rem; border: 1px solid var(--line); border-radius: 8px; }
  .dashboard-table-responsive tbody td { display: block; min-width: 0; padding: .25rem; border: 0; }
  .dashboard-table-responsive tbody td::before { display: block; margin-bottom: .15rem; color: var(--text-muted); content: attr(data-label); font-size: .7rem; }
  .dashboard-table-responsive tbody td.dashboard-empty-cell { grid-column: 1 / -1; }
  .dashboard-attention-item { flex-direction: column; gap: .25rem; }
  .dashboard-attention-item time { align-self: flex-end; }
}
@media (max-width: 440px) {
  .dashboard-metrics-overview, .dashboard-extra-metrics, .dashboard-finance-metrics { grid-template-columns: 1fr; }
  .dashboard-table-responsive tbody tr { grid-template-columns: 1fr; }
  .dashboard-heading-links { gap: .45rem; }
}

/* Реестр велосипедов */
.bikes-panel { padding: 1.2rem; }
.bikes-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.bikes-search-group { display: grid; flex: 1 1 auto; min-width: 0; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: .8rem 1.1rem; }
.bikes-search-group h1 { margin: 0; color: var(--accent); font-size: 1.35rem; font-weight: 500; }
.bikes-search-form { display: flex; width: 100%; min-width: 0; align-items: center; flex-wrap: wrap; gap: .4rem; }
.bikes-search-field { display: flex; flex: 1 1 0; width: 0; min-width: 0; min-height: 2.75rem; box-sizing: border-box; align-items: center; gap: .45rem; padding: 0 .65rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.bikes-search-field svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: var(--text-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bikes-search-field input { width: 0; min-width: 0; flex: 1 1 auto; border: 0; outline: 0; color: var(--text-main); background: transparent; font: inherit; font-size: .8rem; }
.bikes-search-field input::placeholder { color: var(--text-muted); }
.bikes-search-form .secondary-button { min-height: 2.75rem; padding: .45rem .75rem; }
.bikes-clear-search { padding: .4rem; color: var(--accent); font-size: .82rem; text-decoration: none; white-space: nowrap; }
.bikes-table-scroll { max-width: 100%; overflow-x: auto; }
.bikes-table { min-width: 75rem; font-size: .83rem; }
.bikes-table th, .bikes-table td { padding: .62rem .65rem; }
.bike-number-link { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.bike-number-link:hover, .back-link:hover { text-decoration: underline; }
.bike-status { display: inline-block; padding: .25rem .55rem; border-radius: 999px; font-size: .76rem; line-height: 1.2; white-space: nowrap; }
.bike-status-available { color: #286548; background: #e9f6ee; }
.bike-status-rented { color: #22618a; background: #e8f4fb; }
.bike-status-repair { color: #916014; background: #fff4dc; }
.bike-status-inspection { color: #6c4d9b; background: #f2ebfb; }
.bike-status-written_off, .bike-status-sold { color: #687687; background: #edf1f5; }
.danger-button { display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; padding: .65rem 1rem; border: 1px solid #bf3445; border-radius: 7px; color: #fff; background: #bf3445; font: inherit; cursor: pointer; }
.danger-button:hover { background: #a92839; }
.bike-delete-dialog > p { color: var(--text-muted); line-height: 1.5; }
.bike-delete-confirm { display: flex; align-items: center; gap: .55rem; color: var(--text-main); font-size: .88rem; }
.bike-delete-confirm input { accent-color: var(--accent); }
.bike-detail-panel { padding: 1.4rem; }
.bike-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.bike-detail-heading h1 { margin: .35rem 0 0; color: var(--text-main); font-size: 1.35rem; font-weight: 600; }
.back-link { color: var(--accent); font-size: .85rem; text-decoration: none; }
.bike-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line); }
.bike-details > div { min-width: 0; padding: .9rem .75rem; border-bottom: 1px solid var(--line); }
.bike-details > div:nth-child(3n + 1) { padding-left: 0; }
.bike-details dt { margin-bottom: .35rem; color: var(--text-muted); font-size: .78rem; }
.bike-details dd { margin: 0; overflow-wrap: anywhere; color: var(--text-main); font-size: .9rem; }
.bike-details .bike-comment-detail { grid-column: 1 / -1; padding-left: 0; }
body.crm-shell[data-theme="dark"] .bikes-search-field { background: #18232e; }
body.crm-shell[data-theme="dark"] .row-actions-menu a:hover, body.crm-shell[data-theme="dark"] .row-actions-menu button:hover { background: #263746; }
body.crm-shell[data-theme="dark"] .bike-status-available { color: #a6e0b9; background: #234335; }
body.crm-shell[data-theme="dark"] .bike-status-rented { color: #a6d5f1; background: #244257; }
body.crm-shell[data-theme="dark"] .bike-status-repair { color: #f4d18d; background: #4d3c22; }
body.crm-shell[data-theme="dark"] .bike-status-inspection { color: #d0b9f2; background: #3c3050; }
body.crm-shell[data-theme="dark"] .bike-status-written_off, body.crm-shell[data-theme="dark"] .bike-status-sold { color: #c3ced9; background: #344352; }
@media (max-width: 900px) {
  .bikes-toolbar { flex-wrap: wrap; }
  .bikes-search-group { flex: 1 1 100%; }
  .bike-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bike-details > div:nth-child(3n + 1) { padding-left: .75rem; }
  .bike-details > div:nth-child(2n + 1) { padding-left: 0; }
  .bike-details .bike-comment-detail { grid-column: 1 / -1; padding-left: 0; }
}
@media (max-width: 600px) {
  .bikes-panel { padding: .9rem; }
  .bikes-search-group { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
  .bikes-search-form { display: grid; flex: none; width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .bikes-search-field { width: auto; min-width: 0; }
  .bikes-search-field input { width: auto; font-size: .75rem; }
  .bikes-clear-search { grid-column: 1 / -1; justify-self: start; }
  .bikes-search-form .secondary-button { min-width: 4.3rem; }
  .bikes-toolbar > .primary-button { width: 100%; }
  .bike-detail-panel { padding: 1rem; }
  .bike-details { grid-template-columns: 1fr; }
  .bike-details > div, .bike-details > div:nth-child(n) { padding: .7rem 0; }
  .bike-details .bike-comment-detail { grid-column: auto; }
}
@media (max-width: 360px) {
  .bikes-search-form { grid-template-columns: minmax(0, 1fr); }
  .bikes-search-form .secondary-button { justify-self: start; }
}

/* Каталог склада */
.warehouse-panel { min-height: clamp(24rem, calc(100vh - 16rem), 34rem); padding: 1.2rem; }
.warehouse-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.warehouse-search-group { display: grid; flex: 1 1 auto; min-width: 0; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: .8rem 1.1rem; }
.warehouse-search-group h1 { margin: 0; color: var(--accent); font-size: 1.35rem; font-weight: 500; }
.warehouse-search-form { display: flex; width: 100%; min-width: 0; align-items: center; flex-wrap: wrap; gap: .4rem; }
.warehouse-search-field { display: flex; flex: 1 1 0; width: 0; min-width: 0; min-height: 2.75rem; box-sizing: border-box; align-items: center; gap: .45rem; padding: 0 .65rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.warehouse-search-form .warehouse-search-field { width: auto; }
.warehouse-search-field svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: var(--text-muted); stroke-width: 1.6; }
.warehouse-search-field input { width: 0; min-width: 0; flex: 1 1 auto; border: 0; outline: 0; color: var(--text-main); background: transparent; font: inherit; font-size: .82rem; }
.warehouse-search-form select { min-height: 2.75rem; max-width: 12rem; box-sizing: border-box; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; font-size: .82rem; }
.warehouse-search-form .secondary-button { min-height: 2.75rem; padding: .45rem .85rem; }
.warehouse-clear-search { padding: .4rem; color: var(--accent); font-size: .82rem; text-decoration: none; white-space: nowrap; }
.warehouse-table-scroll { max-width: 100%; overflow-x: auto; }
.warehouse-table { min-width: 68rem; font-size: .83rem; }
.warehouse-table th, .warehouse-table td { padding: .62rem .65rem; }
.warehouse-item-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.warehouse-item-link:hover { text-decoration: underline; }
.stock-low-badge { display: inline-block; margin-left: .45rem; padding: .2rem .45rem; border-radius: 999px; color: #9a5b13; background: #fff2dc; font-size: .7rem; white-space: nowrap; }
.warehouse-modal { width: min(100% - 2rem, 48rem); }
.warehouse-form { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.warehouse-form .warehouse-comment-field, .warehouse-form .modal-actions { grid-column: 1 / -1; }
.warehouse-delete-dialog { width: min(100% - 2rem, 32rem); }
.warehouse-delete-dialog > p { color: var(--text-muted); line-height: 1.5; }
.warehouse-detail-panel { padding: 1.4rem; }
.warehouse-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.warehouse-detail-heading h1 { margin: .35rem 0 0; color: var(--text-main); font-size: 1.35rem; font-weight: 600; }
.warehouse-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); }
.warehouse-details > div { min-width: 0; padding: .9rem .75rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.warehouse-details dt { margin-bottom: .35rem; color: var(--text-muted); font-size: .78rem; }
.warehouse-details dd { margin: 0; color: var(--text-main); font-size: .9rem; }
.warehouse-comment-detail { grid-column: 1 / -1; padding-left: 0 !important; }
.stock-low-notice { margin: 0 0 1rem; padding: .7rem .85rem; border-radius: 7px; color: #875211; background: #fff2dc; }
.supplier-history-panel { margin-top: .9rem; }
.supplier-history-panel h2 { margin: 0 0 .8rem; color: var(--text-main); font-size: 1rem; font-weight: 600; }
.supplier-table, .purchase-table { min-width: 52rem; }
.purchase-search-group, .supplier-search-group { grid-template-columns: max-content minmax(0, 1fr); }
.purchase-create-modal { width: min(100% - 2rem, 58rem); }
.purchase-form { gap: .8rem; }
.purchase-header-fields .form-field textarea { height: 2.75rem; min-height: 2.75rem; resize: vertical; }
.purchase-form h3 { margin: .3rem 0 0; color: var(--text-main); font-size: .95rem; }
.purchase-header-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.purchase-header-fields .form-field { min-width: 0; }
.purchase-lines { display: grid; gap: .6rem; }
.purchase-line-row { display: grid; grid-template-columns: minmax(11rem, 1.8fr) minmax(5.5rem, .6fr) minmax(7rem, .8fr) auto; align-items: end; gap: .6rem; padding: .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.purchase-line-row .form-field { min-width: 0; margin: 0; }
.purchase-line-row .form-field label { font-size: .82rem; }
.purchase-line-row .form-field select, .purchase-line-row .form-field input { width: 100%; min-width: 0; min-height: 2.45rem; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; font-size: .85rem; }
.purchase-line-delete { display: flex; align-self: end; align-items: center; gap: .35rem; padding: 0; }
.purchase-line-delete .secondary-button { min-height: 2.45rem; padding: .45rem .7rem; font-weight: 400; }
.purchase-add-line { min-height: 2.45rem; padding: .45rem .7rem; }
.purchase-line-row[hidden] { display: none; }
.purchase-add-line { justify-self: start; }
.purchase-prerequisite { color: var(--text-muted); line-height: 1.5; }
.purchase-detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.purchase-detail-actions .danger-button { min-height: 2.75rem; }
.purchase-canceled-badge { display: inline-block; vertical-align: middle; padding: .25rem .55rem; border-radius: 999px; color: #8d3942; background: #fae9eb; font-size: .75rem; font-weight: 400; }
.purchase-cancellation-note { margin-top: 1rem; padding: .8rem; border-radius: 7px; color: #8d3942; background: #fae9eb; }
.sales-toolbar { align-items: flex-end; }
.sales-search-group { grid-template-columns: max-content minmax(0, 1fr); align-items: end; }
.sales-search-group h1 { align-self: end; margin-bottom: .5rem; white-space: nowrap; }
.sales-filter-form { display: grid; grid-template-columns: minmax(7rem, 1fr) repeat(2, minmax(8rem, 8rem)) auto; align-items: end; gap: .45rem; flex-wrap: nowrap; }
.sales-filter-form .warehouse-search-field { width: auto; min-width: 0; }
.sales-date-filter { display: grid; min-width: 8rem; grid-template-rows: auto 2.75rem; align-content: end; gap: .2rem; color: var(--text-muted); font-size: .72rem; white-space: nowrap; }
.sales-date-filter input { width: 100%; min-width: 0; min-height: 2.75rem; box-sizing: border-box; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; font-size: .8rem; }
.sales-table { min-width: 76rem; }
.sale-item-summary { display: block; white-space: nowrap; }
.sale-totals-preview { display: flex; flex-wrap: wrap; gap: .55rem 1.2rem; color: var(--text-muted); font-size: .86rem; }
.sale-totals-preview output { color: var(--text-main); font-weight: 600; }
.sale-canceled-badge { display: inline-block; margin-left: .35rem; padding: .2rem .45rem; border-radius: 999px; color: #8d3942; background: #fae9eb; font-size: .7rem; font-weight: 400; white-space: nowrap; }
.sale-cancellation-note { margin-top: 1rem; padding: .8rem; border-radius: 7px; color: #8d3942; background: #fae9eb; }
body.crm-shell[data-theme="dark"] .purchase-line-row { background: #18232e; }
body.crm-shell[data-theme="dark"] .purchase-line-row .form-field select, body.crm-shell[data-theme="dark"] .purchase-line-row .form-field input { color: var(--text-main); background: #18232e; }
body.crm-shell[data-theme="dark"] .purchase-canceled-badge, body.crm-shell[data-theme="dark"] .purchase-cancellation-note { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .sale-canceled-badge, body.crm-shell[data-theme="dark"] .sale-cancellation-note { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .warehouse-search-field { background: #18232e; }
body.crm-shell[data-theme="dark"] .warehouse-search-form select { background: #18232e; }
body.crm-shell[data-theme="dark"] .stock-low-badge, body.crm-shell[data-theme="dark"] .stock-low-notice { color: #f0cb91; background: #49391f; }
@media (max-width: 960px) {
  .warehouse-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .warehouse-toolbar { flex-wrap: wrap; }
  .warehouse-search-group { flex: 1 1 100%; }
}
@media (max-width: 600px) {
  .warehouse-panel { padding: .9rem; }
  .warehouse-search-group { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
  .warehouse-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .warehouse-search-form select { grid-column: 1 / -1; width: 100%; max-width: none; }
  .warehouse-search-form .secondary-button { grid-column: 1 / -1; justify-self: start; }
  .warehouse-toolbar > .primary-button { width: 100%; }
  .warehouse-form, .warehouse-details { grid-template-columns: 1fr; }
  .warehouse-form .warehouse-comment-field, .warehouse-form .modal-actions, .warehouse-comment-detail { grid-column: auto; }
  .warehouse-detail-panel { padding: 1rem; }
  .purchase-header-fields { grid-template-columns: 1fr; }
  .purchase-line-row { grid-template-columns: minmax(0, 1fr) minmax(5rem, .5fr); }
  .purchase-line-row .form-field:first-of-type { grid-column: 1 / -1; }
  .purchase-line-delete { grid-column: 1 / -1; justify-content: flex-end; padding-bottom: 0; }
  .purchase-detail-actions { justify-content: flex-start; }
  .sales-search-group { grid-template-columns: minmax(0, 1fr); }
  .sales-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sales-filter-form .warehouse-search-field { grid-column: 1 / -1; }
  .sales-filter-form .secondary-button { grid-column: 1 / -1; justify-self: start; }
}

/* Ремонты используют общую верхнюю строку склада и форму закупки. */
.repairs-search-group { grid-template-columns: max-content minmax(0, 1fr); }
.repairs-search-form { flex-wrap: nowrap; }
.repairs-table { min-width: 74rem; }
.repair-status { display: inline-block; padding: .22rem .55rem; border-radius: 999px; color: #28618a; background: #e7f3fb; font-size: .75rem; font-weight: 400; white-space: nowrap; }
.repair-status-in_progress { color: #805b10; background: #fff1ce; }
.repair-status-waiting_parts { color: #76539a; background: #f1eafa; }
.repair-status-completed { color: #28714b; background: #e5f5ec; }
.repair-status-canceled { color: #8d3942; background: #fae9eb; }
.repair-form h3 { margin-top: .25rem; }
.repair-form [hidden] { display: none !important; }
.repair-external-toggle { display: flex; min-height: 2.75rem; align-items: center; gap: .5rem; color: var(--text-main); font-size: .83rem; }
.repair-parts-optional { margin: -.55rem 0 0; color: var(--text-muted); font-size: .8rem; }
.repair-line-row { grid-template-columns: minmax(11rem, 1.8fr) minmax(5.5rem, .6fr) minmax(8rem, .8fr) auto; }
.repair-part-estimate { align-self: center; color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.repair-confirm-stock { display: flex; align-items: center; gap: .5rem; color: var(--text-main); font-size: .83rem; }
.repair-confirm-stock input { accent-color: var(--accent); }
.repair-total-preview { color: var(--text-muted); font-size: .88rem; }
.repair-total-preview strong { color: var(--text-main); }
.repair-detail-panel .repair-status { vertical-align: middle; }
body.crm-shell[data-theme="dark"] .repair-status-open { color: #acd6f2; background: #20394a; }
body.crm-shell[data-theme="dark"] .repair-status-in_progress { color: #f0d38e; background: #49391f; }
body.crm-shell[data-theme="dark"] .repair-status-waiting_parts { color: #d8bdf2; background: #392c4c; }
body.crm-shell[data-theme="dark"] .repair-status-completed { color: #9bd7b4; background: #203c2d; }
body.crm-shell[data-theme="dark"] .repair-status-canceled { color: #f0b3b9; background: #48272c; }
@media (max-width: 600px) {
  .repairs-search-group { grid-template-columns: minmax(0, 1fr); }
  .repairs-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .repair-line-row { grid-template-columns: minmax(0, 1fr) minmax(5rem, .5fr); }
  .repair-line-row .form-field:first-of-type { grid-column: 1 / -1; }
  .repair-part-estimate { align-self: center; }
}

/* Техническое обслуживание использует готовые элементы складских разделов. */
.maintenance-search-group { grid-template-columns: max-content minmax(0, 1fr); }
.maintenance-panel, .maintenance-detail-panel, .maintenance-history-panel { min-width: 0; max-width: 100%; overflow-x: clip; }
.maintenance-toolbar, .maintenance-search-group, .maintenance-search-form, .maintenance-panel > .table-scroll, .maintenance-history-panel > .table-scroll { min-width: 0; max-width: 100%; }
.maintenance-search-form { flex-wrap: nowrap; }
.maintenance-panel > .table-scroll { width: 100%; overflow-x: auto; }
.maintenance-history-panel > .table-scroll { width: 100%; overflow-x: auto; }
.maintenance-table { width: 100%; min-width: 68rem; }
.maintenance-part-summary { display: block; white-space: normal; overflow-wrap: anywhere; }
.maintenance-line-row { grid-template-columns: minmax(11rem, 1.8fr) minmax(5.5rem, .6fr) minmax(8rem, .8fr) auto; }
.maintenance-part-estimate { align-self: center; color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.maintenance-confirm-stock { display: flex; align-items: center; gap: .5rem; color: var(--text-main); font-size: .83rem; }
.maintenance-confirm-stock input, .maintenance-repair-confirm-field input { accent-color: var(--accent); }
.maintenance-total-preview { color: var(--text-muted); font-size: .88rem; }
.maintenance-total-preview strong { color: var(--text-main); }
.maintenance-repair-confirm-field { grid-column: 1 / -1; }
.maintenance-repair-confirm-field label { display: flex; align-items: flex-start; gap: .45rem; }
.maintenance-repair-confirm-field small { color: var(--text-muted); font-size: .76rem; }
.maintenance-history-heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.maintenance-history-heading h2, .bike-maintenance-history h2, .maintenance-detail-panel + .supplier-history-panel h2 { margin: 0; color: var(--accent); font-size: 1rem; font-weight: 600; }
.maintenance-history-heading .secondary-button { display: inline-flex; align-items: center; padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; white-space: nowrap; }
.maintenance-history-table { min-width: 72rem; }
.maintenance-notification { display: grid; gap: .18rem; padding: .65rem .7rem; border-radius: 7px; color: var(--text-main); text-decoration: none; }
.maintenance-notification:hover { background: var(--workspace-bg); }
.maintenance-notification span { font-size: .83rem; }
.maintenance-notification small { color: var(--text-muted); font-size: .75rem; }
.maintenance-notification-overdue span { color: #b53b47; }
.maintenance-notification-today span { color: #9a641a; }
.maintenance-notification-soon span { color: var(--accent); }
.notification-menu { position: relative; }
.notification-button { list-style: none; }
.notification-button::-webkit-details-marker { display: none; }
.notification-dropdown { position: absolute; top: calc(100% + .55rem); right: 0; z-index: 35; width: min(22rem, calc(100vw - 2rem)); max-height: min(70vh, 26rem); overflow-y: auto; padding: .55rem; border: 1px solid var(--line); border-radius: 9px; color: var(--text-main); background: var(--surface); box-shadow: 0 8px 24px rgb(31 66 100 / 14%); }
.notification-dropdown > strong { display: block; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
.notification-empty { margin: 0; padding: .85rem .7rem; color: var(--text-muted); font-size: .82rem; }
body.crm-shell[data-theme="dark"] .maintenance-notification-overdue span { color: #f0a4aa; }
body.crm-shell[data-theme="dark"] .maintenance-notification-today span { color: #e8c47a; }
body.crm-shell[data-theme="dark"] .notification-dropdown { background: var(--surface); border-color: var(--line); }
@media (max-width: 600px) {
  .maintenance-search-group { grid-template-columns: minmax(0, 1fr); }
  .maintenance-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .maintenance-line-row { grid-template-columns: minmax(0, 1fr) minmax(5rem, .5fr); }
  .maintenance-line-row .form-field:first-of-type { grid-column: 1 / -1; }
  .maintenance-part-estimate { align-self: center; }
  .maintenance-repair-confirm-field { grid-column: auto; }
  .maintenance-history-heading { align-items: flex-start; flex-direction: column; }
}

/* Реестр клиентов использует стандартные элементы складских списков и карточек. */
.clients-search-group { grid-template-columns: max-content minmax(0, 1fr); }
.clients-search-form { flex-wrap: nowrap; }
.clients-table { min-width: 66rem; }
.clients-table th, .clients-table td { padding: .62rem .65rem; }
.client-phone-link { color: var(--text-main); text-decoration: none; white-space: nowrap; }
.client-phone-link:hover { color: var(--accent); text-decoration: underline; }
.client-data-unavailable { color: var(--text-muted); font-size: .8rem; }
.client-modal { width: min(100% - 2rem, 52rem); }
.client-form { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.client-wide-field, .client-form .modal-actions, .client-duplicate-warning { grid-column: 1 / -1; }
.client-duplicate-warning { padding: .75rem .85rem; border: 1px solid #efd49a; border-radius: 8px; color: #72551d; background: #fff8e8; font-size: .84rem; line-height: 1.45; }
.client-duplicate-warning strong { display: block; font-weight: 600; }
.client-duplicate-warning p { margin: .3rem 0 .45rem; }
.client-duplicate-warning ul { display: grid; gap: .3rem; margin: .35rem 0 .7rem; padding-left: 1.2rem; }
.client-duplicate-warning a { color: #287fb8; }
.client-duplicate-warning li span { color: var(--text-muted); }
.client-duplicate-confirm { display: flex; align-items: flex-start; gap: .45rem; color: var(--text-main); font-size: .82rem; }
.client-duplicate-confirm input { margin: .15rem 0 0; accent-color: var(--accent); }
.client-detail-panel > .client-info-section { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.client-info-section h2 { margin: 0 0 .65rem; color: var(--accent); font-size: 1rem; font-weight: 600; }
.client-details { border-top: 0; }
.client-details > div { padding-top: .65rem; padding-bottom: .65rem; }
.client-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.client-summary-grid .client-info-section { min-width: 0; }
.client-empty-state { margin: 0; padding: .75rem .8rem; border-radius: 7px; color: var(--text-muted); background: var(--workspace-bg); font-size: .84rem; line-height: 1.5; }
.client-comment-content { margin: 0; color: var(--text-main); font-size: .88rem; line-height: 1.55; overflow-wrap: anywhere; }
.client-archived-badge { display: inline-block; margin-left: .35rem; padding: .2rem .5rem; border-radius: 999px; color: #8d3942; background: #fae9eb; font-size: .72rem; font-weight: 400; vertical-align: middle; }
.client-archive-note { margin-top: 1rem; padding: .8rem; border-radius: 7px; color: #8d3942; background: #fae9eb; font-size: .84rem; }
body.crm-shell[data-theme="dark"] .client-duplicate-warning { color: #e8d29c; background: #3b3322; border-color: #65532d; }
body.crm-shell[data-theme="dark"] .client-duplicate-warning a { color: var(--accent); }
body.crm-shell[data-theme="dark"] .client-archived-badge, body.crm-shell[data-theme="dark"] .client-archive-note { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .client-empty-state { background: #18232e; }
@media (max-width: 600px) {
  .clients-search-group { grid-template-columns: minmax(0, 1fr); }
  .clients-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .client-form { grid-template-columns: 1fr; }
  .client-wide-field, .client-form .modal-actions, .client-duplicate-warning { grid-column: auto; }
  .client-summary-grid { grid-template-columns: 1fr; }
  .client-detail-panel { padding: 1rem; }
}

/* Аренда использует таблицу, карточки и модальные формы общих разделов CRM. */
.rentals-search-group { grid-template-columns: max-content minmax(0, 1fr); }
.rentals-filter-form { flex-wrap: nowrap; }
.rentals-filter-form select { flex: 0 0 9rem; }
.rentals-table-scroll { max-width: 100%; overflow: visible; }
.warehouse-table.rentals-table { width: 100%; min-width: 0; table-layout: fixed; font-size: .78rem; }
.rentals-table th, .rentals-table td { padding: .48rem .38rem; vertical-align: top; overflow-wrap: anywhere; }
.rentals-table th { font-size: .7rem; line-height: 1.25; }
.rentals-table th:nth-child(1) { width: 12%; }
.rentals-table th:nth-child(2) { width: 17%; }
.rentals-table th:nth-child(3) { width: 12%; }
.rentals-table th:nth-child(4) { width: 9%; }
.rentals-table th:nth-child(5) { width: 12%; }
.rentals-table th:nth-child(6) { width: 20%; }
.rentals-table th:nth-child(7) { width: 12%; }
.rentals-table th:nth-child(8) { width: 6%; }
.rentals-table .rental-cell-label { display: none; }
.rentals-table td small { display: block; margin-top: .16rem; color: var(--text-muted); font-size: .7rem; line-height: 1.35; overflow-wrap: anywhere; }
.rental-client-link { display: block; }
.rental-bike-summary { display: block; color: var(--accent); font-size: .78rem; text-decoration: none; overflow-wrap: anywhere; }
.rental-bike-summary:hover { text-decoration: underline; }
.rental-status { display: inline-block; padding: .22rem .55rem; border-radius: 999px; color: #28714b; background: #e5f5ec; font-size: .75rem; font-weight: 400; white-space: nowrap; }
.rental-status.rental-status-later { color: #28714b; background: #e5f5ec; }
.rental-status.rental-status-tomorrow { color: #806313; background: #fff3cd; }
.rental-status.rental-status-today { color: #8d3942; background: #fae9eb; }
.rental-status.rental-status-overdue { color: #8d3942; background: #fae9eb; }
.rental-status.rental-status-completed, .rental-status.rental-status-canceled { color: #52677c; background: #edf2f6; }
.rental-status.rental-status-unpaid { margin-top: .25rem; color: #8d3942; background: #fae9eb; }
.rental-payment-status { display: inline-block; width: fit-content; padding: .18rem .45rem; border-radius: 999px; font-size: .69rem; line-height: 1.25; font-weight: 400; }
.rental-payment-status-paid { color: #28714b; background: #e5f5ec; }
.rental-payment-status-partial { color: #806313; background: #fff3cd; }
.rental-payment-status-unpaid { color: #8d3942; background: #fae9eb; }
.rental-create-modal { width: min(100% - 2rem, 60rem); }
.rental-form { gap: .75rem; }
.rental-form .form-field { min-width: 0; }
.rental-form .rental-wide-field, .rental-form .modal-actions { grid-column: 1 / -1; }
.rental-bike-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.rental-bike-row .form-field { margin: 0; }
.rental-bike-row .form-field select { width: 100%; min-height: 2.45rem; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; font-size: .85rem; }
.rental-bike-row .purchase-line-delete { align-self: end; }
.rental-bike-row .purchase-line-delete .secondary-button { min-height: 2.45rem; }
.rental-bikes-block { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.rental-bikes-block h2 { margin: 0 0 .65rem; color: var(--accent); font-size: 1rem; font-weight: 600; }
.rental-bikes-block ul { display: grid; gap: .45rem; margin: 0; padding-left: 1.2rem; }
.rental-bikes-block li { color: var(--text-main); font-size: .88rem; }
.rental-bikes-block .bike-status { margin-left: .35rem; }
.rental-payments-table { min-width: 48rem; }
.rental-events-table { min-width: 38rem; }
body.crm-shell[data-theme="dark"] .rental-status-active { color: #9bd7b4; background: #203c2d; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-later { color: #9bd7b4; background: #203c2d; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-tomorrow { color: #f0d47c; background: #463c1e; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-today { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .rental-status-overdue, body.crm-shell[data-theme="dark"] .rental-status-canceled { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-overdue { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-completed, body.crm-shell[data-theme="dark"] .rental-status.rental-status-canceled { color: #bdcbd8; background: #2b3946; }
body.crm-shell[data-theme="dark"] .rental-status.rental-status-unpaid { color: #f0b3b9; background: #48272c; }
body.crm-shell[data-theme="dark"] .rental-bike-row .form-field select { color: var(--text-main); background: #18232e; }
@media (max-width: 600px) {
  .rentals-search-group { grid-template-columns: minmax(0, 1fr); }
  .rentals-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .rentals-filter-form select { grid-column: 1 / -1; width: 100%; }
  .rental-form .rental-wide-field, .rental-form .modal-actions { grid-column: auto; }
  .rental-bike-row { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 1199px) {
  .rentals-toolbar { flex-wrap: wrap; }
  .rentals-search-group { flex: 1 1 100%; grid-template-columns: minmax(0, 1fr); gap: .55rem; }
  .rentals-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; width: 100%; gap: .45rem; }
  .rentals-filter-form select { width: auto; max-width: none; flex: initial; }
  .rentals-table-scroll { overflow: visible; }
  .warehouse-table.rentals-table,
  .warehouse-table.rentals-table tbody { display: block; }
  .warehouse-table.rentals-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .warehouse-table.rentals-table tbody { display: grid; gap: .75rem; }
  .warehouse-table.rentals-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .7rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 2px 8px rgb(31 66 100 / 4%); }
  .warehouse-table.rentals-table tbody td { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: .16rem; box-sizing: border-box; padding: .45rem .25rem; border: 0; font-size: .82rem; }
  .warehouse-table.rentals-table .rental-cell-label { display: block; color: var(--text-muted); font-size: .7rem; line-height: 1.25; }
  .warehouse-table.rentals-table td:nth-child(3),
  .warehouse-table.rentals-table td:nth-child(6) { grid-column: 1 / -1; }
  .warehouse-table.rentals-table td:nth-child(8) { align-items: flex-end; }
  .warehouse-table.rentals-table .actions-column { text-align: right; }
  .warehouse-table.rentals-table .empty-row { grid-column: 1 / -1; display: block; padding: .85rem .45rem; text-align: center; }
  .warehouse-table.rentals-table .empty-row::before { display: none; }
}
@media (max-width: 600px) {
  .rentals-search-group { grid-template-columns: minmax(0, 1fr); }
  .rentals-filter-form { grid-template-columns: minmax(0, 1fr) auto; }
  .rentals-filter-form select,
  .rentals-filter-form .secondary-button { grid-column: 1 / -1; justify-self: start; }
  .warehouse-table.rentals-table tbody tr { padding-inline: .45rem; gap: 0 .4rem; }
  .warehouse-table.rentals-table tbody td { padding-inline: .18rem; }
}
@media (max-width: 760px) {
  .rental-detail-panel .warehouse-detail-heading { align-items: stretch; flex-direction: column; }
  .rental-detail-panel .purchase-detail-actions {
    display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch; gap: .5rem;
  }
  .rental-detail-panel .purchase-detail-actions > .primary-button,
  .rental-detail-panel .purchase-detail-actions > .secondary-button,
  .rental-detail-panel .purchase-detail-actions > .danger-button {
    display: flex; width: 100%; min-width: 0; min-height: 3rem;
    box-sizing: border-box; align-items: center; justify-content: center;
    padding: .5rem .55rem; text-align: center; line-height: 1.25; white-space: normal;
  }
}
.finance-panel, .finance-form-panel { display: grid; gap: 16px; min-width: 0; }
.finance-panel .warehouse-table { width: 100%; min-width: 0; table-layout: fixed; }
.finance-panel .warehouse-table th, .finance-panel .warehouse-table td { overflow-wrap: anywhere; }
.finance-panel h1, .finance-form-panel h1 { margin: 0; }
.finance-panel h2 { margin: 12px 0 0; font-size: 17px; font-weight: 500; }
.finance-balance-card { display: grid; gap: 5px; padding: 20px 22px; border: 1px solid #d9e9f5; border-radius: 14px; background: #f4faff; }
.finance-balance-card > span, .finance-metrics article > span { color: #657987; font-size: 13px; }
.finance-balance-card strong { color: #237bb3; font-size: 28px; font-weight: 500; }
.finance-balance-card small, .finance-metrics small { color: #71808a; font-size: 12px; }
.finance-period-form, .finance-actions, .finance-links { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.finance-period-form label { display: grid; gap: 5px; color: #596d7a; font-size: 12px; }
.finance-period-form input, .finance-period-form select { width: auto; height: 2.75rem; min-height: 2.75rem; box-sizing: border-box; padding: .45rem .65rem; border: 1px solid #d7e3eb; border-radius: 8px; background: #fff; color: #263746; font: inherit; }
.finance-inline-form input { min-height: 38px; padding: 7px 10px; border: 1px solid #d7e3eb; border-radius: 8px; background: #fff; color: #263746; font: inherit; }
.finance-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; }
.finance-metrics article { display: grid; align-content: start; gap: 6px; min-width: 0; padding: 14px; border: 1px solid #e5edf2; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(31, 64, 87, .04); }
.finance-metrics strong { color: #2a475b; font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.finance-actions a, .finance-links a { text-decoration: none; }
.finance-inline-form { display: flex; flex-wrap: wrap; gap: 7px; }
.finance-inline-form input { min-width: 140px; }
.finance-form-panel { max-width: 760px; }
.finance-form-panel form { display: grid; gap: 12px; }
.finance-form-panel form > p { display: grid; min-width: 0; grid-template-columns: minmax(10rem, .38fr) minmax(0, 1fr); align-items: center; gap: .75rem; margin: 0; }
.finance-form-panel form > p > label { color: var(--text-muted); font-size: .9rem; }
.finance-form-panel form > p input:not([type="checkbox"]):not([type="hidden"]),
.finance-form-panel form > p select,
.finance-form-panel form > p textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 2.65rem; box-sizing: border-box; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; }
.finance-form-panel form > p textarea { min-height: 4.5rem; resize: vertical; }
.finance-form-panel form > p input:focus,
.finance-form-panel form > p select:focus,
.finance-form-panel form > p textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.finance-form-panel form .modal-actions { margin-top: 0; }
.finance-panel .row-actions-menu form { display: grid; gap: 8px; min-width: 220px; }
.finance-panel .row-actions-menu label { display: grid; gap: 5px; }
.finance-panel .row-actions-menu input { min-height: 36px; border: 1px solid #d7e3eb; border-radius: 8px; padding: 6px 9px; }
dialog#finance-account-modal .modal-form,
dialog#finance-account-edit-modal .modal-form { min-width: 0; }
dialog#finance-account-modal .modal-form > p,
dialog#finance-account-edit-modal .modal-form > p { display: grid; min-width: 0; gap: .35rem; margin: 0; }
dialog#finance-account-modal .modal-form > p input:not([type="hidden"]):not([type="checkbox"]),
dialog#finance-account-modal .modal-form > p select,
dialog#finance-account-modal .modal-form > p textarea,
dialog#finance-account-edit-modal .modal-form > p input:not([type="hidden"]):not([type="checkbox"]),
dialog#finance-account-edit-modal .modal-form > p select,
dialog#finance-account-edit-modal .modal-form > p textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 2.75rem; box-sizing: border-box; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; }
dialog#finance-account-modal .modal-form > p:has(input[type="checkbox"]),
dialog#finance-account-edit-modal .modal-form > p:has(input[type="checkbox"]) { display: flex; align-items: center; gap: .6rem; }
dialog#finance-account-modal .modal-form > p input[type="checkbox"],
dialog#finance-account-edit-modal .modal-form > p input[type="checkbox"] { width: 1.15rem; height: 1.15rem; min-height: 1.15rem; margin: 0; padding: 0; accent-color: var(--accent); }
dialog#finance-account-modal .modal-form > p textarea,
dialog#finance-account-edit-modal .modal-form > p textarea { min-height: 4.5rem; resize: vertical; }
dialog#finance-account-modal .modal-form > p input:not([type="checkbox"]):focus,
dialog#finance-account-modal .modal-form > p select:focus,
dialog#finance-account-modal .modal-form > p textarea:focus,
dialog#finance-account-edit-modal .modal-form > p input:not([type="checkbox"]):focus,
dialog#finance-account-edit-modal .modal-form > p select:focus,
dialog#finance-account-edit-modal .modal-form > p textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
body.crm-shell[data-theme="dark"] .finance-balance-card { color: var(--text-main); background: var(--workspace-bg); border-color: var(--line); }
body.crm-shell[data-theme="dark"] .finance-balance-card > span,
body.crm-shell[data-theme="dark"] .finance-balance-card small,
body.crm-shell[data-theme="dark"] .finance-metrics article > span,
body.crm-shell[data-theme="dark"] .finance-metrics small { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .finance-balance-card strong { color: var(--accent); }
body.crm-shell[data-theme="dark"] .finance-metrics article { color: var(--text-main); background: var(--surface); border-color: var(--line); box-shadow: none; }
body.crm-shell[data-theme="dark"] .finance-metrics strong { color: var(--text-main); }
body.crm-shell[data-theme="dark"] .finance-period-form label { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .finance-period-form input,
body.crm-shell[data-theme="dark"] .finance-period-form select,
body.crm-shell[data-theme="dark"] .finance-form-panel input:not([type="hidden"]),
body.crm-shell[data-theme="dark"] .finance-form-panel select,
body.crm-shell[data-theme="dark"] .finance-form-panel textarea,
body.crm-shell[data-theme="dark"] dialog[id^="finance-"] input:not([type="hidden"]),
body.crm-shell[data-theme="dark"] dialog[id^="finance-"] select,
body.crm-shell[data-theme="dark"] dialog[id^="finance-"] textarea { color: var(--text-main); background: #18232e; border-color: var(--line); color-scheme: dark; }
body.crm-shell[data-theme="dark"] dialog#finance-account-modal .modal-form > p,
body.crm-shell[data-theme="dark"] dialog#finance-account-edit-modal .modal-form > p { color: var(--text-main); }
@media (max-width: 700px) {
  .finance-balance-card strong { font-size: 24px; }
  .finance-period-form { align-items: stretch; flex-direction: column; }
  .finance-period-form > * { width: 100%; }
  .finance-actions > * { flex: 1 1 100%; text-align: center; }
  .finance-form-panel form > p { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
}
.analytics-panel { gap: 14px; }
.analytics-panel .warehouse-toolbar { align-items: center; }
.analytics-panel .warehouse-toolbar h1 { margin: 0; }
.analytics-metrics article { min-height: 92px; }
.analytics-section { display: grid; min-width: 0; gap: 10px; }
.analytics-section h2 { margin: 8px 0 0; }
.analytics-note { margin: 0; color: var(--text-muted); font-size: .8rem; line-height: 1.5; }
.analytics-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analytics-chart-frame { width: 100%; min-width: 0; overflow: hidden; }
.analytics-chart-svg { display: block; width: 100%; height: auto; color: var(--text-muted); overflow: visible; }
.analytics-chart-grid line { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.analytics-chart-grid text, .analytics-chart-xlabels text { fill: var(--text-muted); font: 11px Arial, sans-serif; }
.analytics-chart-zero { stroke: var(--text-muted) !important; stroke-width: 1.5 !important; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.analytics-bar { stroke: none; transition: filter .12s ease; }
.analytics-bar:hover { filter: brightness(.86); }
.analytics-bar-income { fill: #398fc1; }
.analytics-bar-expenses { fill: #d1786d; }
.analytics-bar-profit { fill: #368f67; }
.analytics-legend { display: flex; gap: 16px; color: var(--text-muted); font-size: .78rem; }
.analytics-legend span { display: inline-flex; align-items: center; gap: 6px; }
.analytics-legend i { width: 8px; height: 8px; border-radius: 50%; }
.income-dot { background: #398fc1; }
.expense-dot { background: #d1786d; }
.profit-dot { background: #368f67; }
.analytics-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 9px; }
.analytics-results > div { display: grid; gap: 5px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.analytics-results span { color: var(--text-muted); font-size: .76rem; }
.analytics-results strong { font-size: .93rem; font-weight: 500; color: var(--text-main); }
body.crm-shell[data-theme="dark"] .analytics-results > div { background: var(--surface); border-color: var(--line); }
body.crm-shell[data-theme="dark"] .analytics-results strong { color: var(--text-main); }
@media (max-width: 760px) {
  .analytics-tables { grid-template-columns: minmax(0, 1fr); }
  .analytics-chart-grid text, .analytics-chart-xlabels text { font-size: 10px; }
  .analytics-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .analytics-results { grid-template-columns: minmax(0, 1fr); }
}

/* Задачи и календарь используют общие компоненты CRM. */
.task-panel, .task-detail-panel, .task-section, .task-calendar-panel { display: grid; min-width: 0; gap: 1rem; }
.task-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: .75rem; }
.task-toolbar > h1, .task-calendar-toolbar h1 { margin: 0; color: var(--accent); font-size: 1.35rem; font-weight: 500; }
.task-filter-form { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: .4rem; }
.task-filter-form .warehouse-search-field { width: auto; min-width: 14rem; flex: 2 1 14rem; }
.task-filter-form select { width: auto; min-width: 7rem; max-width: none; flex: 1 1 7rem; }
.task-filter-form .task-add-button { flex: 0 0 auto; white-space: nowrap; }
.task-table { width: 100%; min-width: 0; table-layout: fixed; }
.task-table th, .task-table td { padding: .55rem .6rem; overflow-wrap: anywhere; vertical-align: top; }
.task-table th:nth-child(1) { width: 11%; }
.task-table th:nth-child(2) { width: 24%; }
.task-table th:nth-child(3) { width: 17%; }
.task-table th:nth-child(4) { width: 16%; }
.task-table th:nth-child(5) { width: 11%; }
.task-table th:nth-child(6) { width: 13%; }
.task-table th:nth-child(7) { width: 8%; }
.task-priority, .task-status, .task-deadline { display: inline-block; width: fit-content; padding: .2rem .48rem; border-radius: 999px; font-size: .73rem; line-height: 1.3; font-weight: 400; }
.task-status-new, .task-status-in_progress, .task-priority-normal, .task-event-task { color: #176fae; background: #e5f3fc; }
.task-status-today, .task-status-overdue, .task-deadline-today, .task-deadline-overdue, .task-priority-urgent { color: #8d3942; background: #fae9eb; }
.task-status-tomorrow, .task-deadline-tomorrow, .task-priority-high, .task-event-maintenance { color: #806313; background: #fff3cd; }
.task-status-completed, .task-event-rental { color: #28714b; background: #e5f5ec; }
.task-status-canceled, .task-priority-low { color: #52677c; background: #edf2f6; }
.task-status-deleted { color: #52677c; background: #edf2f6; }
.task-priority { white-space: nowrap; }
.task-table td small, .task-detail-grid .task-deadline { display: block; margin-top: .25rem; }
.task-modal { width: min(100% - 2rem, 46rem); }
.task-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .2rem 1rem; }
.task-form .task-form-wide, .task-form .modal-actions { grid-column: 1 / -1; }
.task-detail-heading, .task-calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.task-detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.task-detail-heading h1 { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .45rem 0 0; font-size: 1.35rem; font-weight: 500; }
.task-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.task-detail-grid > div { min-width: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 9px; background: var(--workspace-bg); overflow-wrap: anywhere; }
.task-detail-grid dt { margin-bottom: .3rem; color: var(--text-muted); font-size: .78rem; }
.task-detail-grid dd { margin: 0; color: var(--text-main); }
.task-detail-grid .task-description { grid-column: 1 / -1; }
.task-section h2 { margin: 0; font-size: 1rem; font-weight: 500; }
.task-status-form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.task-status-form label { color: var(--text-muted); font-size: .85rem; }
.task-status-form select, .task-calendar-nav input[type="date"] { min-height: 2.5rem; box-sizing: border-box; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text-main); font: inherit; }
.task-comment-form { max-width: 48rem; }
.task-comment-form .primary-button { justify-self: start; }
.task-comment-list { display: grid; gap: .6rem; }
.task-comment { padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 9px; background: var(--workspace-bg); }
.task-comment > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; color: var(--text-muted); font-size: .78rem; }
.task-comment > div strong { color: var(--text-main); font-weight: 500; }
.task-comment p { margin: .5rem 0 0; overflow-wrap: anywhere; }
.task-history { display: grid; gap: .6rem; margin: 0; padding: 0; list-style: none; }
.task-history li { display: grid; grid-template-columns: 9rem minmax(8rem, .7fr) minmax(0, 2fr); gap: .7rem; align-items: start; padding: .65rem 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.task-history time { color: var(--text-muted); }
.task-history strong { font-weight: 500; }
.task-history .empty-state { display: block; }
.task-calendar-toolbar { flex-wrap: wrap; align-items: flex-start; }
.task-calendar-toolbar h2 { margin: .4rem 0 0; font-size: 1.05rem; font-weight: 500; }
.task-calendar-controls { display: grid; justify-items: end; gap: .6rem; }
.task-calendar-views, .task-calendar-nav, .task-calendar-nav form { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.task-calendar-views { padding: .2rem; border: 1px solid var(--line); border-radius: 8px; background: var(--workspace-bg); }
.task-calendar-views a { padding: .38rem .65rem; border-radius: 6px; color: var(--text-muted); font-size: .82rem; text-decoration: none; }
.task-calendar-views a[aria-current="page"] { color: #fff; background: var(--accent); }
body.crm-shell[data-theme="dark"] .task-calendar-views a[aria-current="page"] { color: #14212c !important; }
.task-calendar-nav .secondary-button { min-height: 2.4rem; padding: .35rem .65rem; text-decoration: none; }
.task-calendar-nav form { margin: 0; }
.task-calendar-legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.task-event { display: inline-block; width: fit-content; padding: .2rem .5rem; border-radius: 999px; font-size: .73rem; }
.task-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.task-calendar-grid-day { grid-template-columns: minmax(0, 1fr); }
.task-calendar-weekdays { display: contents; }
.task-calendar-weekdays span { padding: .5rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text-muted); font-size: .75rem; text-align: center; }
.task-calendar-day { min-width: 0; min-height: 7.5rem; padding: .38rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.task-calendar-grid-week .task-calendar-day { min-height: 14rem; }
.task-calendar-grid-day .task-calendar-day { min-height: 24rem; }
.task-calendar-day.is-outside-period { background: var(--workspace-bg); color: var(--text-muted); }
.task-calendar-day.is-today h3 { color: var(--accent); }
.task-calendar-day h3 { margin: 0 0 .35rem; font-size: .8rem; font-weight: 500; }
.task-calendar-events { display: grid; align-content: start; gap: .25rem; }
.task-calendar-event { display: grid; min-width: 0; gap: .1rem; padding: .28rem .35rem; border-radius: 5px; font-size: .68rem; line-height: 1.25; text-decoration: none; overflow-wrap: anywhere; }
.task-calendar-event span { font-size: .62rem; }
.task-calendar-event strong { font-weight: 500; }
.task-calendar-event.task-event-task { color: #176fae; background: #e5f3fc; }
.task-calendar-event.task-event-rental { color: #28714b; background: #e5f5ec; }
.task-calendar-event.task-event-maintenance { color: #806313; background: #fff3cd; }
.task-calendar-empty { color: var(--text-muted); font-size: .68rem; }
body.crm-shell[data-theme="dark"] .task-status-new,
body.crm-shell[data-theme="dark"] .task-status-in_progress,
body.crm-shell[data-theme="dark"] .task-priority-normal,
body.crm-shell[data-theme="dark"] .task-event-task,
body.crm-shell[data-theme="dark"] .task-calendar-event.task-event-task { color: #a4d9fa; background: #243d50; }
body.crm-shell[data-theme="dark"] .task-status-completed,
body.crm-shell[data-theme="dark"] .task-event-rental,
body.crm-shell[data-theme="dark"] .task-calendar-event.task-event-rental { color: #9bdbb8; background: #243e33; }
body.crm-shell[data-theme="dark"] .task-status-tomorrow,
body.crm-shell[data-theme="dark"] .task-deadline-tomorrow,
body.crm-shell[data-theme="dark"] .task-priority-high,
body.crm-shell[data-theme="dark"] .task-event-maintenance,
body.crm-shell[data-theme="dark"] .task-calendar-event.task-event-maintenance { color: #f1d981; background: #453c25; }
body.crm-shell[data-theme="dark"] .task-status-today,
body.crm-shell[data-theme="dark"] .task-status-overdue,
body.crm-shell[data-theme="dark"] .task-deadline-today,
body.crm-shell[data-theme="dark"] .task-deadline-overdue,
body.crm-shell[data-theme="dark"] .task-priority-urgent { color: #f1afb4; background: #482a30; }
body.crm-shell[data-theme="dark"] .task-status-canceled,
body.crm-shell[data-theme="dark"] .task-status-deleted,
body.crm-shell[data-theme="dark"] .task-priority-low { color: #bdc8d2; background: #303b46; }
body.crm-shell[data-theme="dark"] .task-detail-grid > div,
body.crm-shell[data-theme="dark"] .task-comment,
body.crm-shell[data-theme="dark"] .task-calendar-day { background: var(--surface); }
body.crm-shell[data-theme="dark"] .task-calendar-day.is-outside-period { background: var(--workspace-bg); }
@media (max-width: 1200px) {
  .task-filter-form .warehouse-search-field { flex-basis: 14rem; }
  .task-filter-form select { flex-basis: 7rem; }
}
@media (max-width: 900px) {
  .task-filter-form .warehouse-search-field { flex-basis: 14rem; }
  .task-filter-form select { flex-basis: 8rem; }
  .task-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-calendar-grid:not(.task-calendar-grid-day) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-calendar-weekdays { display: none; }
  .task-calendar-day { min-height: 6rem; }
}
@media (max-width: 600px) {
  .task-form { grid-template-columns: minmax(0, 1fr); }
  .task-form .task-form-wide, .task-form .modal-actions { grid-column: auto; }
  .task-toolbar { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .task-toolbar > h1, .task-filter-form { grid-column: 1; }
  .task-detail-heading { align-items: stretch; flex-direction: column; }
  .task-filter-form > .task-add-button, .task-detail-heading > .primary-button { width: 100%; }
  .task-detail-actions { flex-direction: column; }
  .task-detail-actions > * { width: 100%; }
  .task-filter-form .warehouse-search-field { width: 100%; min-width: 0; flex-basis: 100%; }
  .task-filter-form select { width: 100%; flex-basis: 100%; }
  .task-filter-form .secondary-button, .task-filter-form .task-add-button { width: 100%; }
  .task-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .task-detail-grid .task-description { grid-column: auto; }
  .task-status-form { align-items: stretch; flex-direction: column; }
  .task-history li { grid-template-columns: 1fr; gap: .25rem; }
  .task-calendar-controls { justify-items: stretch; width: 100%; }
  .task-calendar-nav { justify-content: space-between; }
  .task-calendar-nav form { width: 100%; }
  .task-calendar-nav form input { flex: 1 1 auto; min-width: 0; }
  .task-calendar-grid:not(.task-calendar-grid-day) { grid-template-columns: minmax(0, 1fr); }
  .task-calendar-day { min-height: 4rem; }
  .task-calendar-grid-week .task-calendar-day, .task-calendar-grid-day .task-calendar-day { min-height: 12rem; }
}
@media (max-width: 760px) {
  .task-table-scroll { overflow: visible; }
  .task-table, .task-table tbody { display: block; width: 100%; }
  .task-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .task-table tbody { display: grid; gap: .65rem; }
  .task-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .65rem; padding: .55rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .task-table tbody td { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere; font-size: .8rem; }
  .task-table tbody td::before { color: var(--text-muted); content: attr(data-label); font-size: .7rem; line-height: 1.25; }
  .task-table tbody td.actions-column { align-items: flex-end; justify-self: end; }
  .task-table tbody td.empty-row { display: block; grid-column: 1 / -1; text-align: center; }
  .task-table tbody td.empty-row::before { display: none; }
}
@media (max-width: 430px) {
  .task-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .task-table tbody td.actions-column { grid-column: 1; }
}
/* Investors module */
.investor-filters { display: flex; gap: .5rem; margin: 0 0 1rem; }
.investor-filters a { padding: .4rem .75rem; border: 1px solid #d9e8f3; border-radius: 6px; color: #52687d; text-decoration: none; }
.investor-filters a.is-selected { border-color: #78b9e5; color: #1d78b5; background: #eef8ff; }
.investor-balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: .8rem; margin: 1.25rem 0; }
.investor-balance-grid article { display: grid; gap: .35rem; padding: 1rem; border: 1px solid #e2ebf4; border-radius: 8px; background: #f9fcff; }
.investor-balance-grid span, .investor-number, .investor-audit-list span { color: #687b8d; font-size: .88rem; font-weight: 400; }
.investor-balance-grid strong { color: #267fb8; font-size: 1.18rem; font-weight: 500; }
.investor-modal { width: min(100% - 2rem, 48rem); }
.investor-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.investor-form .investor-wide-field, .investor-form-note { grid-column: 1 / -1; }
.investor-audit-list { margin: 0; padding-left: 1.2rem; line-height: 1.7; }
.investor-audit-list li { margin-bottom: .35rem; }
.investor-audit-list small { display: block; color: #687b8d; }
.investor-archive-badge { display: inline-block; padding: .2rem .5rem; border-radius: 999px; color: #66788a; background: #edf1f4; font-size: .8rem; font-weight: 400; vertical-align: middle; }
.investor-form-note, .investor-capital-note { color: #687b8d; font-size: .88rem; }
.investor-reminders { display: grid; gap: .5rem; margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid #dfe9f2; border-radius: 8px; background: #f8fbfe; }
.investor-reminders h2 { margin: 0; color: #2586c8; font-size: 1rem; font-weight: 500; }
.investor-reminder-group { padding: .6rem .75rem; border-radius: 6px; background: #fff; }
.investor-reminder-group ul { display: grid; gap: .35rem; margin: .35rem 0 0; padding: 0; list-style: none; }
.investor-reminder-group li { display: flex; justify-content: space-between; gap: .75rem; }
.investor-reminder-group li a { color: #267fb8; text-decoration: none; }
.investor-reminder-group li span { color: #687b8d; white-space: nowrap; }
.investor-reminder-group.is-overdue { border-left: 3px solid #d94a58; }
.investor-reminder-group.is-today { border-left: 3px solid #e5a421; }
.investor-reminder-group.is-soon { border-left: 3px solid #48a4d8; }
.investor-status { display: inline-block; padding: .22rem .52rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; }
.investor-status-scheduled { color: #236d9e; background: #e7f4fd; }
.investor-status-today { color: #8a6200; background: #fff2c7; }
.investor-status-overdue { color: #a42f3b; background: #fde8ea; }
.investor-status-partial { color: #8a5700; background: #fff0d5; }
.investor-status-paid { color: #287348; background: #e3f4e9; }
.investor-status-neutral { color: #637386; background: #edf1f4; }
.investor-row-canceled { color: #778696; }
.investor-table, .investor-schedule-table { width: 100%; min-width: 0; table-layout: fixed; }
.investor-schedule-table th:last-child, .investor-schedule-table td:last-child { width: 6rem; text-align: center; }
.investor-schedule-table th, .investor-schedule-table td { padding-inline: .55rem; overflow-wrap: anywhere; }
body.crm-shell[data-theme="dark"] .investor-filters a, body.crm-shell[data-theme="dark"] .investor-balance-grid article { color: var(--text-main); background: var(--surface); border-color: var(--line); }
body.crm-shell[data-theme="dark"] .investor-filters a.is-selected { color: #a9dbfa; background: #243c4e; }
body.crm-shell[data-theme="dark"] .investor-balance-grid span, body.crm-shell[data-theme="dark"] .investor-number, body.crm-shell[data-theme="dark"] .investor-audit-list span { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .investor-reminders, body.crm-shell[data-theme="dark"] .investor-reminder-group { color: var(--text-main); background: var(--surface); border-color: var(--line); }
body.crm-shell[data-theme="dark"] .investor-reminder-group li span, body.crm-shell[data-theme="dark"] .investor-audit-list small, body.crm-shell[data-theme="dark"] .investor-form-note, body.crm-shell[data-theme="dark"] .investor-capital-note { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .investor-status-scheduled { color: #b8e3ff; background: #28465b; }
body.crm-shell[data-theme="dark"] .investor-status-today, body.crm-shell[data-theme="dark"] .investor-status-partial { color: #ffe29a; background: #544523; }
body.crm-shell[data-theme="dark"] .investor-status-overdue { color: #ffc4c9; background: #542d34; }
body.crm-shell[data-theme="dark"] .investor-status-paid { color: #b9ebc9; background: #244632; }
@media (max-width: 700px) {
  .investor-balance-grid { grid-template-columns: 1fr 1fr; }
  .investor-form { grid-template-columns: 1fr; }
  .investor-form .investor-wide-field, .investor-form-note { grid-column: auto; }
  .investor-reminder-group li { align-items: flex-start; flex-direction: column; gap: .15rem; }
  .investor-table, .investor-table tbody, .investor-schedule-table, .investor-schedule-table tbody { display: block; }
  .investor-table thead, .investor-schedule-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .investor-table tbody, .investor-schedule-table tbody { display: grid; gap: .7rem; }
  .investor-table tbody tr, .investor-schedule-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .investor-table td, .investor-schedule-table td { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .42rem .2rem; border: 0; overflow-wrap: anywhere; }
  .investor-table td::before, .investor-schedule-table td::before { content: attr(data-label); color: var(--text-muted); font-size: .72rem; }
  .investor-table td:nth-child(2), .investor-schedule-table td:nth-child(5) { grid-column: 1 / -1; }
  .investor-table td:last-child, .investor-schedule-table td:last-child { align-items: flex-end; }
  .investor-table .empty-row, .investor-schedule-table .empty-row { grid-column: 1 / -1; align-items: center; }
}
@media (max-width: 430px) { .investor-balance-grid { grid-template-columns: 1fr; } }

/* Persistent cross-section notification inbox */
.notification-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .55rem .55rem; border-bottom: 1px solid var(--line); }
.notification-heading > strong { font-size: .88rem; font-weight: 600; }
.notification-heading button, .crm-notification form button { padding: .25rem .45rem; border: 0; border-radius: 5px; color: var(--accent); background: transparent; font: inherit; font-size: .75rem; cursor: pointer; }
.notification-heading button:hover, .crm-notification form button:hover { background: var(--workspace-bg); }
.crm-notification { display: grid; gap: .25rem; margin: .35rem 0; padding: .55rem .65rem; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--surface); }
.crm-notification > a { display: grid; gap: .18rem; color: var(--text-main); text-decoration: none; }
.crm-notification > a > strong { font-size: .82rem; font-weight: 500; }
.crm-notification time, .crm-notification > a > span { color: var(--text-muted); font-size: .74rem; line-height: 1.4; }
.crm-notification form { display: flex; justify-content: flex-end; }
.crm-notification-critical { border-left-color: #d94a58; }
.crm-notification-critical > a > strong { color: #b53b47; }
.crm-notification-warning { border-left-color: #e5a421; }
.crm-notification-warning > a > strong { color: #8a6419; }
.crm-notification-new { border-left-color: #48a4d8; }
.crm-notification-new > a > strong { color: #267fb8; }
.crm-notification-info { border-left-color: #55a876; }
.crm-notification.is-read { opacity: .78; }
.crm-notification.is-read > a > strong { color: var(--text-muted); }
body.crm-shell[data-theme="dark"] .crm-notification-critical > a > strong { color: #f0a4aa; }
body.crm-shell[data-theme="dark"] .crm-notification-warning > a > strong { color: #e8c47a; }
body.crm-shell[data-theme="dark"] .crm-notification-new > a > strong { color: #98d5fb; }
@media (max-width: 600px) { .notification-dropdown { right: -.5rem; } .notification-heading { align-items: flex-start; flex-direction: column; } }

/* Журнал действий и корзина */
.audit-heading { margin-bottom: .75rem; }
.audit-heading .warehouse-search-group { display: block; }
.audit-heading p { margin: .3rem 0 0; color: var(--text-muted); font-size: .84rem; }
.audit-panel { padding: 1rem; }
.audit-filters { display: grid; grid-template-columns: minmax(12rem, 1.5fr) repeat(3, minmax(8rem, 1fr)) repeat(2, minmax(8rem, .8fr)) auto; align-items: end; gap: .55rem; margin-bottom: .8rem; }
.audit-filters > label, .permanent-delete label { display: grid; gap: .25rem; color: var(--text-muted); font-size: .75rem; }
.audit-control { width: 100%; min-width: 0; min-height: 2.5rem; box-sizing: border-box; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text-main); background: var(--surface); font: inherit; font-size: .82rem; }
.audit-table { width: 100%; min-width: 0; table-layout: fixed; font-size: .78rem; }
.audit-table th, .audit-table td { overflow-wrap: anywhere; }
.audit-table th:nth-child(1) { width: 10%; }
.audit-table th:nth-child(2) { width: 14%; }
.audit-table th:nth-child(3), .audit-table th:nth-child(4) { width: 11%; }
.audit-table th:nth-child(5) { width: 22%; }
.audit-table th:nth-child(6) { width: 32%; }
.audit-table td > .muted-text { display: block; margin-top: .2rem; color: var(--text-muted); }
.audit-actions { min-width: 10rem; }
.audit-actions form { margin: 0 0 .35rem; }
.permanent-delete summary { margin: .35rem 0; color: #b53b47; cursor: pointer; }
.permanent-delete form { display: grid; gap: .35rem; margin-top: .35rem; }
.audit-detail { color: var(--text-main); }
.audit-detail dl { display: grid; gap: .55rem; }
.audit-detail dl > div { display: grid; grid-template-columns: minmax(10rem, .4fr) 1fr; gap: .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.audit-detail dt { color: var(--text-muted); }
.audit-detail dd { margin: 0; overflow-wrap: anywhere; }
body.crm-shell[data-theme="dark"] .audit-control { color: var(--text-main); background: #18232e; border-color: var(--line); }
@media (max-width: 900px) { .audit-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-filters > input[type="search"] { grid-column: 1 / -1; }
  .audit-filters > button { grid-column: 1 / -1; justify-self: start; }
  .audit-table, .audit-table tbody { display: block; }
  .audit-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .audit-table tbody { display: grid; gap: .65rem; }
  .audit-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: .15rem .65rem; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; }
  .audit-table tbody td { display: block; min-width: 0; padding: .3rem .15rem; border: 0; }
  .audit-table tbody td::before { display: block; margin-bottom: .1rem; color: var(--text-muted); font-size: .68rem; content: attr(data-label); }
  .audit-table tbody td:nth-child(1), .audit-table tbody td:nth-child(5), .audit-table tbody td:nth-child(6) { grid-column: 1 / -1; }
  .audit-table .empty-state { grid-column: 1 / -1; }
  .audit-detail dl > div { grid-template-columns: 1fr; gap: .15rem; }
}
.rental-document-heading { align-items: flex-start; }
.rental-document-heading .warehouse-search-group { max-width: 100%; }
.rental-document-heading p { margin: .35rem 0 0; color: var(--text-muted, #68798a); font-size: .88rem; }
.rental-document-editor { padding: 1rem; }
.rental-document-note { margin: 0 0 1rem; color: var(--text-muted, #68798a); font-size: .9rem; }
.rental-document-toolbar, .rental-document-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.rental-document-actions { margin: 1rem 0 0; }
.document-paper { min-height: 70vh; max-height: 78vh; overflow: auto; padding: 18mm; border: 1px solid var(--line, #d7e0e8); border-radius: 8px; background: #fff; color: #111; font: 11pt/1.35 Arial, sans-serif; }
.document-paper:focus { outline: 2px solid #74bce9; outline-offset: 1px; }
.document-paper table { width: 100%; border-collapse: collapse; }
.document-paper td, .document-paper th { min-width: 3rem; border: 1px solid #555; padding: 5px; vertical-align: top; }
.document-paper p { line-height: 1.35; }
.rental-document-versions { margin-top: 1rem; }
.rental-document-versions > summary { cursor: pointer; font-weight: 500; }
.rental-document-choices { display: flex; flex-wrap: wrap; gap: .75rem; }
.rental-document-start-form { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin: .8rem 0; }
.rental-document-start-form .form-field { flex: 1 1 18rem; margin: 0; }
.rental-documents-modal .rental-document-start-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); align-items: end; }
.rental-documents-modal .rental-document-start-form .form-field { min-width: 0; }
.rental-documents-modal .rental-document-start-form > .primary-button { width: 100%; min-width: 0; white-space: normal; }
.landlord-form { max-height: min(78vh, 52rem); overflow-y: auto; }
.landlord-form .form-field { min-width: 0; }
.landlords-panel { min-width: 0; max-width: 100%; overflow-x: clip; }
.landlords-panel .warehouse-toolbar, .landlords-table-scroll { min-width: 0; max-width: 100%; }
.landlords-table-scroll { width: 100%; max-width: 100%; overflow-x: hidden; }
.landlords-table { width: 100%; min-width: 0; table-layout: fixed; }
.landlords-table th, .landlords-table td { min-width: 0; overflow-wrap: anywhere; }
.landlords-table th:nth-child(1), .landlords-table td:nth-child(1) { width: 30%; }
.landlords-table th:nth-child(2), .landlords-table td:nth-child(2) { width: 16%; }
.landlords-table th:nth-child(3), .landlords-table td:nth-child(3) { width: 34%; }
.landlords-table th:nth-child(4), .landlords-table td:nth-child(4) { width: 20%; }
.landlords-table-owner th:nth-child(1), .landlords-table-owner td:nth-child(1) { width: 22%; }
.landlords-table-owner th:nth-child(2), .landlords-table-owner td:nth-child(2) { width: 14%; }
.landlords-table-owner th:nth-child(3), .landlords-table-owner td:nth-child(3) { width: 25%; }
.landlords-table-owner th:nth-child(4), .landlords-table-owner td:nth-child(4) { width: 16%; }
.landlords-table-owner th:nth-child(5), .landlords-table-owner td:nth-child(5) { width: 23%; }
@media (max-width: 760px) {
  .landlords-table-scroll { overflow: visible; }
  .landlords-table, .landlords-table tbody { display: block; width: 100%; }
  .landlords-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .landlords-table tbody { display: grid; gap: .65rem; }
  .landlords-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .65rem; padding: .55rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .landlords-table tbody td { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: .15rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere; font-size: .8rem; }
  .landlords-table tbody td::before { color: var(--text-muted); content: attr(data-label); font-size: .7rem; line-height: 1.25; }
  .landlords-table tbody td.actions-column { align-items: flex-end; justify-self: end; }
  .landlords-table tbody td.empty-row { display: block; grid-column: 1 / -1; text-align: center; }
  .landlords-table tbody td.empty-row::before { display: none; }
}
@media (max-width: 430px) {
  .landlords-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .landlords-table tbody td.actions-column { grid-column: 1; }
}
.rental-document-list { display: grid; gap: .6rem; padding-left: 1.2rem; }
.rental-document-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .25rem 1rem; }
.rental-document-list li > a, .rental-document-list li > span { grid-column: 1; min-width: 0; overflow-wrap: anywhere; }
.rental-document-list li > form { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.rental-document-list li > form .danger-button { min-height: 2.4rem; padding: .45rem .8rem; font-size: .9rem; }
.rental-document-list li span { color: var(--text-muted, #68798a); font-size: .85rem; }
body.crm-shell[data-theme="dark"] .document-paper { border-color: #455365; background: #fff; color: #111; }
/* Dark-theme colors for plain links that otherwise use the browser's low-contrast defaults. */
body.crm-shell[data-theme="dark"] a:not([class]):link { color: #9bd7ff; }

/* Mobile layout corrections: keep native controls inside their panels and
   present dense registries as readable cards instead of compressed columns. */
@media (max-width: 600px) {
  .modal-dialog {
    width: calc(100vw - 1.25rem);
    max-width: calc(100vw - 1.25rem);
    max-height: calc(100vh - 1.25rem);
    max-height: calc(100dvh - 1.25rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto;
    padding: 1rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .modal-dialog *, .page-content *, .panel * { min-width: 0; }
  .modal-dialog input:not([type="checkbox"]):not([type="hidden"]),
  .modal-dialog select, .modal-dialog textarea,
  .page-content input[type="date"], .page-content input[type="datetime-local"],
  .page-content input[type="time"], .page-content input[type="month"] {
    width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box;
  }
  .modal-dialog .form-layout, .modal-dialog .form-field,
  .modal-dialog .purchase-header-fields, .modal-dialog .warehouse-form { min-width: 0; }
  .sales-filter-form { grid-template-columns: minmax(0, 1fr); }
  .sales-filter-form .sales-date-filter, .sales-filter-form .secondary-button,
  .sales-filter-form .warehouse-search-field { grid-column: 1; width: 100%; }

  /* Client and bike registries: keep every value visible without sideways scrolling. */
  .clients-table, .clients-table tbody, .bikes-table, .bikes-table tbody { display: block; width: 100%; min-width: 0; }
  .clients-table thead, .bikes-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .clients-table tbody, .bikes-table tbody { display: grid; gap: .65rem; }
  .clients-table tbody tr, .bikes-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .2rem .65rem; padding: .55rem; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface);
  }
  .clients-table tbody td, .bikes-table tbody td {
    display: flex; min-width: 0; flex-direction: column; align-items: flex-start;
    gap: .12rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere;
    font-size: .8rem;
  }
  .clients-table tbody td::before, .bikes-table tbody td::before {
    color: var(--text-muted); font-size: .7rem; line-height: 1.25;
    content: attr(data-mobile-label);
  }
  .clients-table tbody td:nth-child(1)::before { content: "ФИО"; }
  .clients-table tbody td:nth-child(2)::before { content: "Телефон"; }
  .clients-table tbody td:nth-child(3)::before { content: "Дата регистрации"; }
  .clients-table tbody td:nth-child(4)::before { content: "Задолженность"; }
  .clients-table tbody td:nth-child(5)::before { content: "Действующие аренды"; }
  .clients-table tbody td:nth-child(6) { grid-column: 1 / -1; align-items: flex-end; }
  .clients-table tbody td:nth-child(6)::before { content: "Действия"; }
  .bikes-table tbody td:nth-child(1)::before { content: "Внутренний номер"; }
  .bikes-table tbody td:nth-child(2)::before { content: "Модель"; }
  .bikes-table tbody td:nth-child(3)::before { content: "Цвет"; }
  .bikes-table tbody td:nth-child(4)::before { content: "VIN"; }
  .bikes-table tbody td:nth-child(5)::before { content: "Дата покупки"; }
  .bikes-table tbody td:nth-child(6)::before { content: "Статус"; }
  .bikes-table tbody td:nth-child(7)::before { content: "Аккумулятор"; }
  .bikes-table tbody td:nth-child(8)::before { content: "Следующее ТО"; }
  .bikes-table tbody td:nth-child(9) { grid-column: 1 / -1; align-items: flex-end; }
  .bikes-table tbody td:nth-child(9)::before { content: "Действия"; }
  .clients-table tbody td.empty-row, .bikes-table tbody td.empty-row {
    display: block; grid-column: 1 / -1; text-align: center;
  }
  .clients-table tbody td.empty-row::before, .bikes-table tbody td.empty-row::before { display: none; }

  /* Finance tables need breathing room: stack their cells rather than wrap each word. */
  .finance-panel .table-scroll { overflow: visible; }
  .finance-panel .warehouse-table, .finance-panel .warehouse-table tbody { display: block; width: 100%; }
  .finance-panel .warehouse-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .finance-panel .warehouse-table tbody { display: grid; gap: .65rem; }
  .finance-panel .warehouse-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .15rem .65rem; padding: .55rem; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface);
  }
  .finance-panel .warehouse-table tbody td {
    display: flex; min-width: 0; flex-direction: column; align-items: flex-start;
    gap: .12rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere;
    font-size: .8rem;
  }
  .finance-panel .warehouse-table tbody td::before {
    color: var(--text-muted); font-size: .7rem; line-height: 1.25;
  }
  .finance-accounts-table tbody td:nth-child(1)::before { content: "Счёт"; }
  .finance-accounts-table tbody td:nth-child(2)::before { content: "Тип"; }
  .finance-accounts-table tbody td:nth-child(3)::before { content: "Статус"; }
  .finance-accounts-table tbody td:nth-child(4)::before { content: "Остаток"; }
  .finance-account-list-table tbody td:nth-child(1)::before { content: "Название"; }
  .finance-account-list-table tbody td:nth-child(2)::before { content: "Тип"; }
  .finance-account-list-table tbody td:nth-child(3)::before { content: "Начальный остаток"; }
  .finance-account-list-table tbody td:nth-child(4)::before { content: "Текущий остаток"; }
  .finance-account-list-table tbody td:nth-child(5)::before { content: "Статус"; }
  .finance-account-list-table tbody td:nth-child(6) { grid-column: 1 / -1; align-items: flex-end; }
  .finance-account-list-table tbody td:nth-child(6)::before { content: "Действия"; }
  .finance-operations-table tbody td:nth-child(1)::before { content: "Номер и дата"; }
  .finance-operations-table tbody td:nth-child(2)::before { content: "Операция"; }
  .finance-operations-table tbody td:nth-child(3)::before { content: "Счёт"; }
  .finance-operations-table tbody td:nth-child(4)::before { content: "Категория"; }
  .finance-operations-table tbody td:nth-child(5)::before { content: "Основание"; }
  .finance-operations-table tbody td:nth-child(6)::before { content: "Сумма"; }
  .finance-operations-table tbody td:nth-child(7)::before { content: "Статус"; }
  .finance-operations-table tbody td:nth-child(8) { grid-column: 1 / -1; align-items: flex-end; }
  .finance-operations-table tbody td:nth-child(8)::before { content: "Действия"; }
  .finance-panel .warehouse-table tbody td.empty-state { display: block; grid-column: 1 / -1; text-align: center; }
  .finance-panel .warehouse-table tbody td.empty-state::before { display: none; }
  .landlords-table tbody td.empty-row { width: 100%; box-sizing: border-box; overflow-wrap: normal; }
}

@media (max-width: 380px) {
  .clients-table tbody tr, .bikes-table tbody tr,
  .finance-panel .warehouse-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .clients-table tbody td:nth-child(6), .bikes-table tbody td:nth-child(9) { grid-column: 1; }
  .finance-panel .warehouse-table tbody td.empty-state { grid-column: 1; }
}
body.crm-shell[data-theme="dark"] a:not([class]):visited { color: #9bd7ff; }
body.crm-shell[data-theme="dark"] .page-heading a.button-secondary:link,
body.crm-shell[data-theme="dark"] .page-heading a.button-secondary:visited { color: #9bd7ff; }

@media (max-width: 760px) {
  .rental-document-editor { padding: .7rem; }
  .document-paper { min-height: 65vh; max-height: none; padding: 1rem; font-size: 10pt; }
  .rental-document-choices > form, .rental-document-choices .primary-button { width: 100%; }
  .rental-documents-modal .rental-document-start-form { grid-template-columns: minmax(0, 1fr); }
  .rental-document-list li { grid-template-columns: minmax(0, 1fr); }
  .rental-document-list li > form { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* One-time post-login welcome; it never intercepts dashboard interaction. */
.login-welcome { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; pointer-events: none; background: color-mix(in srgb, var(--workspace-bg) 90%, transparent); animation: login-welcome-away 1.35s ease both; }
.login-welcome-content { display: grid; justify-items: center; gap: 1rem; color: var(--text-main); font-size: clamp(1.15rem, 2vw, 1.65rem); font-weight: 600; text-align: center; }
.login-welcome-mark { display: grid; width: clamp(3.6rem, 7vw, 5.2rem); aspect-ratio: 1; place-items: center; color: var(--accent); animation: login-welcome-mark 1.35s ease both; }
.login-welcome-mark svg { display: block; width: 78%; height: 78%; fill: currentColor; }
.login-welcome-text { opacity: 0; animation: login-welcome-text 1.35s ease both; }
@keyframes login-welcome-mark { 0% { opacity: 0; transform: scale(.92); filter: drop-shadow(0 0 0 transparent); } 22% { opacity: 1; transform: scale(1.04); filter: drop-shadow(0 0 12px color-mix(in srgb, var(--accent) 35%, transparent)); } 68% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); filter: none; } }
@keyframes login-welcome-text { 0%, 22% { opacity: 0; transform: translateY(.3rem); } 38%, 68% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; } }
@keyframes login-welcome-away { 0%, 72% { opacity: 1; } 100% { opacity: 0; } }
.profile-checkbox-field { display: flex; align-items: center; gap: .65rem; }
.profile-checkbox-field label { order: 2; }
.profile-checkbox-field input[type="checkbox"] { order: 1; width: 1.1rem; height: 1.1rem; min-height: 1.1rem; }
@media (prefers-reduced-motion: reduce) {
  .login-welcome, .login-welcome-mark, .login-welcome-text { animation-duration: .45s; }
  .login-welcome-mark { animation-name: login-welcome-mark-reduced; }
  @keyframes login-welcome-mark-reduced { 0%, 20% { opacity: 0; } 100% { opacity: 1; } }
  .login-welcome-text { animation-name: login-welcome-text-reduced; }
  @keyframes login-welcome-text-reduced { 0%, 20% { opacity: 0; } 100% { opacity: 1; } }
  .login-welcome { animation-name: login-welcome-away-reduced; }
  @keyframes login-welcome-away-reduced { 0%, 65% { opacity: 1; } 100% { opacity: 0; } }
}

.login-welcome { animation-duration: 2.05s; }
.login-welcome-mark { animation-duration: 2.05s; }
.login-welcome-text { animation-duration: 2.05s; }
@media (prefers-reduced-motion: reduce) {
  .login-welcome, .login-welcome-mark, .login-welcome-text { animation-duration: .55s; }
}
.login-welcome-mark { position: relative; isolation: isolate; }
.login-welcome-mark::before { position: absolute; z-index: -1; inset: 5%; border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent); border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 20%, transparent), transparent 68%); content: ""; animation: login-welcome-aura 2.05s ease-out both; }
@keyframes login-welcome-aura { 0% { opacity: 0; transform: scale(.58); } 24% { opacity: .85; } 72% { opacity: .38; transform: scale(1.45); } 100% { opacity: 0; transform: scale(1.72); } }
@media (prefers-reduced-motion: reduce) {
  .login-welcome-mark::before { animation: none; opacity: .22; }
}

.backups-panel { min-width: 0; }
.backups-panel .page-heading { align-items: flex-start; }
.backups-panel .page-heading h1 { margin-top: 0; }
.backups-panel .page-heading p { margin: .3rem 0 0; }
.backups-table td { vertical-align: middle; }
.backup-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.backup-actions > details > summary { cursor: pointer; color: var(--text-muted); }
.backup-delete-form { display: grid; gap: .5rem; min-width: min(18rem, 80vw); margin-top: .5rem; }
.backup-delete-form label { display: flex; align-items: center; gap: .45rem; font-size: .84rem; }
.backup-restore-note { margin-top: 1.2rem; padding: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--workspace-bg); }
.backup-restore-note h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.backup-restore-note p { margin: .35rem 0; }

@media (max-width: 600px) {
  .dashboard-heading { justify-content: flex-start; }
  .sales-table, .sales-table tbody { display: block; width: 100%; min-width: 0; }
  .sales-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .sales-table tbody { display: grid; gap: .65rem; }
  .sales-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .15rem .65rem; padding: .55rem; border: 1px solid var(--line);
    border-radius: 8px; background: var(--surface);
  }
  .sales-table tbody td {
    display: flex; min-width: 0; flex-direction: column; align-items: flex-start;
    gap: .12rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere;
    font-size: .8rem;
  }
  .sales-table tbody td::before { color: var(--text-muted); font-size: .7rem; line-height: 1.25; }
  .sales-table tbody td:nth-child(1)::before { content: "Номер"; }
  .sales-table tbody td:nth-child(2)::before { content: "Дата"; }
  .sales-table tbody td:nth-child(3)::before { content: "Товары"; }
  .sales-table tbody td:nth-child(4)::before { content: "Сумма"; }
  .sales-table tbody td:nth-child(5)::before { content: "Себестоимость"; }
  .sales-table tbody td:nth-child(6)::before { content: "Прибыль"; }
  .sales-table tbody td:nth-child(7)::before { content: "Оплата"; }
  .sales-table tbody td:nth-child(8)::before { content: "Оформил"; }
  .sales-table tbody td:nth-child(9) { grid-column: 1 / -1; align-items: flex-end; }
  .sales-table tbody td:nth-child(9)::before { content: "Действия"; }
  .sales-table tbody td.empty-row { display: block; grid-column: 1 / -1; text-align: center; }
  .sales-table tbody td.empty-row::before { display: none; }
}
@media (max-width: 380px) {
  .sales-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  .sales-table tbody td:nth-child(9) { grid-column: 1; }
}

/* One mobile treatment for the remaining wide registry and history tables. */
@media (max-width: 760px) {
  html, body.crm-shell { max-width: 100%; overflow-x: clip; }
  .app-main, .page-content, .panel { min-width: 0; max-width: 100%; }
  .mobile-record-table-scroll { width: 100%; max-width: 100%; overflow: visible !important; }
  table.mobile-record-table, table.mobile-record-table tbody {
    display: block; width: 100%; min-width: 0; table-layout: auto;
  }
  table.mobile-record-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  table.mobile-record-table tbody { display: grid; gap: .65rem; }
  table.mobile-record-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .15rem .65rem; min-width: 0; padding: .55rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  }
  table.mobile-record-table tbody td {
    display: flex; min-width: 0; flex-direction: column; align-items: flex-start;
    gap: .12rem; padding: .35rem .25rem; border: 0; overflow-wrap: anywhere;
    font-size: .8rem;
  }
  table.mobile-record-table tbody td::before {
    color: var(--text-muted); content: attr(data-mobile-label);
    font-size: .7rem; line-height: 1.25;
  }
  table.mobile-record-table tbody td.actions-column { grid-column: 1 / -1; align-items: flex-end; }
  table.mobile-record-table tbody td.mobile-record-empty {
    display: block; grid-column: 1 / -1; text-align: center;
  }
  table.mobile-record-table tbody td.mobile-record-empty::before { display: none; }

  .modal-dialog {
    box-sizing: border-box; width: calc(100vw - 1rem); max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto; padding: 1rem; overflow: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .modal-dialog form, .modal-dialog .form-field, .modal-dialog .form-layout,
  .modal-dialog .purchase-header-fields, .modal-dialog .warehouse-form,
  .modal-dialog .form-grid { min-width: 0; max-width: 100%; }
  .modal-dialog input:not([type="checkbox"]):not([type="hidden"]),
  .modal-dialog select, .modal-dialog textarea,
  .page-content input[type="date"], .page-content input[type="datetime-local"],
  .page-content input[type="time"], .page-content input[type="month"] {
    box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%;
  }
}
@media (max-width: 380px) {
  table.mobile-record-table tbody tr { grid-template-columns: minmax(0, 1fr); }
  table.mobile-record-table tbody td.actions-column,
  table.mobile-record-table tbody td.mobile-record-empty { grid-column: 1; }
}

/* Keep the audit and trash search controls in a clear, single-column flow on phones. */
@media (max-width: 600px) {
  .audit-panel { min-width: 0; padding: .75rem; }
  .audit-filters {
    width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr);
    align-items: stretch; gap: .65rem;
  }
  .audit-filters > *, .audit-filters > label,
  .audit-filters > input[type="search"], .audit-filters > button {
    grid-column: 1; width: 100%; min-width: 0; max-width: 100%; justify-self: stretch;
  }
  .audit-filters > label { box-sizing: border-box; }
  .audit-filters .audit-control,
  .permanent-delete .audit-control { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; }
}

/* Safari gives native date/time controls a larger intrinsic minimum width.
   Constrain both the field wrappers and controls to the dialog's content box. */
@media (max-width: 760px) {
  dialog.modal-dialog { overflow-x: hidden; }
  dialog.modal-dialog form,
  dialog.modal-dialog form > p,
  dialog.modal-dialog .form-field,
  dialog.modal-dialog .rental-form,
  dialog.modal-dialog .repair-form,
  dialog.modal-dialog .maintenance-form,
  dialog.modal-dialog .purchase-form,
  dialog.modal-dialog .bike-form,
  dialog.modal-dialog .task-form,
  dialog.modal-dialog .investor-form {
    box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%;
  }
  dialog.modal-dialog input[type="date"],
  dialog.modal-dialog input[type="datetime-local"],
  dialog.modal-dialog input[type="time"],
  dialog.modal-dialog input[type="month"],
  .page-content input[type="date"],
  .page-content input[type="datetime-local"],
  .page-content input[type="time"],
  .page-content input[type="month"] {
    display: block; box-sizing: border-box; width: 100% !important;
    min-width: 0 !important; max-width: 100% !important;
    inline-size: 100% !important; min-inline-size: 0 !important; max-inline-size: 100% !important;
    /* iOS Safari adds native date-control padding to the declared 100% width. */
    padding-inline: 0 !important;
  }

  .warehouse-table.rentals-table tbody td:nth-child(8),
  .bikes-table tbody td:nth-child(9),
  .clients-table tbody td:nth-child(6),
  table.mobile-record-table tbody td.actions-column {
    display: flex; flex-direction: row; grid-column: 1 / -1;
    align-items: center; justify-content: space-between; gap: .75rem;
    width: 100%; min-width: 0;
  }
  .warehouse-table.rentals-table tbody td:nth-child(8) .row-actions,
  .bikes-table tbody td:nth-child(9) .row-actions,
  .clients-table tbody td:nth-child(6) .row-actions,
  table.mobile-record-table tbody td.actions-column .row-actions { margin-left: auto; flex: 0 0 auto; }
}
