/* TaskFlow design — Round 3 (owner-approved visual language).
   One shared token set and component layer. Loaded LAST so it restyles the existing markup without
   changing any behaviour. Logical properties are used wherever possible so Hebrew RTL and English /
   Russian LTR share the same rules. Reference: artifacts/taskflow-ui-redesign/proposal-round-3/. */

/* ───────────────────────── tokens ───────────────────────── */
:root {
  --font: "Rubik", "Segoe UI", system-ui, -apple-system, "Noto Sans Hebrew", "Noto Sans", Arial, sans-serif;
  --bg: #f6f7f9; --surface: #fff; --surface-2: #fafbfc; --border: #e6e8ec; --border-strong: #d5d9e0; --line: #eceff3;
  --text: #11203a; --text-2: #38465c; --muted: #66738a; --faint: #9aa4b2;
  --primary: #0f766e; --primary-hover: #115e59; --primary-soft: #ecf7f5; --primary-line: #a7d8d1;
  --info: #1e5fb4; --info-soft: #eef4fc; --ok: #047857; --ok-soft: #ecfdf5; --ok-line: #a7f3d0;
  --warn: #a5500a; --warn-soft: #fff8e8; --warn-line: #f3dca0; --bad: #b42323; --bad-soft: #fdf1f1; --bad-line: #f2c5c5;
  --radius: 8px; --radius-sm: 6px; --radius-lg: 12px;
  --w-std: 1320px; --w-wide: 1800px; --gutter: 28px; --pad: 20px; --gap: 20px;
  --row: 48px; --th: 40px; --ctl: 36px; --ctl-sm: 30px;
  --fs-body: 14.5px; --fs-table: 14px; --fs-th: 12.5px; --fs-h1: 26px; --fs-h2: 16px; --fs-btn: 13.5px;
  --kpi-h: 68px;
  /* legacy variable names used all over the existing CSS -> approved palette */
  --accent: #0f766e; --green: #12a67b; --red: #d64545; --yellow: #e0a21a;
  --topnav-main-height: 60px; --topnav-row-height: 0px; --topnav-height: 60px;
  --topnav-teal: #0f766e; --topnav-ink: #11203a;
}

html { scroll-padding-top: 72px; }
body { font-family: var(--font); font-size: var(--fs-body); line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }

/* ───────────────────────── shell: one calm row ───────────────────────── */
.sidebar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: none; color: var(--text);
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) var(--tf-user-w, 300px); align-items: center;
  column-gap: 14px; padding-inline: var(--gutter) 0;
}
.sidebar-logo { position: static; height: 60px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; color: var(--text); }
.sidebar-logo span { color: var(--primary); }
.sidebar-bu-badge {
  position: static; min-width: 0; width: 200px; max-width: 200px; height: 34px; padding: 0 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 500; color: var(--text);
}
.sidebar-bu-badge::after { background: #12a67b; width: 7px; height: 7px; }
.sidebar-bu-badge.topnav-switchable::before { color: var(--muted); }
.sidebar-nav { position: static; height: 60px; padding: 0; border: 0; background: transparent; grid-template-columns: minmax(0, max-content) auto; justify-content: start; min-width: 0; }
#sidebar-facade, #sidebar-scaffold, #sidebar-global { height: 60px; }
.nav-item {
  min-height: 60px; padding: 0 10px; font-size: 0; /* emoji glyphs live in bare text nodes: hidden; labels restored below */
  border-bottom: 2px solid transparent; margin-bottom: 0; color: var(--text-2); font-weight: 500;
}
.nav-item > span { font-size: 14px; font-weight: 500; }
.nav-item > .nav-badge, .nav-item > span.nav-badge { font-size: 11px; font-weight: 600; }
.nav-item:hover { background: transparent; color: var(--text); }
.nav-item.active { background: transparent; color: var(--primary); border-bottom-color: var(--primary); }
.nav-item.active > span { font-weight: 600; }
.nav-badge { background: var(--bad-soft); color: var(--bad); min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; border-radius: 9px; }
.topnav-more-button { height: 60px; background: transparent; box-shadow: none; color: var(--text-2); font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; }
.topnav-more-button:hover, .topnav-more-button[aria-expanded="true"] { background: transparent; color: var(--text); }
.topnav-more-button.active { color: var(--primary); border-bottom-color: var(--primary); }
.topnav-more-menu { top: 58px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); border-color: var(--border); box-shadow: 0 18px 36px rgb(15 23 42 / 14%); }
.topnav-more-link:hover, .topnav-more-link:focus-visible, .topnav-more-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-bu-switcher { position: static; display: none !important; }

.main-wrap { min-height: calc(100vh - 60px); }
body { padding-top: 60px; }
.topbar { width: 100%; max-width: calc(var(--w-std) + 2 * var(--gutter)); margin-inline: auto; padding: 22px var(--gutter) 8px; background: transparent; }
.topbar .pulse { display: none; }
.topbar h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -.2px; line-height: 1.25; color: var(--text); }
.topbar .user-info { top: 8px; left: var(--gutter); height: 44px; padding: 0; gap: 12px; background: transparent; }
.user-info .uname { font-size: 13px; font-weight: 600; color: var(--text); }
.user-info .urole { font-size: 11px; color: var(--muted); }
.lang-select { min-height: var(--ctl-sm); height: var(--ctl-sm); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; padding: 0 8px; }
.content { width: 100%; max-width: calc(var(--w-std) + 2 * var(--gutter)); margin-inline: auto; padding: 14px var(--gutter) 56px; }
.impersonation-bar { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn-line); }

/* ───────────────────────── cards ───────────────────────── */
.table-wrap, .project-card, .settings-card, .chart-wrap, .bu-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none;
}
.project-card { border-top: 1px solid var(--border); padding: var(--pad); }
.project-card:hover { box-shadow: none; transform: none; border-color: var(--border-strong); }
.table-toolbar { padding: 12px var(--pad); min-height: 52px; border-bottom: 1px solid var(--border); }
.table-toolbar h2, .settings-card h3 { font-size: var(--fs-h2); font-weight: 600; letter-spacing: -.1px; }

/* KPI: small separate cards (the approved Round 3 component) */
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stat-card {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: var(--kpi-h);
  padding: 10px var(--pad); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; cursor: default;
  --kc: #3b7bd8;
}
.stat-card:hover { box-shadow: none; }
.stat-card::before { content: ""; position: absolute; inset-inline-end: 14px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--kc); }
.stat-card.green { --kc: #12a67b; border-color: var(--border); } .stat-card.yellow { --kc: #e0a21a; border-color: var(--border); }
.stat-card.red { --kc: #d64545; border-color: var(--border); } .stat-card.gray { --kc: #c4cad3; border-color: var(--border); }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); }

/* ───────────────────────── tables ───────────────────────── */
table { font-size: var(--fs-table); }
thead { background: var(--surface-2); }
th { padding: 10px 12px; font-size: var(--fs-th); font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--border-strong); line-height: 1.25; }
td { padding: 8px 12px; font-size: var(--fs-table); border-bottom: 1px solid var(--line); min-height: var(--row); }
tr:hover td { background: #f7fafa; }
.empty-row td { padding: 40px var(--pad); color: var(--muted); }

/* ───────────────────────── pills / badges ───────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.completed { background: var(--info-soft); color: var(--info); }
.pill.partial { background: #f1ecfa; color: #5b3aa6; }
.pill.issue { background: var(--bad-soft); color: var(--bad); }
.status-badge { border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500; padding: 2px 8px; }
.status-badge.active { background: var(--ok-soft); color: var(--ok); } .status-badge.completed { background: var(--info-soft); color: var(--info); }
.status-badge.inactive { background: var(--warn-soft); color: var(--warn); } .status-badge.archived { background: #f0f2f5; color: var(--muted); }
.status-badge.deleted, .status-badge.faulty { background: var(--bad-soft); color: var(--bad); }
.role-badge { border-radius: var(--radius-sm); }

/* ───────────────────────── buttons ───────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--ctl-sm); padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; line-height: 1.2; transition: background .12s, border-color .12s; }
.btn:hover { opacity: 1; }
.btn-primary { min-height: var(--ctl); padding: 0 14px; font-size: var(--fs-btn); background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost, .btn-view { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover, .btn-view:hover { background: var(--surface-2); }
.btn-approve { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.btn-reject { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }
.btn-reject:hover { background: var(--bad-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ───────────────────────── form controls ───────────────────────── */
select, input[type=date], input[type=text], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=search], input[type=time], input[type=month], input[type=url], textarea {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13.5px;
}
select, input[type=date], input[type=text], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=search], input[type=time], input[type=month], input[type=url] { min-height: var(--ctl); padding: 0 10px; }
textarea { padding: 8px 10px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .18); }
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13.5px; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .18); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }

/* ───────────────────────── dialogs ───────────────────────── */
.modal-overlay { background: rgba(15, 26, 43, .45); }
.modal { border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(15, 26, 43, .35); padding: var(--pad); }
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.modal-close { background: transparent; color: var(--muted); border: 0; }
.modal-close:hover { background: #eef1f4; color: var(--text); }
.detail-item label { font-size: 12.5px; color: var(--muted); }
.detail-item span { font-size: 14.5px; font-weight: 500; }
.modal-actions { gap: 10px; }

/* ───────────────────────── tabs inside pages ───────────────────────── */
.wh-tabs { border-bottom: 1px solid var(--border); gap: 4px; }
.wh-tab-btn { padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; }
.wh-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.wh-filter-banner { background: var(--primary-soft); border-color: var(--primary-line); }
.wh-workspace-controls { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.wh-workspace-controls.global { background: var(--warn-soft); border-color: var(--warn-line); }

/* progress */
.progress-bar { height: 6px; border-radius: 99px; background: #e9edf1; }
.progress-fill { border-radius: 99px; }

/* ───────────────────────── mobile ───────────────────────── */
@media (max-width: 760px) {
  :root { --topnav-main-height: 52px; --topnav-row-height: 46px; --topnav-height: 98px; --gutter: 14px; --pad: 14px; --gap: 12px; --ctl: 44px; --ctl-sm: 44px; }
  body { padding-top: 98px; }
  .sidebar { display: block; height: 98px; padding: 0; }
  .sidebar-logo { position: absolute; inset-inline-start: 14px; top: 0; height: 52px; font-size: 20px; right: auto; }
  html[dir="rtl"] .sidebar-logo { right: 14px; left: auto; }
  .sidebar-bu-badge { position: absolute; top: 9px; inset-inline: 118px 14px; width: auto; max-width: none; height: 34px; }
  .sidebar-nav { position: absolute; inset: 52px 0 auto; height: 46px; border-top: 1px solid var(--line); background: var(--surface); grid-template-columns: minmax(0, 1fr) 62px; }
  #sidebar-facade, #sidebar-scaffold, #sidebar-global { height: 46px; }
  .nav-item { min-height: 46px; padding: 0 12px; }
  .topnav-more-button { height: 46px; }
  .topnav-more-menu { top: 97px; }
  .topbar { padding: 14px var(--gutter) 6px; }
  .topbar h1 { font-size: 20px; }
  .content { padding: 10px var(--gutter) 40px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { min-height: 64px; padding: 8px 12px; }
  .stats-grid .stat-card { padding: 8px 12px; }
  .modal { padding: var(--pad); }
}

/* ───────────────────────── Workers (unified employees, BU1 + BU2) ───────────────────────── */
.employees-shell { gap: var(--gap); }
.employees-bu1-flat .employees-shell { grid-template-columns: minmax(0, 1fr) 420px; }
.employees-panel { border-radius: var(--radius); border-color: var(--border); }
.employees-list-head { padding: 14px var(--pad) 12px; }
.employees-title-row h2 { font-size: var(--fs-h2); font-weight: 600; }
.employees-count { font-size: 12.5px; }
.employee-create { min-height: var(--ctl-sm); border-radius: var(--radius-sm); border-color: var(--primary); background: var(--primary); font-size: 12.5px; font-weight: 500; padding: 0 12px; }
.employees-field { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.employees-field input, .employees-field select { height: var(--ctl); border-color: var(--border-strong); border-radius: var(--radius-sm); font-size: 13.5px; }
.employees-scope-note { font-size: 12px; }
.employees-bu1-flat .employees-list-head { padding: 14px var(--pad) 12px; }
.employees-bu1-flat .employees-list { padding: 0; }
.employee-list-row { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); border-inline-start: 3px solid transparent; padding: 7px var(--pad); }
.employee-list-row:hover { background: #f7fafa; }
.employee-list-row[aria-selected="true"] { background: var(--primary-soft); border-color: var(--line); border-inline-start-color: var(--primary); box-shadow: none; }
.employee-avatar { background: #dff0ee; color: #0d625b; font-weight: 600; }
.employee-list-copy strong { font-size: 14px; font-weight: 600; }
.employee-bu.bu1 { background: #e4f3f1; color: #0d625b; } .employee-bu.bu2 { background: #eceffd; color: #3a3fa0; }
.employee-bu, .employee-status, .employee-pwa-state { font-weight: 500; font-size: 11.5px; }
.employee-status.active { background: var(--ok-soft); color: var(--ok); } .employee-status.inactive { background: #f0f2f5; color: var(--muted); }
/* flat BU1 list row: name; phone · status; gauge at the inline end, readable beside both */
.employees-bu1-flat .employee-compact-worker { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 0; align-items: center; height: 68px; min-height: 68px; padding: 7px var(--pad); border-radius: 0; text-align: start; }
.employees-bu1-flat .employee-compact-name { grid-column: 1 / 3; grid-row: 1; font-size: 14px; font-weight: 600; line-height: 1.35; align-self: end; }
.employees-bu1-flat .employee-compact-meta { display: contents; }
.employees-bu1-flat .employee-compact-phone { grid-column: 1; grid-row: 2; font-size: 12.5px; color: var(--muted); align-self: start; padding-top: 2px; }
.employees-bu1-flat .employee-compact-status { grid-column: 2; grid-row: 2; justify-self: start; margin-inline-start: 12px; font-size: 12.5px; font-weight: 500; color: var(--ok); gap: 6px; align-self: start; padding-top: 2px; }
.employees-bu1-flat .employee-compact-status::before { width: 7px; height: 7px; box-shadow: none; background: #12a67b; }
.employees-bu1-flat .employee-compact-status.inactive { color: var(--muted); } .employees-bu1-flat .employee-compact-status.inactive::before { background: #aab3bf; box-shadow: none; }
.employee-performance-gauge { grid-column: 3; grid-row: 1 / 3; width: 68px; height: 40px; }
.employee-performance-gauge svg { width: 66px; height: 39px; }
.employee-performance-gauge > b { bottom: 11px; }
.employee-performance-days { bottom: -3px; font-size: 10px; }
.employee-performance-tooltip { font-size: 11.5px; width: 236px; }
.employee-performance-tooltip strong { font-size: 12.5px; }
/* detail */
.employee-detail { padding: var(--pad); }
.employee-detail-head { padding-bottom: 14px; }
.employee-heading h2 { font-size: 18px; font-weight: 600; }
.employee-heading p { font-size: 13px; }
.employee-summary { gap: 0; margin: 12px calc(-1 * var(--pad)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.employee-summary-card { border: 0; border-radius: 0; padding: 12px var(--pad); }
.employee-summary-card + .employee-summary-card { border-inline-start: 1px solid var(--border); }
.employee-summary-card span { font-size: 12px; } .employee-summary-card strong { font-size: 15px; font-weight: 600; }
.employee-detail-grid { gap: var(--gap); }
.employee-detail-block { border: 0; padding: 0; border-radius: 0; font-size: 13px; }
.employee-detail-block h3 { font-size: 13.5px; font-weight: 600; }
.employee-info-item span { font-size: 12.5px; } .employee-info-item strong { font-weight: 500; font-size: 13.5px; }
.employee-action { min-height: var(--ctl-sm); border-radius: var(--radius-sm); border-color: var(--border-strong); background: var(--surface); font-weight: 500; font-size: 12.5px; padding: 0 12px; }
.employee-action.primary { background: var(--primary); border-color: var(--primary); }
.employee-action.danger { color: var(--bad); border-color: var(--bad-line); background: var(--surface); }
.employee-future-note { background: var(--surface-2); }
.employee-editor-fields input, .employee-editor-fields select { height: var(--ctl); border-color: var(--border-strong); border-radius: var(--radius-sm); }
.employee-project-editor, .employee-reporter-option { border-color: var(--border); border-radius: var(--radius); }
@media (max-width: 640px) {
  .employee-summary { margin-inline: calc(-1 * var(--pad)); }
  .employee-summary-card:nth-child(3) { border-inline-start: 0; } .employee-summary-card:nth-child(n+3) { border-top: 1px solid var(--border); }
}
.employee-heading h2, .employee-heading p { width: fit-content; max-width: 100%; }

/* ───────────────────────── Projects / buildings / building grid ───────────────────────── */
.back-btn { color: var(--primary); font-size: 12.5px; font-weight: 500; margin-bottom: 6px; }
#buildings-project-name, #sections-project-name { font-size: 22px !important; font-weight: 700 !important; letter-spacing: -.2px; }
#buildings-project-meta, #sections-project-meta { font-size: 13px !important; color: var(--muted) !important; margin-top: 3px; }
/* page action rows: inline-coloured legacy buttons take the approved kinds */
#buildings-view .btn-primary[style], #sections-view .btn-primary[style] { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border-strong); min-height: var(--ctl); font-size: var(--fs-btn); }
#buildings-view .btn-primary[style]:hover, #sections-view .btn-primary[style]:hover { background: var(--surface-2) !important; }
#buildings-view .btn, #sections-view .building-section-actions .btn { min-height: var(--ctl); font-size: var(--fs-btn); }
#sections-view .btn-ghost[style*="color:var(--red)"], #sections-view .btn-ghost[style*="color: var(--red)"] { color: var(--bad) !important; border-color: var(--bad-line); }
.building-kpis { margin: 0 0 var(--gap); }
.stat-num .stat-sub { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-num .stat-sub bdi { font-variant-numeric: tabular-nums; }
.building-kpis .stat-num { font-size: 20px; }
.project-card h3 { font-size: 16px; font-weight: 600; }
.project-meta { color: var(--muted); font-size: 12.5px; }
.progress-label { font-size: 12.5px; color: var(--muted); }
.progress-fill { background: #12a67b; }
.project-card-actions .btn, .project-card .btn { min-height: var(--ctl-sm); }
.archive-select { min-height: var(--ctl-sm); padding: 0 8px; border-radius: var(--radius-sm); }

.building-sections-card .table-toolbar { min-height: 56px; }
#excel-bulk-toolbar { background: var(--surface-2) !important; border-top: 1px solid var(--border) !important; padding: 10px var(--pad) !important; }
#excel-selected-count { font-weight: 500 !important; color: var(--muted) !important; }
#sections-month-filter { min-height: var(--ctl-sm); padding: 0 8px !important; border-color: var(--border-strong) !important; border-radius: var(--radius-sm) !important; font-size: 13px !important; }
.building-sections-scroll { max-height: calc(100vh - 340px); min-height: 360px; }
#building-excel-table { font-size: var(--fs-table); min-width: 1180px; }
#building-excel-table th, #building-excel-table td { height: 46px; padding: 0 8px; border: 0; border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); font-size: var(--fs-table); line-height: 1.3; }
#building-excel-table th:first-child, #building-excel-table td:first-child { border-inline-start: 0; }
#building-excel-table th { position: sticky; top: 0; z-index: 3; height: 44px; background: var(--surface-2); color: var(--muted); font-size: var(--fs-th); font-weight: 500; white-space: normal; border-bottom: 1px solid var(--border-strong); }
#building-excel-table th.excel-sticky-cell { z-index: 5; background: var(--surface-2); }
#building-excel-table .excel-header-label { white-space: normal; text-overflow: clip; overflow: visible; line-height: 1.2; }
#building-excel-table tbody tr:nth-child(even):not(.empty-row) > td { background: var(--surface); }
#building-excel-table tbody tr:not(.empty-row):hover > td, #building-excel-table tbody tr:not(.empty-row):hover > td.excel-sticky-cell { background: #f7fafa; }
#building-excel-table .excel-readonly-cell, #building-excel-table tbody tr:nth-child(even):not(.empty-row) > td.excel-readonly-cell { background: var(--surface); color: var(--muted); }
#building-excel-table .excel-sticky-edge { box-shadow: -3px 0 4px -4px rgba(15, 23, 42, .35); }
#building-excel-table td.excel-sticky-cell:first-child, #building-excel-table td.excel-sticky-cell[data-col="section_number"] { font-weight: 600; font-variant-numeric: tabular-nums; }
#building-excel-table input, #building-excel-table textarea { min-height: 32px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 4px 8px; font-size: var(--fs-table); font-family: inherit; }
#building-excel-table textarea { height: 32px; min-height: 32px; }
#building-excel-table input:hover, #building-excel-table textarea:hover { border-color: var(--border); background: var(--surface); }
#building-excel-table input:focus, #building-excel-table textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .18); }
#building-excel-table .excel-selector-cell input { width: 16px; min-height: 16px; }
.excel-base-readonly { min-height: 32px; padding: 6px 8px; }
/* work cells: percentage / quantity chips, faint "+" until hover (Round 3) */
.excel-cell-btn { display: inline-grid; place-items: center; min-width: 46px; min-height: 26px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; font-family: inherit; }
.excel-cell-btn.is-qty { min-width: 34px; background: var(--info-soft); color: var(--info); }
.excel-cell-btn.is-pct.is-partial { background: var(--warn-soft); color: var(--warn); }
.excel-cell-btn.is-empty { min-width: 30px; background: transparent; border-color: transparent; color: #b7bfca; font-size: 15px; font-weight: 400; line-height: 1; }
.excel-cell-btn:hover { border-color: var(--primary); }
tr:hover .excel-cell-btn.is-empty, .excel-cell-btn.is-empty:focus-visible { border-color: var(--border-strong); color: var(--primary); background: var(--surface); }
.excel-cell-readonly { min-height: 26px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info); border: 0; font-weight: 600; font-size: 12.5px; padding: 0 8px; }
.excel-cell-readonly:empty { background: transparent; }
@media (hover: none) { .excel-cell-btn.is-empty { border-color: var(--border-strong); color: var(--primary); background: var(--surface); min-width: 42px; min-height: 38px; } }
/* column widths sized by content: identifier up to 4 digits + decimals, floor 2 digits / short text, narrow status + quantity columns; notes takes the rest */
#building-excel-table th[data-col="floor_scope"] { width: 72px; }
#building-excel-table th[data-col="apartment"] { width: 96px; }
#building-excel-table th[data-col="area_sqm"] { width: 96px; }
#building-excel-table th[data-col="wash"] { width: 84px; }
#building-excel-table th[data-col="seal"] { width: 96px; }
#building-excel-table th[data-col="cladding"] { width: 84px; }
#building-excel-table th[data-col="stones"], #building-excel-table th[data-col="screws"] { width: 76px; }
#building-excel-table th[data-col="flanges"] { width: 84px; }
#building-excel-table th[data-col="scaffolding"] { width: 92px; }
#building-excel-table th[data-col="notes"] { width: auto; min-width: 280px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="apartment"] { width: 112px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="area_sqm"] { width: 104px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="seal"] { width: 124px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="cladding"] { width: 100px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="scaffolding"] { width: 118px; }
html:is([lang="en"], [lang="ru"]) #building-excel-table th[data-col="flanges"] { width: 96px; }

/* ───────────────────────── Reports ───────────────────────── */
.action-btns { flex-wrap: nowrap; align-items: center; }
.action-btns .btn { white-space: nowrap; }
#page-dashboard .table-toolbar .btn-primary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); min-height: var(--ctl-sm); font-size: 12.5px; }
#page-dashboard .table-toolbar .btn-primary:hover { background: var(--surface-2); }
.stat-num { text-align: right; }
#building-excel-table textarea { resize: none; }

/* ───────────────────────── legacy blue / indigo accents -> approved palette ───────────────────────── */
.manual-ack-option { border-radius: var(--radius); }
.manual-ack-option:has(input:checked), .proj-checkbox:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.rcr-reassurance, .rcr-confirm-copy { background: var(--info-soft); color: #1c4a85; border-radius: var(--radius); }
.rir-motors { border: 1px solid #cfe0f5; border-radius: var(--radius); background: var(--info-soft); }
tr.editing td { background: var(--primary-soft); }
.rt-cell-meta button, .raj-shell .link-btn, .rct-link-btn { color: var(--primary); }
.rcr-status.invoiced, .rate-source-tag.rate-source-building, .role-badge.manager, .status-badge.completed { background: var(--info-soft); color: var(--info); }
.project-card.completed { border-top-color: var(--border); }
a { color: var(--primary); }

/* ───────────────────────── rental scaffolds (BU2): KPI cards, toolbar, tabs, tables ───────────────────────── */
.rco-kpis { gap: var(--gap); margin: var(--gap) 0; }
.rco-kpi { border-radius: var(--radius); padding: 10px var(--pad); min-height: var(--kpi-h); display: flex; flex-direction: column; justify-content: center; }
.rco-kpi-label { font-size: 12.5px; }
.rco-kpi-value { margin-top: 1px; font-size: 22px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.rco-kpi-subtitle { font-size: 12px; }
.rco-toolbar, .rco-period-card, .rcr-mobile-card, .rir-card, .raj-card, .rib-history-card, .rib-charge-card, .rib-line-card { border-radius: var(--radius); }
.rco-customer-meta { font-size: 13px; }
.rco-section-header h3 { font-size: var(--fs-h2); font-weight: 600; }
.rct-tab { font-weight: 500; font-size: 14px; color: var(--text-2); }
.rct-tab.active { font-weight: 600; color: var(--primary); }
.rct-table th, .rct-table td { padding: 6px 8px; }
.rct-table thead th { background: var(--surface-2); font-size: var(--fs-th); font-weight: 500; }
.rct-table td.rct-sticky, .rct-table td.rct-sticky-actions { background: var(--surface); }
.rct-table th.rct-sticky, .rct-table th.rct-sticky-actions { background: var(--surface-2); }
.rct-table input, .rct-table select { border-radius: var(--radius-sm); }
.rct-badge, .rcr-status, .rib-status, .raj-badge, .rir-status, .rco-period-state { font-weight: 500; }
/* controls inside table cells stay compact so rows keep the approved height */
td input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), td select, th select, td textarea { min-height: 30px; }
td input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), td select { padding-block: 0; }

/* ───────────────────────── settings, flow, translations ───────────────────────── */
.settings-card { padding: 0; }
.settings-card h3 { padding: 14px var(--pad); border-bottom: 1px solid var(--border); margin: 0; }
.setting-row { padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.flow-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; }
.flow-step-num { background: var(--primary); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.rental-rates-card, .rt-group { border-radius: var(--radius); border-color: var(--border); box-shadow: none; }
.rental-rates-table th, .rt-table th { background: var(--surface-2); color: var(--muted); font-size: var(--fs-th); font-weight: 500; }

/* ───────────────────────── warehouse ───────────────────────── */
.wh-tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.wh-tab-btn { white-space: nowrap; }
.wh-workspace-control select { min-height: var(--ctl); border-color: var(--border-strong); border-radius: var(--radius-sm); }
.whsd-location-section, .whsd-danger-zone { border-radius: var(--radius); }
.wh-req-item-row select, .wh-req-item-row input { min-height: var(--ctl-sm); }

/* ───────────────────────── Budget & Profitability: the two revenue cards sit side by side (Round 3) ───────────────────────── */
@media (min-width: 1100px) {
  .fin-v2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
  .fin-v2 > * { grid-column: 1 / -1; min-width: 0; }
  .fin-v2 > .fin-v2-section:nth-child(2), .fin-v2 > .fin-v2-section:nth-child(3) { grid-column: auto; }
}

/* inline-coloured legacy elements -> approved palette */
[style*="background:#0d9488"], [style*="background: #0d9488"], [style*="background:#2563eb"], [style*="background: #2563eb"] { background: var(--primary) !important; }
[style*="color:#1e40af"], [style*="color: #1e40af"], [style*="color:#2563eb"], [style*="color: #2563eb"] { color: var(--info) !important; }
[style*="background:#eff6ff"], [style*="background: #eff6ff"], [style*="background:#dbeafe"], [style*="background: #dbeafe"] { background: var(--info-soft) !important; }
@media (max-width: 640px) {
  /* touch targets on cards keep the existing 44px minimum */
  .project-card .btn, .project-card-actions .btn, .project-card .archive-select { min-height: 44px; }
}
/* explain popover: width must not depend on its left offset (it is measured before it is placed) */
.fin-explain-popover { width: max-content; background: var(--surface); border-radius: var(--radius); }

/* ───────────────────────── context heading + breadcrumb ───────────────────────── */
.topbar { flex-wrap: wrap; }
.page-crumbs { flex: 0 0 100%; order: -1; display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 2px; min-width: 0; }
.page-crumbs[hidden] { display: none; }
.page-crumbs .crumb { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-crumbs .crumb:hover { text-decoration: underline; }
.page-crumbs .sep { color: var(--faint); }
body[data-ctx] #page-projects .back-btn, body[data-ctx] #page-scaffolding-projects .back-btn { display: none; }
body[data-ctx] #buildings-project-name, body[data-ctx] #sections-project-name, body[data-ctx] #fin-proj-title, body[data-ctx] #fin-bld-title, body[data-ctx] #sc-customer-projects-name { display: none; }
body[data-ctx] #page-projects [style*="margin-bottom:18px"]:has(> div > #buildings-project-meta:empty) { margin-bottom: 0; }

/* ───────────────────────── content widths: 1320 standard, 1800 for the Building grid ───────────────────────── */
.content:has(#page-projects.active #sections-view[style*="display: block"]) { max-width: calc(var(--w-wide) + 2 * var(--gutter)); }
body:has(#page-projects.active #sections-view[style*="display: block"]) .topbar { max-width: calc(var(--w-wide) + 2 * var(--gutter)); }
#page-reports .table-wrap { overflow-x: auto; }
#page-reports table { min-width: 1120px; }
#page-reports th, #page-reports td { padding-inline: 8px; }

/* ───────────────────────── Settings: section navigation + compact field grouping ───────────────────────── */
.settings-card { scroll-margin-top: 76px; }
#page-settings > h2 { display: none; }
#page-settings.active.has-subnav { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--gap); align-items: start; }
#page-settings.has-subnav > :not(.settings-subnav) { grid-column: 2; min-width: 0; margin-bottom: var(--gap); }
#page-settings.has-subnav > .settings-subnav { grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 72px; margin: 0; }
.settings-subnav { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; }
.settings-subnav .grp { font-size: 11px; font-weight: 600; letter-spacing: .3px; color: var(--faint); padding: 10px 10px 4px; }
.settings-subnav a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-2); text-decoration: none; line-height: 1.35; }
.settings-subnav a:hover { background: #f3f6f7; }
.settings-subnav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
/* rows: label next to its input (and unit), several per line on wide screens */
.settings-card:has(> .setting-row:nth-child(5)) { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); column-gap: var(--pad); align-content: start; }
.settings-card:has(> .setting-row:nth-child(5)) > h3, .settings-card:has(> .setting-row:nth-child(5)) > hr, .settings-card:has(> .setting-row:nth-child(5)) > :not(.setting-row) { grid-column: 1 / -1; }
.settings-card > .setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px var(--pad); border-bottom: 1px solid var(--line); min-width: 0; }
.settings-card > .setting-row > label { flex: 1 1 auto; min-width: 0; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.settings-card > .setting-row > input { flex: none; }
.settings-card > hr { margin: 0 !important; }
@media (max-width: 900px) {
  #page-settings.active.has-subnav { grid-template-columns: minmax(0, 1fr); }
  #page-settings.has-subnav > :not(.settings-subnav), #page-settings.has-subnav > .settings-subnav { grid-column: 1; grid-row: auto; }
  #page-settings.has-subnav > .settings-subnav { position: sticky; top: 98px; z-index: 5; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .settings-subnav .grp { display: none; }
  .settings-subnav a { white-space: nowrap; padding: 10px 12px; min-height: 44px; display: inline-flex; align-items: center; }
}

/* ───────────────────────── readable card tables on phones (Reports and other long lists) ───────────────────────── */
@media (max-width: 640px) {
  #page-reports table { min-width: 0; }
  table.rt-cards thead { display: none; }
  table.rt-cards, table.rt-cards tbody { display: block; width: 100%; }
  table.rt-cards tr { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; }
  table.rt-cards tr:hover td { background: transparent; }
  table.rt-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; grid-column: 1 / -1; min-width: 0; white-space: normal; text-align: start; }
  table.rt-cards td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12.5px; font-weight: 500; }
  table.rt-cards td > :not(.action-btns) { min-width: 0; }
  table.rt-cards td:empty { display: none; }
  /* Reports card: #id + date + status on top, worker as the title, labelled details, actions last */
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(1) { grid-column: 1; grid-row: 1; font-weight: 700; padding: 0; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(1)::before { content: "#"; color: var(--muted); font-weight: 500; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(2) { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 12.5px; padding: 0; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(2)::before, #reports-tbody td:nth-child(1)::after { content: none; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(9) { grid-column: 3; grid-row: 1; padding: 0; justify-content: flex-end; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(9)::before { content: none; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(3) { grid-row: 2; font-size: 15px; font-weight: 600; padding: 8px 0 6px; }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(3)::before { content: none; }
  #reports-tbody td:nth-child(11) { padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line); }
  #reports-tbody td:nth-child(11)::before { content: none; }
  #reports-tbody .action-btns { flex-wrap: wrap; width: 100%; gap: 8px; }
  #reports-tbody .action-btns .btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
  #reports-tbody td:nth-child(10) img.thumb { width: 56px; height: 56px; }
  table.rt-cards tr.empty-row, table.rt-cards tr.batch-group-row { display: block; }
  table.rt-cards tr.empty-row td, table.rt-cards tr.batch-group-row td { display: block; text-align: center; }
  #page-reports .table-wrap, #page-reports .table-wrap > table, #page-users .table-wrap { background: transparent; border: 0; }
  #page-reports .table-toolbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
}

/* ───────────────────────── LTR (English / Russian): mirrored layout ───────────────────────── */
html[dir="ltr"] body { direction: ltr; }
th { text-align: start; }
html[dir="ltr"] .topbar .user-info { left: auto; inset-inline-end: var(--gutter); }
html[dir="ltr"] .topnav-more-menu { left: auto; right: 22px; }
.filters { margin-right: 0; margin-inline-start: auto; }
html[dir="ltr"] .employees-bu1-flat .employees-shell { grid-template-columns: 420px minmax(0, 1fr); }
html[dir="ltr"] .employees-shell { grid-template-columns: 360px minmax(0, 1fr); }
html[dir="ltr"] .employees-list-panel { grid-column: 1; }
html[dir="ltr"] .employees-detail-panel { grid-column: 2; }
html[dir="ltr"] .employees-panel { direction: ltr; }
html[dir="ltr"] .employee-list-row, html[dir="ltr"] .employee-heading p { text-align: left; }
html[dir="ltr"] .employee-list-row[aria-selected="true"] { box-shadow: none; }
html[dir="ltr"] .stat-num { text-align: left; }
@media (max-width: 1180px) {
  html[dir="ltr"] .employees-shell { grid-template-columns: 310px minmax(0, 1fr); }
  html[dir="ltr"] .employees-bu1-flat .employees-shell { grid-template-columns: 390px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  html[dir="ltr"] .employees-shell { display: block; }
}
:where(html[dir="ltr"]) td { text-align: left; }
html:is([lang="en"], [lang="ru"]) .nav-item > span { font-size: 13.5px; }
/* Reports table: actions wrap onto two lines instead of forcing a wider table */
#page-reports .action-btns { flex-wrap: wrap; max-width: 250px; row-gap: 6px; }
#page-reports td:nth-child(3) { min-width: 150px; }
#page-reports td:nth-child(4) { min-width: 140px; }
@media (max-width: 640px) {
  table.rt-cards td.rt-empty { display: none; }
  /* phone filters: one control per line, nothing clipped */
  .table-toolbar .filters { margin: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .table-toolbar .filters > select, .table-toolbar .filters > input { width: 100%; min-width: 0; }
  .table-toolbar .filters > select:nth-child(n+3), .table-toolbar .filters > input, .table-toolbar .filters > .btn { grid-column: 1 / -1; }
}
body[data-ctx] .content { padding-top: 6px; }

/* ───────────────────────── Meckano review dialog (approved: inset dialog on a dark scrim, width bounded to 1800) ───────────────────────── */
.mai-dialog { inset: 16px; margin: auto; width: min(var(--w-wide), calc(100dvw - 32px)); height: calc(100dvh - 32px); border: 0; border-radius: var(--radius-lg); padding: 0; background: var(--surface); box-shadow: 0 24px 60px rgba(0, 0, 0, .4); font-family: var(--font); }
.mai-dialog::backdrop { background: rgba(15, 26, 43, .55); }
.mai-dialog > header { margin: 0; padding: 14px var(--pad); border-bottom: 1px solid var(--border); }
.mai-dialog [data-mai-body] { padding: 12px var(--pad) 0; gap: 10px; }
.mai-dialog .mai-summary { margin: 0; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.mai-metric { border: 0; border-radius: 0; background: var(--surface); padding: 8px 14px; }
.mai-metric + .mai-metric { border-inline-start: 1px solid var(--line); }
.mai-metric span { font-size: 11.5px; color: var(--muted); }
.mai-metric strong { font-size: 14.5px; font-weight: 600; }
.mai-dialog .wp-scroll { border-color: var(--border); border-radius: var(--radius); }
.mai-status { background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.mai-status-ok { background: var(--ok-soft); color: var(--ok); }
.mai-resolved { background: var(--ok-soft); color: var(--ok); }
.mai-change { background: var(--warn-soft); border-inline-start-color: var(--warn); color: #6d3a08; }
.mai-drop { border-color: var(--primary-line); background: var(--primary-soft); border-radius: var(--radius); }
@media (max-width: 640px) { .mai-dialog { inset: 0; width: 100dvw; height: 100dvh; border-radius: 0; } }

/* ───────────────────────── list tables: approved row height ───────────────────────── */
#page-dashboard td, #page-reports td, #page-users td, #page-audit td, #page-worker-requests td, #page-scaffolding-reports td { height: var(--row); }

/* ───────────────────────── phones: dialogs rise from the bottom (approved bottom sheet) ───────────────────────── */
@media (max-width: 640px) {
  .modal-overlay { align-items: flex-end; }
  .modal-overlay > .modal:not(.modal-xl):not([class*="-modal"]) { width: 100%; max-width: 100%; border-radius: 14px 14px 0 0; max-height: 92vh; }
}

/* ───────────────────────── Worker Performance / Meckano module (.wp-*, .mai-*) ───────────────────────── */
.wp-sheet { color: var(--text); font-size: var(--fs-body); font-family: var(--font); }
.wp-dialog { border: 0; border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(15, 26, 43, .35); padding: var(--pad); }
.wp-dialog::backdrop { background: rgba(15, 26, 43, .45); }
.wp-sheet h2 { font-size: 18px; font-weight: 700; }
.wp-sheet h3 { font-size: 14px; font-weight: 600; }
.wp-sheet .wp-muted { color: var(--muted); font-size: 12.5px; }
.wp-sheet button, .wp-sheet input, .wp-sheet select { min-height: var(--ctl); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13.5px; }
.wp-sheet button.wp-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.wp-sheet button.wp-primary:hover { background: var(--primary-hover); }
.wp-sheet th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: var(--fs-th); border-bottom: 1px solid var(--border-strong); }
.wp-sheet td { border-bottom-color: var(--line); }
.wp-sheet label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.wp-sheet .wp-warning { background: var(--warn-soft); border-inline-start-color: #e0a21a; border-radius: var(--radius-sm); color: #6d3a08; }
.wp-sheet .wp-subtotal { background: var(--primary-soft); border-top-color: var(--primary-line); }
.wp-sheet .wp-positive { color: var(--ok); } .wp-sheet .wp-attention { color: var(--warn); }
.wp-visual-settings { border-color: var(--border); border-radius: var(--radius); background: var(--surface); }
#worker-cost-settings { padding: var(--pad); }
@media (max-width: 640px) { .wp-sheet button, .wp-sheet input, .wp-sheet select { min-height: 44px; } .wp-dialog { padding: 14px; } }
html[dir="ltr"] .modal-close { left: auto; right: 14px; }
html[dir="ltr"] .modal h2 { padding-left: 0; padding-right: 44px; }
html[dir="ltr"] .fin-explain-popover, html[dir="ltr"] .employee-performance-tooltip { direction: ltr; text-align: left; }
html[dir="ltr"] .employee-performance-days { direction: ltr; }
html[dir="ltr"] select, html[dir="ltr"] input[type=date], html[dir="ltr"] .form-group input, html[dir="ltr"] .form-group select, html[dir="ltr"] .form-group textarea, html[dir="ltr"] .fin-v2-partner-debit { direction: ltr; }
html[dir="ltr"] .employee-detail-head .employee-heading p { text-align: left; }
html[dir="ltr"] .back-btn { text-align: left; }

/* ───────────────────────── Phone refinements: Reports filters + shared navigation ───────────────────────── */
@media (max-width: 640px) {
  /* Reports: compact two-column filter grid; long controls (project, worker, export) span both columns */
  #page-reports .table-toolbar { padding: 10px; gap: 8px; min-height: 0; margin-bottom: 8px; }
  #page-reports .table-toolbar h2 { display: none; }
  #page-reports .table-toolbar .filters { gap: 8px; }
  #page-reports .table-toolbar .filters > * { grid-column: auto; min-height: 44px; }
  #page-reports .table-toolbar .filters > .btn:first-child, #page-reports #f-project, #page-reports #f-worker, #page-reports .filters:has(#f-hidden:not([style*="none"])) #f-status { grid-column: 1 / -1; }
  #page-reports .table-toolbar .filters > select, #page-reports .table-toolbar .filters > input { text-overflow: ellipsis; padding-inline: 10px; }
  #page-reports .table-toolbar .filters > .btn { justify-content: center; white-space: normal; line-height: 1.2; }
  #page-reports #scaffold-simple-panel { padding: 10px 12px !important; }
  #page-reports #scaffold-simple-panel h3 { margin-bottom: 6px !important; }
}

/* Shared mobile navigation: the primary destinations share the row equally (no sideways scrolling, no cut-off labels);
   everything else lives in "More". */
@media (max-width: 760px) {
  #sidebar-facade, #sidebar-scaffold, #sidebar-global { overflow: visible; }
  #sidebar-facade:not([style*="display: none"]), #sidebar-scaffold:not([style*="display: none"]), #sidebar-global:not([style*="display: none"]) { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(min-content, 1fr); }
  .nav-item { flex: initial; min-width: 0; padding: 0 3px; text-align: center; white-space: normal; justify-content: center; align-items: center; flex-wrap: wrap; row-gap: 0; column-gap: 3px; }
  .nav-item > span:not(.nav-badge) { font-size: 13px; line-height: 1.15; overflow-wrap: normal; word-break: keep-all; }
  .topnav-more-button { min-width: 0; width: 54px; padding: 0 4px; font-size: 13px; }
  .sidebar-nav { grid-template-columns: minmax(0, 1fr) 54px; }
}
@media (max-width: 380px) { .nav-item > span:not(.nav-badge) { font-size: 12.5px; } }
@media (max-width: 640px) {
  /* report card header: the status pill may wrap to two lines instead of being cut off (long ru/en labels) */
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) { grid-template-columns: auto minmax(78px, 1fr) minmax(0, max-content); }
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(9) > * { white-space: normal; max-width: 100%; overflow: visible; text-overflow: clip; text-align: center; line-height: 1.2; }
}
@media (max-width: 640px) { #page-reports #scaffold-simple-panel h3 { font-size: 14px; } #page-reports #scaffold-simple-panel > h3 + * { font-size: 13px; } }
@media (max-width: 640px) {
  /* report card: the photo row centres label and thumbnail so the label is never cut by the actions divider */
  #reports-tbody tr:not(.empty-row):not(.batch-group-row) td:nth-child(10) { align-items: center; padding-block: 6px; }
  #reports-tbody td:nth-child(11) { margin-top: 8px; }
}

/* Reports: load-failure state (error message + retry), distinct from the empty-results state */
.reports-load-error { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 12px; color: var(--bad); font-weight: 500; text-align: center; }
.reports-load-error .btn { min-height: var(--ctl); color: var(--text); }
@media (max-width: 640px) { table.rt-cards tr.error-row { border-color: var(--bad-line); background: var(--bad-soft); } .reports-load-error .btn { min-width: 160px; min-height: 44px; } }
/* empty / error rows hold free-form content: they must not inherit the fixed list-row height */
#reports-tbody tr.empty-row td { height: auto; }
.reports-load-error .btn { background: var(--surface); border-color: var(--border-strong); }

/* Long translated routing labels need their own line beside the full-width phone control. */
@media (max-width: 640px) {
  #owner-wa-flow-card > .setting-row { flex-direction: column; align-items: stretch; }
  #owner-wa-flow-select { width: 100%; min-width: 0; }
}

/* ───────────────────────── Building grid on phones: compact sticky identifiers + touch-sized work cells ───────────────────────── */
@media (max-width: 640px) {
  /* checkbox + type + number are sticky: 244px (JS widths 36+112+96) left ~86px of a 360px screen for the work columns.
     Keep all three sticky and readable but narrower: 38+66+60 = 164px. */
  #building-excel-table th.excel-selector-cell, #building-excel-table td.excel-selector-cell { width: 38px; min-width: 38px; max-width: 38px; padding-inline: 0; text-align: center; }
  #building-excel-table .excel-selector-cell input { width: 24px; height: 24px; min-height: 24px; margin: 0; }
  #building-excel-table th[data-col="section_type"], #building-excel-table td[data-col="section_type"] { inset-inline-start: 38px; width: 66px; min-width: 66px; max-width: 66px; padding-inline: 6px; }
  /* The compact type cell already has padding; avoid clipping translated read-only labels. */
  #building-excel-table td[data-col="section_type"] .excel-base-readonly { padding-inline: 0; }
  #building-excel-table th[data-col="section_number"], #building-excel-table td[data-col="section_number"] { inset-inline-start: 104px; width: 60px; min-width: 60px; max-width: 60px; padding-inline: 6px; }
  #building-excel-table th, #building-excel-table td { height: 52px; }
  .excel-cell-btn, .excel-cell-btn.is-qty, .excel-cell-btn.is-empty { min-width: 48px; min-height: 44px; }
  .excel-cell-btn.is-empty { border-color: var(--border-strong); color: var(--primary); background: var(--surface); }
}
@media (max-width: 640px) { .modal-close { width: 44px; height: 44px; top: 8px; left: 8px; font-size: 16px; } html[dir="ltr"] .modal-close { left: auto; right: 8px; } .modal h2 { padding-inline-end: 0; } }
@media (max-width: 640px) {
  /* the transient save toast must never swallow taps meant for the grid underneath, and must fit the screen */
  .excel-work-toast { pointer-events: none; left: 12px !important; right: 12px !important; bottom: 12px !important; max-width: none !important; }
}
/* phone building grid: the work columns are off-screen until the grid is swiped sideways - say so */
.grid-scroll-hint { display: none; }
@media (max-width: 640px) { .grid-scroll-hint { display: block; margin: 0; padding: 8px 14px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 500; border-top: 1px solid var(--line); } }

/* phone building grid: the Notes column is hidden (less clutter, less sideways scrolling). The section note stays reachable
   and editable from the work dialog (button below). Desktop is untouched. */
.excel-section-notes-btn { display: none; }
@media (max-width: 640px) {
  #building-excel-table th[data-col="notes"], #building-excel-table td[data-col="notes"] { display: none; }
  #building-excel-table { min-width: 1090px; }
  #excel-work-section-notes { display: flex; width: 100%; min-height: 44px; justify-content: center; margin: -4px 0 14px; }
}

/* ───────────────────────── Mobile Reports fixes (production iPhone report) ───────────────────────── */
/* 1) Card cells are display:flex on phones, where `height` is a hard height (in a real table it only acts as a minimum).
      The list-row height (48px) therefore clipped the wrapped action row of owner cards, which then spilled over the next card. */
@media (max-width: 640px) {
  #page-dashboard table.rt-cards td, #page-reports table.rt-cards td, #page-users table.rt-cards td, #page-audit table.rt-cards td,
  #page-worker-requests table.rt-cards td, #page-scaffolding-reports table.rt-cards td { height: auto; min-height: var(--row); }
  #reports-tbody td:nth-child(11) .action-btns { gap: 8px; }
  #reports-tbody td:nth-child(11) .action-btns .btn { white-space: normal; overflow-wrap: anywhere; }
}
/* 2) iOS paints an empty date input blank: show the "all dates" label (placeholder attribute) until a date is chosen. */
@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  #f-date { position: relative; }
  html[dir="ltr"] #f-date { direction: ltr !important; }
  html[dir="rtl"] #f-date { direction: rtl !important; }
  #f-date.is-empty:not(:focus)::before { content: attr(placeholder); color: var(--muted); flex: 1 1 auto; align-self: center; text-align: start; white-space: nowrap; }
  #f-date.is-empty:not(:focus)::-webkit-datetime-edit, #f-date.is-empty:not(:focus)::-webkit-date-and-time-value { display: none; }
}

/* a status pill whose label wraps (long ru/en labels in a narrow card) grows with its text instead of spilling out of its background */
@media (max-width: 640px) { table.rt-cards .pill { height: auto; min-height: 24px; padding-block: 4px; text-align: start; } }
