/*
 * foreman.css — Phase 2 + Phase 3 + Phase 4 + Phase 5 Foreman Dashboard
 *
 * Re-uses existing ms-* classes from my_surveys.css for layout, cards, modal
 * and action buttons.  Only new fm-* components are defined here.
 */

/* ── Root ────────────────────────────────────────────────────────────────── */

/*
 * Foreman full-height layout (class toggled in router.js on tab change).
 * No padding on content-area — segment bar flush under tabs-bar.
 * Scroll on page (body); horizontal scroll inside .fm-table-wrap.
 */
.content-area.content-area--foreman,
.content-area:has(#foreman-view.active) {
  position: relative;
  padding: 0 !important;
  overflow: visible !important;
  min-height: 0;
  display: block !important;
}

.content-area.content-area--foreman #foreman-view.active,
.content-area:has(#foreman-view.active) #foreman-view.active,
.content-area.content-area--foreman #warehouse-view.active,
.content-area.content-area--foreman #logistics-view.active {
  position: relative;
  display: flex !important;
  flex-direction: column;
  overflow: visible;
  min-height: auto;
  flex: none;
}

/* Override my_surveys.css .ms-root { height:100% } — causes top gap / double scroll */
.content-area.content-area--foreman .fm-root.ms-root,
.content-area:has(#foreman-view.active) .fm-root.ms-root,
.content-area.content-area--foreman .fm-root,
.content-area.content-area--foreman .lg-root {
  flex: none;
  min-height: auto;
  height: auto !important;
  max-height: none;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.fm-root {
  flex: none;
  min-height: auto;
  height: auto !important;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Segment bar: not sticky — stays at top of foreman panel (no row bleed-through) */
.content-area.content-area--foreman .fm-root > .ms-filterbar,
.fm-root > .ms-filterbar {
  position: relative !important;
  top: auto !important;
  flex-shrink: 0;
  z-index: 10;
  margin: 0;
  background: var(--card-bg, var(--surface, #fff));
}

/* ── Card extras ─────────────────────────────────────────────────────────── */
.fm-card {
  cursor: pointer;
}

.fm-card-preldate {
  font-size: 13px;
  color: var(--muted, #888);
}

.fm-card-company {
  display: block;
  font-size: 13px;
  color: var(--muted, #888);
  margin-top: 2px;
}

.fm-card-address {
  font-size: 13px;
  color: var(--muted, #888);
}

.fm-card-assign {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary, #555);
}

.fm-card-label {
  font-weight: 600;
}

.fm-unassigned {
  color: var(--danger, #e53935);
  font-style: italic;
}

/* ── AMO link ─────────────────────────────────────────────────────────────── */
.fm-amo-link {
  color: var(--accent, #1976d2);
  text-decoration: none;
  font-weight: 600;
}
.fm-amo-link:hover {
  text-decoration: underline;
}

/* ── Filters row (search only for «Новые») ───────────────────────────────── */
.fm-filters {
  margin-top: 8px;
}

/* ── Detail: document buttons ────────────────────────────────────────────── */
.fm-doc-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fm-btn-photos,
.fm-btn-estimate {
  flex: 1 1 140px;
  min-height: 44px;
  font-size: 14px;
}

/* ── Detail: assign-installer row ────────────────────────────────────────── */
.fm-assign-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.fm-installer-picker {
  flex: 1 1 200px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  font-size: 15px;
  background: var(--input-bg, #fff);
  color: var(--text, #222);
  cursor: pointer;
}

.fm-installer-picker:focus {
  outline: none;
  border-color: var(--accent, #1976d2);
  box-shadow: 0 0 0 2px rgba(25,118,210,.15);
}

.fm-btn-assign {
  min-height: 44px;
  min-width: 110px;
  white-space: nowrap;
}

/* ── Detail: date row ────────────────────────────────────────────────────── */
.fm-date-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.fm-date-input {
  flex: 1 1 160px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  font-size: 15px;
  background: var(--input-bg, #fff);
  color: var(--text, #222);
}

.fm-date-input:focus {
  outline: none;
  border-color: var(--accent, #1976d2);
  box-shadow: 0 0 0 2px rgba(25,118,210,.15);
}

.fm-btn-date {
  min-height: 44px;
  min-width: 110px;
  white-space: nowrap;
}

/* ── Detail: confirm-montage row ─────────────────────────────────────────── */
.fm-confirm-row {
  padding: 12px 16px;
  background: var(--card-bg, #f9f9f9);
  border-radius: 10px;
  border: 1px solid var(--border, #e0e0e0);
}

.fm-confirm-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.fm-confirm-checkbox {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--accent, #1976d2);
  flex-shrink: 0;
}

.fm-confirm-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.fm-confirm-label:has(.fm-confirm-checkbox:disabled) {
  color: var(--muted, #888);
}

/* ── Placeholder (В работе / Выполнено) ──────────────────────────────────── */
.fm-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--muted, #888);
  gap: 12px;
}

.fm-placeholder .ms-empty-icon {
  font-size: 40px;
}

.fm-placeholder p {
  font-size: 15px;
  margin: 0;
}

/* ── Dark mode ───────────────────────────────────────────────────────────── */
[data-theme="dark"] .fm-installer-picker,
[data-theme="dark"] .fm-date-input {
  background: var(--input-bg, #2a2a2a);
  color: var(--text, #f0f0f0);
  border-color: var(--border, #444);
}

[data-theme="dark"] .fm-confirm-row {
  background: var(--card-bg, #1e1e1e);
  border-color: var(--border, #444);
}

[data-theme="dark"] .fm-unassigned {
  color: #ef9a9a;
}

/* ── Phase 3: Table (В работе / Выполнено) ───────────────────────────────── */

/* .ms-list — no scroll container; page (body) scrolls vertically */
.fm-root > .ms-list {
  flex: none;
  min-height: 0;
  overflow: visible;
  padding: 0 20px 16px;
}

.fm-root > .ms-list > .fm-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}

/* Native horizontal scrollbar hidden — use .fm-hscroll-sync under fixed header */
.fm-table-wrap,
.lg-table-wrap,
.fm-cal-wrap {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.fm-table-wrap::-webkit-scrollbar,
.lg-table-wrap::-webkit-scrollbar,
.fm-cal-wrap::-webkit-scrollbar {
  display: none;
  height: 0;
}

/* Sync scrollbar — lives in fixed .fm-page-footer at viewport bottom */
.fm-hscroll-sync {
  position: relative;
  left: 0;
  width: 100%;
  height: 17px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 1;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border, #e0e0e0);
}
[data-theme="dark"] .fm-hscroll-sync {
  background: var(--surface, #1e1e1e);
}

/* Fixed viewport footer: horizontal scroll + action buttons */
.fm-page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 98;
  background: var(--surface, #fff);
  border-top: 1px solid var(--border, #e0e0e0);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .06);
  display: none;
}
[data-theme="dark"] .fm-page-footer {
  background: var(--surface, #1e1e1e);
}

.fm-hscroll-track {
  min-height: 0;
  overflow: hidden;
}

.fm-hscroll-track:empty {
  display: none;
}

.fm-page-footer-actions {
  padding: 8px 20px;
}

.fm-page-footer-actions:empty {
  display: none;
}

/* Reserve space so last table row is not covered by fixed .fm-page-footer.
   Applies to all workdesk roots that use StickyThead (foreman, warehouse, logistics). */
.fm-root,
.ms-root.fm-root,
.lg-root {
  --fm-footer-h: 0px;
  --fm-footer-gap: 56px; /* ~one table row above fixed footer + h-scroll bar */
  padding-bottom: calc(var(--fm-footer-h) + var(--fm-footer-gap));
}

.lg-root > .lg-body {
  padding-bottom: 16px;
}

/* Extends document scroll height so fixed footer does not cover last rows. */
.fm-scroll-pad {
  flex: none;
  width: 100%;
  height: 0;
  pointer-events: none;
}

/* Pinned clone of thead (built via StickyThead.mount).
   Sticky to the visible area horizontally so its rounded edges stay pinned to
   the viewport while the inner table slides underneath on horizontal scroll —
   this way headers of off-screen columns emerge from under the fixed edge
   instead of staying hidden behind the moving rounded mask. */
.fm-thead-pin {
  position: sticky;
  left: 0;
  width: 100%;
  max-width: 100%;
  z-index: 25;
  overflow: hidden;
  background: var(--card-bg, #f5f5f5);
  border-bottom: 2px solid var(--border, #e0e0e0);
  border-radius: 10px 10px 0 0;
}

.fm-thead-pin.fm-thead-fixed {
  position: fixed;
  top: 0;
  z-index: 100;
  border-radius: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
}

/* Calendar pin uses the same sticky behaviour as the base rule (kept for clarity). */
.fm-thead-pin--cal {
  position: sticky;
  left: 0;
  width: 100%;
  max-width: 100%;
}

.fm-thead-spacer {
  display: none;
}

.fm-thead-pin-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  margin: 0;
}

/* Frozen header cells in pin (match body columns) — work table only; calendar overrides below */
.fm-thead-pin-table:not(.fm-cal-table) th:nth-child(1) { position: sticky; left: 0;   z-index: 27; }
.fm-thead-pin-table:not(.fm-cal-table) th:nth-child(2) { position: sticky; left: 130px; z-index: 27; }
.fm-thead-pin-table:not(.fm-cal-table) th:nth-child(3) { position: sticky; left: 270px; z-index: 27; box-shadow: 2px 0 4px rgba(0,0,0,.08); }

.fm-thead-pin-table th {
  padding: 9px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted, #666);
  white-space: nowrap;
  background: var(--card-bg, #f5f5f5);
  border-bottom: none;
  box-shadow: none;
}

/* Original thead hidden; column widths come from tbody */
.fm-table thead.fm-thead-offscreen {
  visibility: collapse;
}

/* Calendar / other content inside ms-list without table-wrap */
.fm-root > .ms-list > .fm-cal-wrap {
  overflow-x: auto;
}

.fm-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: auto;
}

.fm-table th {
  padding: 9px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted, #666);
  white-space: nowrap;
  border-bottom: 2px solid var(--border, #e0e0e0);
  background: var(--card-bg, #f5f5f5);
}

/* ── Frozen columns 1–3 (Date, Installer, Client) — sticky left ── */
/* Approximate widths: col1 (date) ≈ 130px, col2 (installer) ≈ 140px */
.fm-table th:nth-child(1),
.fm-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface, #fff);
}
.fm-table th:nth-child(2),
.fm-table td:nth-child(2) {
  position: sticky;
  left: 130px;
  z-index: 2;
  background: var(--surface, #fff);
}
.fm-table th:nth-child(3),
.fm-table td:nth-child(3) {
  position: sticky;
  left: 270px;
  z-index: 2;
  background: var(--surface, #fff);
}
/* Corner header cells: sticky both top AND left — highest z-index */
.fm-table thead th:nth-child(1),
.fm-table thead th:nth-child(2),
.fm-table thead th:nth-child(3) {
  z-index: 6;
}
/* Shadow on right edge of 3rd frozen column */
.fm-table td:nth-child(3),
.fm-table th:nth-child(3) {
  box-shadow: 2px 0 4px rgba(0, 0, 0, .08);
}

.fm-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: middle;
  background: var(--surface, #fff);
}

/* Hover: opaque highlight + soft lift shadow. The background MUST stay opaque,
   otherwise the frozen (sticky) left columns become see-through and scrolled
   content bleeds through them during horizontal scroll. */
.fm-table tbody tr:hover td {
  background: var(--row-hover, #eef2f6);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, .05), inset 0 -1px 0 rgba(0, 0, 0, .05);
}
.fm-table tbody tr:hover td:nth-child(3) {
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, .05), inset 0 -1px 0 rgba(0, 0, 0, .05), 2px 0 4px rgba(0, 0, 0, .08);
}
[data-theme="dark"] .fm-table tbody tr:hover td {
  background: #2a2825;
}

/* AMO deal row — click opens detail modal (inputs/links keep their own handlers) */
.fm-table tbody tr.fm-row-deal {
  cursor: pointer;
}

/* Narrow «icon» columns */
.fm-th-docs,
.fm-th-done {
  width: 48px;
  text-align: center;
}

.fm-cell-docs,
.fm-cell-complete {
  text-align: center;
}

/* Tomorrow montage with assembly ready — neutral highlight */
.fm-row-tomorrow td {
  background: rgba(1, 105, 111, 0.06);
}
.fm-table tbody tr.fm-row-tomorrow:hover td {
  background: rgba(1, 105, 111, 0.11);
}
[data-theme="dark"] .fm-row-tomorrow td {
  background: rgba(77, 182, 188, 0.10);
}
[data-theme="dark"] .fm-table tbody tr.fm-row-tomorrow:hover td {
  background: rgba(77, 182, 188, 0.16);
}

/* Tomorrow montage without assembly — alert row */
.fm-row-assembly-alert td {
  background: rgba(229, 57, 53, 0.07);
}
.fm-table tbody tr.fm-row-assembly-alert:hover td {
  background: #f7dddb;
}
[data-theme="dark"] .fm-row-assembly-alert td {
  background: rgba(239, 83, 80, 0.12);
}
[data-theme="dark"] .fm-table tbody tr.fm-row-assembly-alert:hover td {
  background: #3a2826;
}

.fm-cell-assembly-alert {
  background: rgba(229, 57, 53, 0.22) !important;
}
.fm-cell-assembly-alert .fm-inline-check--readonly {
  outline: 2px solid #c62828;
  outline-offset: 1px;
}
[data-theme="dark"] .fm-cell-assembly-alert {
  background: rgba(239, 83, 80, 0.28) !important;
}

.fm-inline-check--readonly {
  cursor: not-allowed;
  opacity: 0.95;
}

/* Legacy alias kept for safety */
.fm-row-docs-alert td {
  background: rgba(229, 57, 53, 0.07);
}

/* Terminal payment highlight */
.fm-row-terminal td {
  background: #fff3cd;
}
.fm-table tbody tr.fm-row-terminal:hover td {
  background: #ffe69c;
}
[data-theme="dark"] .fm-row-terminal td {
  background: rgba(255, 193, 7, 0.18);
}
[data-theme="dark"] .fm-table tbody tr.fm-row-terminal:hover td {
  background: rgba(255, 193, 7, 0.28);
}

/* Inline inputs */
.fm-inline-date,
.fm-inline-text,
.fm-inline-num,
.fm-inline-select {
  width: 100%;
  min-height: 34px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text, #222);
  transition: border-color .15s, background .15s;
}

.fm-inline-date,
.fm-inline-text,
.fm-inline-num {
  max-width: 160px;
}

.fm-inline-date:focus,
.fm-inline-text:focus,
.fm-inline-num:focus,
.fm-inline-select:focus {
  outline: none;
  border-color: var(--accent, #1976d2);
  background: var(--input-bg, #fff);
  box-shadow: 0 0 0 2px rgba(25,118,210,.12);
}

.fm-inline-date:hover,
.fm-inline-text:hover,
.fm-inline-num:hover,
.fm-inline-select:hover {
  border-color: var(--border, #bbb);
  background: transparent;
}

.fm-inline-num { max-width: 60px; }
.fm-inline-check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent, #1976d2); }
.fm-inline-complete { width: 20px; height: 20px; cursor: pointer; accent-color: var(--danger, #e53935); }

/* Filled vs empty distinction.
   Cells that actually contain entered data get a soft green highlight so they
   stand out; empty selects/dates keep their placeholder text muted so they
   visually recede. Applies to foreman, warehouse and logistics (shared classes). */
.fm-inline-text.fm-filled,
.fm-inline-num.fm-filled,
.fm-inline-date.fm-filled,
.fm-inline-select.fm-filled {
  background: rgba(76, 175, 80, 0.16);
  border-color: rgba(76, 175, 80, 0.40);
  color: var(--text, #1b1b1b);
  font-weight: 500;
}

#fm-work-table .fm-inline-select:not(.fm-filled):not(:focus),
#fm-work-table .fm-inline-date:not(.fm-filled):not(:focus) {
  color: var(--muted, #9aa0a6);
}

/* Saving state */
.fm-saving {
  opacity: .55;
  pointer-events: none;
}

/* Cell width hints */
.fm-cell-client  { min-width: 140px; }
/* Address: ~⅓ of former width, ellipsis + native tooltip via title */
.fm-cell-addr {
  min-width: 54px;
  max-width: 54px;
  width: 54px;
}
.fm-addr-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
/* min-width overridden in Phase 6 block below */
.fm-cell-note,
.fm-cell-delcomment { min-width: 130px; }
/* Explicit widths for frozen cols — these drive the sticky left offsets */
.fm-cell-date      { min-width: 130px; max-width: 130px; }
.fm-cell-installer { min-width: 140px; max-width: 160px; }
/* Narrow phone — no need for much space */
.fm-cell-phone     { min-width: 110px; max-width: 120px; white-space: nowrap; }

.fm-cell-company {
  font-size: 11px;
  color: var(--muted, #888);
}

/* «Выполнено» table tweaks */
.fm-table-done th,
.fm-table-done td {
  white-space: nowrap;
}

/* Load-more footer */
.fm-done-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted, #888);
  flex-wrap: wrap;
  gap: 8px;
}

.fm-load-more-btn {
  min-width: 130px;
}

.fm-done-count {
  white-space: nowrap;
}

/* ── Mobile (≤480px) ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .fm-assign-row,
  .fm-date-row {
    flex-direction: column;
    align-items: stretch;
  }

  .fm-btn-assign,
  .fm-btn-date {
    min-width: 0;
    width: 100%;
  }

  .fm-installer-picker,
  .fm-date-input {
    width: 100%;
  }

  .fm-doc-buttons {
    flex-direction: column;
  }

  .fm-btn-photos,
  .fm-btn-estimate {
    min-width: 0;
    width: 100%;
  }

  /* Narrower frozen columns on mobile */
  .fm-cell-date      { min-width: 90px;  max-width: 90px; }
  .fm-cell-installer { min-width: 100px; max-width: 120px; }
  .fm-cell-client    { min-width: 110px; }
  .fm-table th,
  .fm-table td       { font-size: 12px; padding: 6px 6px; }
  /* Adjust sticky left offsets for narrower mobile columns */
  .fm-table th:nth-child(2), .fm-table td:nth-child(2) { left: 90px; }
  .fm-table th:nth-child(3), .fm-table td:nth-child(3) { left: 190px; }
}

/* ── Phase 4: Manual rows + add-row UI ───────────────────────────────────── */

/* Light tint for manual / day-off rows */
.fm-row-manual td {
  background: var(--manual-row-bg, rgba(100, 149, 237, 0.06));
}
.fm-table tbody tr.fm-row-manual:hover td {
  background: #e6edfb;
}
[data-theme="dark"] .fm-row-manual td {
  background: rgba(100, 149, 237, 0.09);
}
[data-theme="dark"] .fm-table tbody tr.fm-row-manual:hover td {
  background: #262d3a;
}

/* Day-off label in Client cell */
.fm-dayoff-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted, #888);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* New unsaved row highlight */
.fm-row-new {
  outline: 2px dashed var(--accent, #1976d2);
  outline-offset: -2px;
}

/* Empty table row message */
.fm-empty-row {
  text-align: center;
  color: var(--muted, #aaa);
  padding: 24px 0;
}

/* Wider inline inputs for client/station — all row types */
.fm-inline-client,
.fm-inline-station {
  min-width: 110px;
  max-width: 200px;
}

/* Compact selects for gorlovina and filtration_kind */
.fm-inline-gor {
  min-width: 52px;
  max-width: 70px;
  font-size: 13px;
}
.fm-inline-fk {
  min-width: 52px;
  max-width: 70px;
  font-size: 13px;
}
.fm-cell-station { min-width: 130px; }
.fm-cell-qty     { min-width: 52px; max-width: 52px; width: 52px; }
.fm-cell-neck    { min-width: 52px; }
.fm-cell-fk      { min-width: 52px; max-width: 52px; width: 52px; }

/* Add-row buttons bar */
.fm-add-row-bar {
  display: flex;
  gap: 6px;
  padding: 0;
}

.fm-add-row-btn {
  font-size: 12px;
  padding: 4px 12px;
  min-height: unset;
  background: var(--card-bg, #f5f5f5);
  border: 1px dashed var(--accent, #1976d2);
  color: var(--accent, #1976d2);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.fm-add-row-btn:hover {
  background: var(--accent-light, rgba(25,118,210,.08));
}

/* Delete (×) button inside manual row */
.fm-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--danger, #e53935);
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  vertical-align: middle;
  opacity: .7;
  transition: opacity .15s, background .15s;
}
.fm-delete-btn:hover {
  opacity: 1;
  background: rgba(229, 57, 53, .1);
}

/* Cancel new-row button */
.fm-cancel-new-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--muted, #aaa);
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  vertical-align: middle;
}
.fm-cancel-new-btn:hover {
  color: var(--danger, #e53935);
  background: rgba(229, 57, 53, .08);
}

/* ── Phase 5: Calendar ───────────────────────────────────────────────────── */

/* Navigation bar — centered period with arrows on both sides */
.fm-cal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 4px 10px;
}

.fm-cal-arrow {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border, #d0d0d0);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  color: var(--text, #222);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.fm-cal-arrow:hover {
  background: var(--accent, #01696f);
  border-color: var(--accent, #01696f);
  color: #fff;
}

.fm-cal-range {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #222);
  text-align: center;
  min-width: 200px;
  cursor: pointer;
  user-select: none;
}
.fm-cal-range:hover {
  color: var(--accent, #01696f);
}

/* Calendar table wrapper — wide horizontal scroll */
.fm-cal-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fm-cal-table {
  width: max-content;        /* don't compress: let it be as wide as needed */
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

/* Calendar: only installer column (col 1) is sticky — undo fm-table 3-col freeze */
.fm-table.fm-cal-table > thead > tr > th:nth-child(n+2),
.fm-table.fm-cal-table > tbody > tr > td:nth-child(n+2) {
  position: static !important;
  left: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
}

/* Sticky installer column (first) */
.fm-cal-th-name,
.fm-cal-td-name {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--card-bg, #f5f5f5);
  min-width: 130px;
  max-width: 160px;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  border-right: 2px solid var(--border, #ddd);
  border-bottom: 1px solid var(--border, #eee);
}

/* Sticky header row — handled by StickyThead.mount (pin clone) on page scroll */
.fm-cal-table thead.fm-thead-offscreen {
  visibility: collapse;
}

.fm-thead-pin .fm-thead-pin-table.fm-cal-table {
  border-collapse: collapse;
}

.fm-thead-pin .fm-thead-pin-table.fm-cal-table th:nth-child(1) {
  position: sticky !important;
  left: 0 !important;
  z-index: 28 !important;
  min-width: 130px;
  max-width: 160px;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
  border-right: 2px solid var(--border, #ddd);
  background: var(--card-bg, #f5f5f5);
}
.fm-thead-pin .fm-thead-pin-table.fm-cal-table th:nth-child(n+2) {
  position: static !important;
  left: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  padding: 7px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted, #666);
  white-space: nowrap;
  vertical-align: bottom;
  background: var(--card-bg, #f5f5f5);
}
.fm-thead-pin .fm-thead-pin-table.fm-cal-table th.fm-cal-weekend {
  background: var(--weekend-bg, #faf6f0);
  color: var(--muted, #888);
}
.fm-thead-pin .fm-thead-pin-table.fm-cal-table th.fm-cal-today {
  background: var(--today-bg, #e8f4f8);
  color: var(--accent, #01696f);
  font-weight: 700;
}

.fm-cal-th-day {
  min-width: 150px;         /* wide enough to show full name */
  max-width: 170px;
  width: 155px;
  padding: 7px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted, #666);
  white-space: nowrap;
  border-bottom: 2px solid var(--border, #e0e0e0);
  background: var(--card-bg, #f5f5f5);
  vertical-align: bottom;
}

/* Day cells */
.fm-cal-td {
  min-width: 150px;
  width: 155px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: top;
}

/* Weekend highlight */
.fm-cal-weekend .fm-cal-th-day,
.fm-cal-th-day.fm-cal-weekend {
  background: var(--weekend-bg, #f8f4ee);
  color: var(--weekend-text, #b05f00);
}
.fm-cal-td.fm-cal-weekend {
  background: var(--weekend-bg, #faf6f0);
}
[data-theme="dark"] .fm-cal-td.fm-cal-weekend {
  background: rgba(255, 180, 60, .06);
}

/* Today highlight */
.fm-cal-th-day.fm-cal-today {
  background: var(--accent, #1976d2);
  color: #fff;
  border-radius: 4px 4px 0 0;
}
.fm-cal-td.fm-cal-today {
  background: rgba(25, 118, 210, .07);
}
[data-theme="dark"] .fm-cal-td.fm-cal-today {
  background: rgba(100, 181, 246, .08);
}

/* Row hover */
.fm-cal-table tbody tr:hover .fm-cal-td {
  background: rgba(0, 0, 0, .02);
}
.fm-cal-table tbody tr:hover .fm-cal-td.fm-cal-weekend {
  background: rgba(255, 180, 60, .08);
}
.fm-cal-table tbody tr:hover .fm-cal-td.fm-cal-today {
  background: rgba(25, 118, 210, .1);
}

/* ── Chips ────────────────────────────────────────────────────────────────── */
.fm-cal-chip {
  background: var(--accent-light, rgba(25, 118, 210, .12));
  border-left: 3px solid var(--accent, #1976d2);
  border-radius: 4px;
  padding: 4px 7px;
  margin-bottom: 3px;
  white-space: normal;
  word-break: break-word;
  min-height: 36px;
  transition: background .12s;
}
.fm-cal-chip:last-child {
  margin-bottom: 0;
}
.fm-cal-chip[data-cal-deal]:hover {
  background: rgba(25, 118, 210, .22);
}

/* First day of a multi-day span */
.fm-cal-chip--start {
  border-left-width: 4px;
}

/* Manual montage chip */
.fm-cal-chip--manual {
  background: rgba(100, 149, 237, .12);
  border-left-color: cornflowerblue;
}
.fm-cal-chip--manual:hover {
  background: rgba(100, 149, 237, .22);
}

/* Day-off chip */
.fm-cal-chip--dayoff {
  background: rgba(158, 158, 158, .15);
  border-left-color: #9e9e9e;
}
[data-theme="dark"] .fm-cal-chip--dayoff {
  background: rgba(200, 200, 200, .08);
}

/* Chip content */
.fm-cal-chip-name {
  display: block;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text, #222);
}
.fm-cal-chip-sub {
  display: block;
  font-size: 11px;
  color: var(--muted, #888);
  margin-top: 1px;
}

/* ── Монтажники (installer dictionary) ──────────────────────────────────── */

.fm-ins-wrap {
  padding: 16px 20px;
  max-width: 1100px;
}

.fm-ins-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.fm-ins-th {
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #666);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border, #e0e0e0);
  background: var(--card-bg, #f5f5f5);
}

.fm-ins-th-name    { width: 180px; }
.fm-ins-th-phone   { width: 150px; }
.fm-ins-th-status  { width: 190px; }
.fm-ins-th-comment { width: auto; min-width: 180px; }
.fm-ins-th-amo     { width: 170px; }
.fm-ins-th-del     { width: 36px; }

.fm-ins-row:hover td {
  background: var(--hover-bg, rgba(0,0,0,.025));
}

.fm-ins-td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border, #eee);
  vertical-align: middle;
}

.fm-ins-td-del {
  text-align: center;
}

.fm-ins-input {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text, #222);
  transition: border-color .15s, background .15s;
}

.fm-ins-input:hover {
  border-color: var(--border, #ddd);
  background: var(--input-bg, #fff);
}

.fm-ins-input:focus {
  outline: none;
  border-color: var(--accent, #1976d2);
  background: var(--input-bg, #fff);
  box-shadow: 0 0 0 2px rgba(25,118,210,.15);
}

/* Saving indicator */
.fm-ins-input.fm-ins-saving {
  opacity: .55;
}

.fm-ins-select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--text, #222);
  cursor: pointer;
}
.fm-ins-select:hover {
  border-color: var(--border, #ddd);
  background: var(--surface, #fff);
}
.fm-ins-select:focus {
  outline: none;
  border-color: var(--accent, #01696f);
  background: var(--surface, #fff);
}
.fm-ins-select.fm-ins-saving {
  opacity: .55;
}

.fm-ins-comment {
  font-size: 13px;
}

/* AMO column — linked (amo_enum_id is set) */
.fm-ins-amo.fm-ins-amo-linked {
  color: var(--success, #2e7d32);
  font-weight: 500;
}

.fm-ins-amo.fm-ins-amo-linked::placeholder {
  color: var(--success, #2e7d32);
}

/* Delete button */
.fm-ins-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted, #aaa);
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.fm-ins-del-btn:hover {
  color: var(--danger, #e53935);
  background: rgba(229, 57, 53, .1);
}

.fm-ins-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted, #888);
  font-size: 14px;
}

.fm-ins-footer {
  margin-top: 12px;
}

.fm-ins-add-btn {
  font-size: 13px;
  padding: 6px 16px;
  background: var(--card-bg, #f5f5f5);
  border: 1px dashed var(--accent, #1976d2);
  color: var(--accent, #1976d2);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.fm-ins-add-btn:hover {
  background: var(--accent-light, rgba(25,118,210,.08));
}

/* ═══════════════════════════════════════════════════════════════════════════
   Монтажные работы — вертикальная редактируемая таблица
   ═══════════════════════════════════════════════════════════════════════════ */

.fm-rates-wrap {
  padding: 16px 20px;
}

.fm-rates-table {
  width: auto;
  max-width: 800px;
}

.fm-rates-th-label { width: 300px; text-align: left; }
.fm-rates-th-num   { width: 120px; text-align: center; }

.fm-rates-td-label { text-align: left; font-weight: 500; }
.fm-rates-td-num   { text-align: center; }

.fm-rates-input {
  width: 100px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: right;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fm-rates-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.1);
}

.fm-rates-input.fm-rates-saving {
  background-color: #fff9e6;
  border-color: #ffc107;
}

.fm-rates-input.fm-rates-saved {
  background-color: #e8f5e9;
  border-color: #4caf50;
}

.fm-rates-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Зарплата монтажнику + калькулятор
   ═══════════════════════════════════════════════════════════════════════════ */

.fm-salary-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.fm-salary-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
}

.fm-salary-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.1);
}

.fm-salary-unit {
  font-size: 16px;
  color: var(--text-muted);
}

.fm-calc-salary-btn {
  width: 100%;
  margin-top: 8px;
}

/* Модалка калькулятора */
.fm-calc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.fm-calc-modal {
  background: var(--bg, #fff);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.fm-calc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.fm-calc-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.fm-calc-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background .15s;
}

.fm-calc-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.fm-calc-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.fm-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 4px;
}

.fm-calc-row label {
  flex: 0 0 60%;
  font-size: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.fm-calc-auto-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #d4edda;
  color: #155724;
  letter-spacing: 0.3px;
}

.fm-calc-manual-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #fff3cd;
  color: #856404;
  letter-spacing: 0.3px;
}

.fm-calc-hint {
  flex: 0 0 100%;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  padding-left: 2px;
}

.fm-calc-input {
  flex: 0 0 35%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: right;
  font-size: 14px;
}

.fm-calc-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.1);
}

.fm-calc-modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.ms-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  border: none;
}

.ms-btn--secondary {
  background: var(--card-bg, #f5f5f5);
  color: var(--text-primary, #333);
  border: 1px solid var(--border);
}

.ms-btn--secondary:hover {
  background: var(--border);
}

.ms-btn--primary {
  background: var(--primary, #01696f);
  color: #fff;
}

.ms-btn--primary:hover {
  background: var(--primary-hover, #015156);
}

.ms-btn--loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Тиры ЛОС — справочник размеров станций → стоимость монтажа
   ═══════════════════════════════════════════════════════════════════════════ */

.fm-tiers-wrap {
  padding: 16px 20px;
}

.fm-tiers-table {
  width: auto;
  max-width: 600px;
}

.fm-tiers-th-label { width: 250px; text-align: left; }
.fm-tiers-th-num   { width: 180px; text-align: center; }

.fm-tiers-td-label { text-align: left; font-weight: 500; }
.fm-tiers-td-num   { text-align: center; }

.fm-tiers-input {
  width: 140px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: right;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fm-tiers-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.1);
}

.fm-tiers-input.fm-tiers-saving {
  background-color: #fff9e6;
  border-color: #ffc107;
}

.fm-tiers-input.fm-tiers-saved {
  background-color: #e8f5e9;
  border-color: #4caf50;
}

.fm-tiers-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Phase 3: Montage requests modal (отправка запросов монтажникам)
   ═══════════════════════════════════════════════════════════════════════════ */

.fm-request-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.fm-request-modal {
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}

.fm-request-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.fm-request-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.fm-request-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.15s, color 0.15s;
}

.fm-request-modal-close:hover {
  background-color: var(--hover-bg);
  color: var(--text);
}

.fm-request-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.fm-request-info {
  background: var(--hover-bg);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}

.fm-request-info div {
  margin-bottom: 4px;
}

.fm-request-info div:last-child {
  margin-bottom: 0;
}

.fm-request-salary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.fm-request-salary-row label {
  white-space: nowrap;
  flex-shrink: 0;
}

.fm-request-salary-input {
  flex: 1;
  max-width: 200px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--input-bg, #fff);
  color: var(--text);
}

.fm-request-salary-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0,128,110,.15);
}

.fm-request-table-wrapper {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.fm-request-table {
  width: 100%;
  border-collapse: collapse;
}

.fm-request-table thead {
  background-color: var(--hover-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fm-request-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.fm-request-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s;
}

.fm-request-table tbody tr:last-child {
  border-bottom: none;
}

.fm-request-table tbody tr:hover:not(.fm-request-row--disabled) {
  background-color: var(--hover-bg);
}

.fm-request-table tbody tr.fm-request-row--disabled {
  opacity: 0.5;
  background-color: #fafafa;
}

.fm-request-table td {
  padding: 12px 16px;
  font-size: 14px;
}

.fm-request-cell-checkbox {
  width: 40px;
  text-align: center;
}

.fm-request-cell-status {
  width: 120px;
  text-align: center;
}

.fm-request-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.fm-request-checkbox:disabled {
  cursor: not-allowed;
}

.fm-request-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.fm-request-badge--sent {
  background-color: #e3f2fd;
  color: #1976d2;
}

.fm-request-badge--accepted {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.fm-request-badge--declined {
  background-color: #ffebee;
  color: #c62828;
}

.fm-request-badge--cancelled {
  background-color: #f5f5f5;
  color: #757575;
}

/* Salary hint inline with installer name */
.fm-request-salary {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success, #437a22);
  white-space: nowrap;
}

/* Installer's response comment under the name */
.fm-request-response-comment {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  word-break: break-word;
}

.fm-request-comment-section {
  margin-top: 20px;
}

.fm-request-comment-section label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}

.fm-request-comment {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fm-request-comment:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.1);
}

.fm-request-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background-color: var(--hover-bg);
}

/* ── «Удал.» column ────────────────────────────────────────────────────────── */
.fm-th-del {
  width: 48px;
  text-align: center;
}
.fm-cell-delete {
  text-align: center;
}
/* Same size as fm-inline-complete; red tint to signal destructive action */
.fm-cell-delete input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #e53e3e;
}

/* ── «Закрыть сделку» modal ─────────────────────────────────────────────────── */
.fm-close-unr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.fm-close-unr-modal {
  background: var(--card-bg, #fff);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 440px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
}
.fm-close-unr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #e0e0e0);
  font-weight: 600;
  font-size: 15px;
}
.fm-close-unr-x {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted, #888);
  padding: 0 4px;
}
.fm-close-unr-x:hover { color: #e53e3e; }
.fm-close-unr-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fm-close-unr-body p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text, #333);
}
.fm-close-unr-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #333);
}
.fm-close-unr-req {
  color: #e53e3e;
  margin-left: 2px;
}
.fm-close-unr-select,
.fm-close-unr-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  font-size: 13.5px;
  background: var(--input-bg, #fff);
  color: var(--text, #333);
  box-sizing: border-box;
}
.fm-close-unr-select:focus,
.fm-close-unr-textarea:focus {
  outline: none;
  border-color: var(--primary, #01696f);
  box-shadow: 0 0 0 3px rgba(1,105,111,0.12);
}
.fm-close-unr-textarea { resize: vertical; }
.fm-close-unr-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border, #e0e0e0);
  background: var(--hover-bg, #f8f8f8);
  border-radius: 0 0 10px 10px;
}
.fm-close-unr-btn-cancel {
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid var(--border, #ccc);
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
}
.fm-close-unr-btn-cancel:hover { background: var(--hover-bg, #f0f0f0); }
.fm-close-unr-btn-submit {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  background: #e53e3e;
  color: #fff;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}
.fm-close-unr-btn-submit:hover:not(:disabled) { background: #c53030; }
.fm-close-unr-btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* Кнопка "Отправить запрос монтажникам" в detail view */
.fm-send-requests-btn {
  background-color: #f5f5f5;
  color: var(--text);
}

.fm-send-requests-btn:hover {
  background-color: #e0e0e0;
}

/* ── «Логистика» tab (read-only Затраты) ───────────────────────────────────── */
.fm-logistics-wrap {
  padding: 4px 0 12px;
}
.fm-logistics-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted, #666);
}
.fm-log-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.fm-log-filter-select {
  min-width: 160px;
  padding: 6px 8px;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  font-size: 13px;
  background: var(--input-bg, #fff);
  color: var(--text, #333);
}
.fm-log-filter-input {
  min-width: 140px;
  max-width: 200px;
}
.fm-log-filter-clear {
  padding: 6px 12px;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted, #666);
}
.fm-log-filter-clear:hover {
  background: var(--hover-bg, #f0f0f0);
}
.fm-log-filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted, #888);
  white-space: nowrap;
}
.fm-log-table-wrap {
  overflow-x: auto;
}
.fm-log-table td.lg-ro,
.fm-log-table td {
  white-space: nowrap;
}
.fm-log-table .fm-log-driver {
  font-weight: 600;
}
.fm-log-table .fm-log-station {
  max-width: 220px;
  white-space: normal;
  font-size: 12px;
  line-height: 1.35;
}

.fm-log-table tbody tr.fm-log-row-today td {
  background: #edfaed;
}
.fm-log-table tbody tr.fm-log-row-today:hover td {
  background: #d8f5d8;
}
