/* odeX shared UI — design tokens + layout shell. Do not duplicate per view. */
:root {
  --ink: #111827;
  --muted: #6b7280;
  --paper: #f6f7fb;
  --paper-soft: #f9fafb;
  --card: #ffffff;
  --line: #e5e7eb;
  --orange: #f47a1f;
  --orange-dark: #df6814;
  --orange-soft: #fff4eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar: #18202b;
  --sidebar-text: #cbd5e1;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --control-h: 44px;
  --header-h: 56px;
  --sidebar-w: 13rem;
  --sidebar-w-collapsed: 4.35rem;
  --ease: 180ms ease;
  --livedate-h: 2.25rem;
  --focus: 0 0 0 3px rgba(244, 122, 31, 0.28);
}

html { color-scheme: light; }
body {
  margin: 0;
  background: var(--paper) !important;
  color: var(--ink);
  font-family: "Source Sans 3", Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}
h1, .page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2, .section-head h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.015em; }
h3, .section-head h3 { font-size: 16px; font-weight: 650; }
.muted, .brand-slogan { color: var(--muted); }

/* Upload telefonu — jeden widoczny stan dla wszystkich formularzy. */
.upload-status {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 500;
  width: min(380px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(15, 23, 42, .22);
}
.upload-status.hidden { display: none; }
.upload-status.busy { border-color: #fdba74; }
.upload-status.success { border-color: #86efac; background: #f0fdf4; }
.upload-status.error { border-color: #fca5a5; background: #fef2f2; }
.upload-status-row { display: flex; align-items: center; gap: 9px; }
.upload-status-row b { flex: 1; overflow-wrap: anywhere; }
.upload-status-icon {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 999px;
  color: #fff;
  background: var(--orange);
  font-weight: 800;
}
.upload-status.success .upload-status-icon { background: var(--green); }
.upload-status.error .upload-status-icon { background: var(--red); }
.upload-progress { height: 6px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #e5e7eb; }
.upload-progress i { display: block; height: 100%; border-radius: inherit; background: var(--orange); transition: width .18s ease; }

/* P0 — jedno centrum działania i czytelny stan usług. */
.action-center { border-top: 3px solid var(--orange); }
.action-center-head,
.system-status-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.action-center-head h2,
.action-center-head p,
.system-status-head h3,
.system-status-head p { margin-top: 0; }
.action-urgent,
.system-state {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}
.action-urgent,
.system-state.error { color: #991b1b; background: #fee2e2; }
.system-state.warning { color: #92400e; background: #fef3c7; }
.system-state.ok { color: #166534; background: #dcfce7; }
.system-state.off { color: #475569; background: #e2e8f0; }
.action-list { display: grid; gap: 8px; }
.action-item {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.action-item:hover { border-color: #fdba74; background: #fffaf5; }
.action-indicator,
.system-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }
.action-item.danger .action-indicator,
.system-service.error .system-dot { background: var(--red); }
.action-item.info .action-indicator { background: #2563eb; }
.system-service.ok .system-dot { background: var(--green); }
.system-service.off .system-dot { background: #94a3b8; }
.action-label { min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.action-label small { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; }
.action-count { min-width: 2rem; text-align: center; font-size: 17px; }
.action-open { color: var(--orange-dark); font-weight: 700; white-space: nowrap; }
.action-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 12px 14px;
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
}
.action-empty span { display: grid; place-items: center; width: 26px; height: 26px; color: #fff; background: var(--green); border-radius: 50%; }
.screen-loading {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}
.screen-loading small { color: var(--muted); font-size: 12px; }
.screen-loading-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #fed7aa;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: ordex-screen-spin .75s linear infinite;
}
@keyframes ordex-screen-spin { to { transform: rotate(360deg); } }
.system-status-card.compact { padding-top: 14px; padding-bottom: 14px; }
.system-services { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.system-service {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px 11px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.system-service-state { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.system-actions { align-items: center; margin-top: 12px; }

@media (max-width: 700px) {
  .action-center-head,
  .system-status-head { align-items: center; }
  .action-item { grid-template-columns: 9px minmax(0, 1fr) auto; }
  .action-open { grid-column: 2 / 4; font-size: 13px; }
  .system-services { grid-template-columns: 1fr; }
  .system-actions .muted { flex-basis: 100%; }
}

/* ── Header ── */
.top {
  background: #ffffff !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: var(--shadow);
  min-height: var(--header-h);
  padding: 8px 16px !important;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}
.top .brand { color: var(--ink) !important; }
.top .brand-slogan { color: var(--muted) !important; max-width: 12rem; }
.top .brand-mark { width: 36px; height: 36px; border-radius: 9px; }
.live-date {
  flex: 1;
  text-align: center;
  font-family: "Source Sans 3", Inter, sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted) !important;
}
#sidebar-toggle {
  color: var(--ink) !important;
  background: transparent !important;
  border: 1px solid var(--line) !important;
  min-height: 36px;
  min-width: 36px;
  padding: 4px !important;
  border-radius: 8px;
}
#sidebar-toggle:hover { background: var(--paper-soft) !important; }
body:has(#app-view.hidden) #sidebar-toggle { display: none !important; }

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-soft);
}
.userbox.is-admin {
  border-color: #fdba74;
  background: var(--orange-soft);
  box-shadow: inset 0 0 0 1px rgba(244, 122, 31, 0.15);
}
.userbox .btn.ghost,
.userbox .btn.ghost.btn-ghost {
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  background: #fff !important;
  padding: 6px 10px !important;
  font-size: 13px;
}

.lang-dd { position: relative; }
.lang-dd > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  min-height: 32px;
}
.lang-dd > summary::-webkit-details-marker { display: none; }
.lang-dd[open] > summary { border-color: var(--orange); color: var(--orange); }
.lang-dd-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 10.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
  display: grid;
  gap: 2px;
}
.lang-dd-menu button {
  background: transparent !important;
  color: var(--ink) !important;
  border: 0 !important;
  text-align: left;
  padding: 8px 10px !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.lang-dd-menu button:hover { background: var(--paper-soft) !important; }
.lang-dd-menu button.active {
  background: var(--orange-soft) !important;
  color: var(--orange) !important;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
  max-width: var(--sidebar-w) !important;
  flex: 0 0 var(--sidebar-w) !important;
  background: var(--sidebar) !important;
  color: #fff;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  transition: width var(--ease), min-width var(--ease), max-width var(--ease), flex-basis var(--ease), left var(--ease);
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 10px 10px;
}
.sidebar-collapse {
  margin-left: auto;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.sidebar-collapse:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar-collapse svg { width: 16px; height: 16px; transition: transform var(--ease); }
body.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.sidebar-mobile-close { display: none; }
.nav-empty { color: #94a3b8; font-size: 13px; line-height: 1.4; padding: 12px 10px; margin: 0; }
.nav-group-label {
  margin: 12px 10px 4px;
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
}
.nav-group-label:first-child { margin-top: 4px; }
.nav-main-label {
  margin: 4px 10px 7px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.nav-primary { display: grid; gap: 2px; }
.nav-more {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, .18);
}
.nav-more > summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: #94a3b8;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  list-style: none;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: "⌄"; margin-left: auto; transition: transform var(--ease); }
.nav-more[open] > summary::after { transform: rotate(180deg); }
.nav-more > summary:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-more-count {
  min-width: 22px;
  padding: 2px 6px;
  color: #cbd5e1;
  background: rgba(148, 163, 184, .16);
  border-radius: 999px;
  font-size: 10px;
  text-align: center;
}
.nav-more-items { display: grid; gap: 2px; padding-top: 3px; }

#nav { padding: 4px 8px 12px; gap: 2px; }
#nav button {
  min-height: 40px;
  padding: 8px 10px !important;
  border-radius: 10px !important;
  color: var(--sidebar-text) !important;
  background: transparent !important;
  font-weight: 600 !important;
  font-size: 13.5px !important;
  transition: background var(--ease), color var(--ease);
}
#nav button:hover {
  background: rgba(255, 255, 255, 0.07) !important;
  color: #fff !important;
}
#nav button.active,
#nav button.active.bg-accent {
  background: rgba(244, 122, 31, 0.16) !important;
  color: #f47a1f !important;
}
#nav button.active svg { color: #f47a1f; }
#nav button svg { width: 1.25rem; height: 1.25rem; flex: 0 0 1.25rem; }
.sidebar-copyright {
  color: #64748b;
  font-size: 10px;
  padding: 10px 12px 14px;
}

body.sidebar-collapsed #sidebar {
  width: var(--sidebar-w-collapsed) !important;
  min-width: var(--sidebar-w-collapsed) !important;
  max-width: var(--sidebar-w-collapsed) !important;
  flex-basis: var(--sidebar-w-collapsed) !important;
}
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-copyright span,
body.sidebar-collapsed #nav button .nav-label {
  display: none !important;
}
body.sidebar-collapsed .sidebar-copyright { padding: 8px; text-align: center; }
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .nav-main-label,
body.sidebar-collapsed .nav-more > summary span { display: none; }
body.sidebar-collapsed #nav button { justify-content: center; padding: 8px !important; gap: 0 !important; }
body.sidebar-collapsed .nav-more > summary { justify-content: center; padding: 8px; }
body.sidebar-collapsed .nav-more > summary::before { content: "•••"; letter-spacing: 1px; }
body.sidebar-collapsed .nav-more > summary::after { display: none; }
body.sidebar-collapsed .sidebar-head { justify-content: center; padding: 12px 6px; }
body.sidebar-collapsed .sidebar-head .brand-mark { display: none; }
body.sidebar-collapsed .sidebar-collapse { margin: 0 auto; }

.app-shell-body {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100dvh - var(--header-h));
}
.app-main,
#app-view > .flex > main {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--paper) !important;
  padding: 20px 22px;
}
#mfa-grace-banner {
  margin: 12px 22px 0;
}
.app-footer {
  background: var(--paper-soft) !important;
  color: var(--muted) !important;
  border-top: 1px solid var(--line) !important;
  font-size: 11px;
  padding: 10px 16px;
}

/* ── Cards / KPI ── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat b { font-size: 22px; font-weight: 700; }
.stat.kpi small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.pay-match b, .pay-match { color: var(--green); }
.stat.pay-mismatch b, .pay-mismatch { color: var(--amber); }
.today-banner {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--orange);
}
.today-banner b { color: var(--ink); }

/* ── Buttons ── */
.tabs button, .btn, button.btn {
  background: var(--orange);
  color: #fff;
  border: 1px solid transparent;
  padding: 9px 14px;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 600;
  transition: background var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.tabs button:hover, .btn:hover, button.btn:hover { background: var(--orange-dark); }
.tabs button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.tabs button.active {
  background: var(--orange-soft);
  color: var(--orange);
  border-color: #fdba74;
}
.btn.ghost, button.btn.ghost, .btn.btn-ghost {
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}
.btn.ghost:hover, button.btn.ghost:hover { background: var(--paper-soft) !important; }
.btn.good, button.btn.good { background: var(--green); border-color: var(--green); color: #fff; }
.btn.bad, button.btn.bad,
.btn.danger-outline, button.btn.danger-outline {
  background: transparent !important;
  color: var(--red) !important;
  border: 1px solid var(--red) !important;
  box-shadow: none;
}
.btn.bad:hover, button.btn.bad:hover,
.btn.danger-outline:hover, button.btn.danger-outline:hover { background: #fef2f2 !important; }
.btn:disabled, button.btn:disabled, .btn[disabled] {
  background: #e5e7eb !important;
  color: #9ca3af !important;
  border-color: #e5e7eb !important;
  cursor: not-allowed;
}
.btn:focus-visible, button.btn:focus-visible, #nav button:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ── Forms ── */
label { color: var(--ink) !important; font-weight: 600 !important; font-size: 13px !important; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select, textarea {
  min-height: 42px;
  background: var(--paper-soft) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  color: var(--ink) !important;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange) !important;
  background: #fff !important;
}
.err { color: var(--red); font-size: 13px; }

/* ── Tables ── */
table { font-size: 14px; }
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  background: var(--paper-soft);
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper-soft);
  box-shadow: inset 0 -1px 0 var(--line);
}
tbody tr:hover td { background: #f8fafc; }
td.calc, td.num, td.money, .sheet .calc, .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sheet-wrap, .payroll-board, .disp-wrap {
  overflow: auto;
  max-width: 100%;
}
.sheet.payroll thead th.pay-stick { z-index: 5; background: var(--paper-soft); }
.sheet.payroll th.pay-stick, .sheet.payroll td.pay-stick { background: #fff; }
.sheet.payroll tfoot td.pay-stick { background: var(--orange-soft); }

.badge { font-weight: 650; letter-spacing: 0.03em; }
.q-chip.active { background: var(--orange); color: #fff; border-color: var(--orange); }

/* ── More menu ── */
.more-menu { position: relative; display: inline-flex; vertical-align: middle; }
.more-menu-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}
.more-menu-btn:hover { background: var(--paper-soft); }
.more-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 11rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
}
.more-menu.open .more-menu-list { display: grid; gap: 4px; }
.more-menu-list .btn { width: 100%; justify-content: flex-start; }

/* ── Payroll ── */
#p-stats { gap: 10px !important; margin-bottom: 12px; }
.sheet.payroll input.cell:not(:disabled) {
  background: #fffaf5 !important;
  border-color: #fed7aa !important;
}
.sheet.payroll td.calc,
.sheet.payroll .calc.pay-auto {
  background: var(--paper-soft);
  position: relative;
}
.sheet.payroll td.calc::after,
.sheet.payroll .calc.pay-auto::after {
  content: "🖩";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 11px;
  color: #9ca3af;
  pointer-events: none;
}
.pay-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  background: #fff;
}
.pay-card .pc-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 2px 0;
}
.pay-card .pc-row b { font-family: Barlow, sans-serif; }
.pay-details-row td { background: var(--paper-soft) !important; }
.pay-details-grid { transition: opacity var(--ease); }
.kpi-grid { gap: 10px !important; }
.stat.kpi { padding: 12px 14px; }
.stat.kpi b { font-size: 20px; }
.pay-acc {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.pay-acc-toggle { font-size: 13px; }

/* ── Modal ── */
.modal-panel, .cert-modal {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* ── Login ── */
#login-view .card {
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* ── Mobile drawer ── */
@media (max-width: 900px) {
  body.nav-open { overflow: hidden; }
  #sidebar {
    position: fixed;
    left: 0 !important;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: min(19rem, 88vw) !important;
    min-width: min(19rem, 88vw) !important;
    max-width: min(19rem, 88vw) !important;
    flex-basis: min(19rem, 88vw) !important;
    transform: translateX(-105%);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: none;
    transition: transform var(--ease), box-shadow var(--ease);
  }
  #sidebar.open { transform: translateX(0); box-shadow: 8px 0 28px rgba(0, 0, 0, .28); }
  body.sidebar-collapsed #sidebar {
    width: min(19rem, 88vw) !important;
    min-width: min(19rem, 88vw) !important;
    max-width: min(19rem, 88vw) !important;
    flex-basis: min(19rem, 88vw) !important;
  }
  body.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed #nav button .nav-label { display: block !important; }
  body.sidebar-collapsed .sidebar-head .brand-mark { display: block; }
  body.sidebar-collapsed #nav button { justify-content: flex-start; gap: 0.75rem !important; }
  .sidebar-collapse { display: none; }
  .sidebar-mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    cursor: pointer;
  }
  .sidebar-mobile-close svg { width: 22px; height: 22px; }
  .sidebar-head { align-items: center; padding: 12px 12px 8px; }
  #nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 10px 16px; }
  #nav button { min-height: 46px; padding: 10px 12px !important; font-size: 15px !important; }
  .sidebar-copyright { margin-top: 0; padding: 10px 14px 14px; }
  .top .brand-slogan { display: none; }
  .live-date { font-size: 12px; font-weight: 500; }
  .app-main,
  #app-view > .flex > main { padding: 16px 12px; }
  #mfa-grace-banner { margin: 10px 12px 0; }
}

@media (max-width: 640px) {
  :root { --header-h: 58px; }
  .top {
    min-height: var(--header-h);
    padding: max(7px, env(safe-area-inset-top, 0px)) 10px 7px !important;
    gap: 7px !important;
    flex-wrap: nowrap !important;
  }
  #sidebar-toggle { display: inline-flex !important; flex: 0 0 40px; width: 40px; height: 40px; }
  .top .brand { min-width: 0; gap: 7px; }
  .top .brand-mark { width: 34px; height: 34px; flex: 0 0 34px; }
  .top .brand-text strong { font-size: 16px; white-space: nowrap; }
  .live-date { display: none; }
  .lang-switch { margin-left: auto; flex: 0 0 auto; }
  .lang-dd > summary { min-height: 38px; padding: 8px 10px; }
  .lang-dd-menu { position: fixed; top: calc(var(--header-h) + 4px); right: 8px; min-width: min(12rem, calc(100vw - 16px)); }
  .userbox { border: 0; background: transparent; padding: 0; gap: 4px; }
  .userbox.is-admin { border: 0; background: transparent; box-shadow: none; }
  #session-box > div { display: none; }
  .userbox .btn.ghost,
  .userbox .btn.ghost.btn-ghost { min-height: 40px; padding: 7px 9px !important; font-size: 12px; }
  .wrap { padding: 14px 10px; }
  #login-view .card { padding: 20px 16px !important; border-radius: 14px; }
  #login-view .login-hero img { width: 84px; height: 84px; }
  .app-main,
  #app-view > .flex > main { padding: 12px 10px !important; }
  .card { padding: 14px 12px; border-radius: 11px; }
  .stat { padding: 12px; }
  .row { gap: 7px; }
  .btn { min-height: 44px; }
  input, select, textarea { min-height: 46px; font-size: 16px !important; }
  .modal-backdrop { padding: 8px; }
  .modal-panel { padding: 14px 12px; border-radius: 12px; }
}

/* P1 1.7 — role-first home screens and a short path to common work. */
.role-home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(125deg, #18202b 0%, #273548 70%, #334155 100%);
  border: 0;
}
.role-home-hero h1 { margin: 3px 0 4px; color: #fff; font-size: clamp(23px, 3vw, 32px); }
.role-home-hero p { margin: 0; color: #cbd5e1; }
.role-home-eyebrow { color: var(--orange); font-size: 11px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.role-home-date { flex: 0 0 auto; padding: 8px 12px; color: #e2e8f0; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 999px; font-size: 13px; font-weight: 700; text-transform: capitalize; }
.role-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.role-kpi {
  min-height: 118px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.role-kpi:hover { border-color: #fdba74; transform: translateY(-1px); }
.role-kpi > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.role-kpi > b { font-family: Barlow, sans-serif; font-size: 23px; overflow-wrap: anywhere; }
.role-kpi > small { color: var(--muted); }
.role-kpi.is-live { border-color: #86efac; background: #f0fdf4; }
.role-kpi.has-warning { border-color: #fdba74; background: #fff7ed; }
.role-quick-card { padding-top: 17px; }
.role-quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.role-quick-action {
  min-height: 70px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  color: var(--ink);
  text-align: left;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.role-quick-action:hover { border-color: var(--orange); background: var(--orange-soft); }
.role-quick-icon { display: grid; place-items: center; width: 38px; height: 38px; color: var(--orange-dark); background: #fff; border: 1px solid #fed7aa; border-radius: 10px; font-size: 20px; font-weight: 800; }
.role-quick-action b, .role-quick-action small { display: block; }
.role-quick-action small { margin-top: 3px; color: var(--muted); }
.role-quick-arrow { color: var(--orange-dark); font-size: 24px; }
.role-event-list { display: grid; gap: 7px; }
.role-event { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; }
.role-event > span, .role-event > small { color: var(--muted); }
.dashboard-more > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.dashboard-more > summary::-webkit-details-marker { display: none; }
.dashboard-more > summary b, .dashboard-more > summary small { display: block; }
.dashboard-more > summary small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.dashboard-more-toggle { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; color: var(--orange-dark); background: var(--orange-soft); border-radius: 999px; font-size: 20px; transition: transform var(--ease); }
.dashboard-more[open] .dashboard-more-toggle { transform: rotate(45deg); }
.dashboard-more-body { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.dashboard-more-body > .card { margin: 12px 0 0; box-shadow: none; }

@media (max-width: 960px) {
  .role-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .role-home-hero { align-items: flex-start; flex-direction: column; gap: 12px; }
  .role-home-date { font-size: 12px; }
  .role-kpi-grid, .role-quick-grid { grid-template-columns: 1fr; }
  .role-kpi { min-height: 96px; }
  .role-event { grid-template-columns: 86px minmax(0, 1fr); }
  .role-event > small { grid-column: 2; }
}

/* ── Table → cards ── */
@media (max-width: 768px) {
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody { display: block; width: 100%; }
  .stack-table tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  .stack-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border: 0;
    padding: 6px 0;
  }
  .stack-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 42%;
  }
  .stack-table td:empty { display: none; }
  .sheet.payroll.stack-table,
  .payroll-board .sheet.payroll {
    min-width: 0 !important;
  }
  .sheet.payroll .pay-stick { position: static !important; box-shadow: none !important; left: auto !important; }
  .wide-table { min-width: 640px; }
}

.receipts-table.ocr-low,
.receipts-table tr.ocr-low {
  background: #fff7ed;
}
.receipts-table-wrap { max-width: 100%; overflow-x: auto; padding-bottom: 4px; }
.receipts-admin-table { min-width: 1060px; }
.receipts-admin-table th:last-child,
.receipts-admin-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  box-shadow: -8px 0 12px -12px rgba(15, 23, 42, .45);
}
.receipts-admin-table tr.ocr-low td:last-child { background: #fff7ed; }
.receipt-actions-cell { min-width: 235px; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.receipt-actions .btn { min-height: 34px; padding: 6px 9px !important; font-size: 11px; white-space: nowrap; }
.receipt-missing { color: var(--red); font-weight: 700; white-space: nowrap; }
.receipt-review-hint { max-width: 15rem; margin-top: 4px; color: var(--red); font-size: 11px; line-height: 1.25; }
.receipt-file-preview img { border: 1px solid var(--line); }

/* Projects workspace */
.project-page-head,
.project-detail-head,
.project-address-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.project-page-head { margin-bottom: 14px; }
.project-page-head h2,
.project-detail-title h2 { margin: 0; }
.project-page-head p,
.project-detail-title p { margin: 3px 0 0; }
.project-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.project-kpi-grid .stat { min-width: 0; }
.project-kpi-grid .stat b { overflow-wrap: anywhere; }
.project-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(150px, 1fr) minmax(140px, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.project-toolbar label { display: block; margin-bottom: 4px; }
.project-result-count { min-width: 74px; text-align: center; padding: 7px 10px; }
.project-result-count span { display: block; color: var(--muted); font-size: 11px; }
.project-result-count b { font-size: 20px; }
.project-list { display: grid; gap: 10px; margin-bottom: 16px; }
.project-list-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) minmax(420px, 2fr) 28px;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 15px 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-list-card:hover {
  border-color: var(--orange);
  box-shadow: 0 7px 20px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
}
.project-list-card.is-finished { background: var(--paper-soft); opacity: .82; }
.project-list-main { display: grid; gap: 4px; min-width: 0; }
.project-list-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.project-list-title b { font-size: 17px; }
.project-list-kpis { display: grid; grid-template-columns: repeat(5, minmax(76px, 1fr)); gap: 8px; }
.project-list-kpis > span { min-width: 0; padding-left: 9px; border-left: 1px solid var(--line); }
.project-list-kpis small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.project-list-kpis b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.project-list-kpis .loss b { color: var(--red); }
.project-list-kpis .profit b { color: var(--green); }
.project-open-arrow { color: var(--orange); font-size: 30px; text-align: right; }
.project-create > summary { cursor: pointer; font-family: Barlow, sans-serif; font-weight: 800; font-size: 18px; }
.project-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 12px;
}
.project-form-grid label { display: block; margin-bottom: 4px; }
.project-billing-edit { margin-top: 14px; }
.project-detail-head { margin-bottom: 12px; }
.project-detail-title { flex: 1; min-width: 0; }
.project-address-row { margin-bottom: 12px; padding: 12px 16px; }
.project-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 6px;
  scrollbar-width: thin;
}
.project-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.project-tabs button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.project-tab-panel { min-width: 0; }
.project-team-list { display: grid; gap: 8px; }
.project-team-row,
.project-remark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.project-team-row:last-child,
.project-remark:last-child { border-bottom: 0; }
.project-team-add,
.project-remark-add { margin-top: 14px; }
.project-team-add select,
.project-remark-add input { flex: 1; min-width: 180px; }
.project-remark { align-items: flex-start; }
.project-remark small { display: block; color: var(--muted); margin-top: 2px; }
.project-remark p { margin: 5px 0 0; white-space: pre-wrap; }
.project-activity { display: grid; gap: 0; }
.project-activity > div { border-left: 2px solid var(--line); padding: 0 0 14px 14px; margin-left: 6px; }
.project-activity time { color: var(--muted); font-size: 11px; }
.project-activity p { margin: 3px 0 0; }
.project-notes { white-space: pre-wrap; }
.worker-project-list { display: grid; gap: 9px; }
.worker-project-card {
  width: 100%;
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: inherit;
}
.worker-project-main { display: grid; gap: 4px; min-width: 0; }
.worker-project-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-project-meta { display: grid; justify-items: end; gap: 6px; flex: 0 0 auto; }
.project-mobile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.project-worker-hero h2 { margin-top: 0; }
.project-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-worker-info { margin-top: 0; }
.project-alerts { display: grid; gap: 8px; margin: 0 0 14px; }
.project-alert {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid #bfdbfe;
  border-radius: 11px; background: #eff6ff; color: var(--ink); padding: 10px 12px;
  text-align: left; font: inherit; cursor: pointer;
}
.project-alert.warning { border-color: #fed7aa; background: #fff7ed; }
.project-alert.danger { border-color: #fecaca; background: #fef2f2; }
.tab-count { opacity: .72; font-size: 11px; margin-left: 3px; }
.project-progress { height: 8px; border-radius: 99px; overflow: hidden; background: var(--paper-soft); margin: 10px 0 16px; }
.project-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s; }
.project-task-create { align-items: end; padding: 12px; border-radius: 12px; background: var(--paper-soft); margin-bottom: 12px; }
.project-task-add { align-self: end; }
.project-task-list, .project-document-list, .project-checklist, .project-invoice-lines { display: grid; gap: 8px; }
.project-task, .project-document, .project-invoice-line {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.project-task.overdue { border-left: 4px solid var(--red); }
.project-task.done { opacity: .68; background: var(--paper-soft); }
.project-task.done .project-task-main > b { text-decoration: line-through; }
.project-task-main, .project-document > div, .project-invoice-line > div { display: grid; gap: 5px; min-width: 0; }
.project-task-main p { margin: 0; white-space: pre-wrap; }
.project-task-main small, .project-document small, .project-invoice-line small { color: var(--muted); overflow-wrap: anywhere; }
.project-task-actions, .project-document-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.project-document.archived { opacity: .55; }
.project-forecast { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.project-forecast > div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-soft); }
.project-forecast span, .project-forecast b { display: block; }
.project-forecast span { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.project-finance-table { min-width: 980px; }
.project-finance-table .loss, .project-forecast .loss b { color: var(--red); font-weight: 800; }
.project-finance-table .profit, .project-forecast .profit b { color: var(--green); font-weight: 800; }
.project-check-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.project-check-item input { width: 22px; height: 22px; }
.project-check-item span { display: grid; gap: 3px; }
.project-check-item small { color: var(--muted); }
.project-check-item em { color: var(--muted); font-style: normal; font-size: 20px; }
.project-check-item.done { border-color: #bbf7d0; background: #f0fdf4; }
.project-check-item.done em { color: var(--green); }
.calendar-filters { align-items: end; margin-bottom: 12px; }
.calendar-filter-actions { display: flex; gap: 7px; align-self: end; }
.cal-day-cell[onclick], .cal-day[onclick] { cursor: pointer; }
.cal-day-cell[onclick]:hover, .cal-day[onclick]:hover { outline: 2px solid rgba(234, 88, 12, .16); outline-offset: -2px; }

@media (max-width: 900px) {
  .project-list-card { grid-template-columns: minmax(190px, 1fr) minmax(300px, 1.6fr) 22px; gap: 10px; }
  .project-list-kpis { grid-template-columns: repeat(3, minmax(76px, 1fr)); }
}

@media (max-width: 768px) {
  .project-page-head { align-items: flex-start; }
  .project-page-head .btn { min-height: 44px; }
  .project-toolbar { grid-template-columns: 1fr 1fr; }
  .project-toolbar > div:first-child { grid-column: 1 / -1; }
  .project-result-count { align-self: stretch; display: grid; align-content: center; }
  .project-list-card { grid-template-columns: 1fr 18px; padding: 13px; }
  .project-list-main { grid-column: 1; }
  .project-list-kpis { grid-column: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 6px; }
  .project-list-kpis > span { padding: 6px 8px; border: 0; border-radius: 8px; background: var(--paper-soft); }
  .project-open-arrow { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .project-form-grid { grid-template-columns: 1fr; }
  .project-detail-head { align-items: flex-start; flex-wrap: wrap; }
  .project-detail-head .project-detail-title { order: 3; flex-basis: 100%; }
  .project-address-row { align-items: flex-start; flex-direction: column; }
  .project-address-row .btn { width: 100%; }
  .project-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-kpi-grid .stat { padding: 11px; }
  .project-kpi-grid .stat b { font-size: 16px; }
  .project-tabs { margin-left: -4px; margin-right: -4px; }
  .project-tabs button { min-height: 44px; }
  .project-team-row,
  .project-remark { align-items: stretch; flex-direction: column; }
  .project-team-row .btn,
  .project-remark .btn { width: 100%; min-height: 42px; }
  .project-team-add,
  .project-remark-add { flex-direction: column; }
  .project-team-add .btn,
  .project-remark-add .btn { width: 100%; }
  .worker-project-card { min-height: 76px; }
  .project-quick-actions .btn { flex: 1 1 130px; min-height: 46px; }
  .project-alert { align-items: flex-start; }
  .project-task, .project-document, .project-invoice-line { align-items: stretch; flex-direction: column; }
  .project-task-actions, .project-document-actions { width: 100%; flex-wrap: wrap; }
  .project-task-actions > *, .project-document-actions > * { flex: 1 1 120px; min-height: 44px; }
  .project-task-create { padding: 10px; }
  .project-task-add .btn { width: 100%; min-height: 44px; }
  .project-forecast { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-check-item { align-items: start; }
  .calendar-filter-actions { grid-column: 1 / -1; }
  .calendar-filter-actions .btn { flex: 1; min-height: 44px; }
  .receipts-admin-table { min-width: 0; }
  .receipts-admin-table th:last-child,
  .receipts-admin-table td:last-child { position: static; box-shadow: none; background: transparent; }
  .receipt-actions-cell { min-width: 0; }
  .receipt-actions { width: 100%; justify-content: flex-start; }
  .receipt-actions .btn { flex: 1 1 9rem; min-height: 44px; }
}

/* Weekly hours report wizard */
.ss-wrap { position: relative; }
.ss-input {
  width: 100%;
  min-height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
}
.ss-list {
  position: absolute;
  z-index: 20;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
}
.ss-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  min-height: 44px;
}
.ss-opt small { display: block; color: var(--muted); font-size: 12px; }
.ss-opt:hover { background: var(--orange-soft); }
.ss-empty { padding: 12px; color: var(--muted); }
.hrw-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; font-size: 12px; }
.hrw-step { color: var(--muted); }
.hrw-step.on { color: var(--orange); font-weight: 700; }
.hrw-summary { margin: 0 0 12px; font-size: 13px; }
.hrw-warn {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}
.hrw-check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.hrw-pdf { width: 100%; min-height: 360px; border: 1px solid var(--line); border-radius: 10px; }
.hrw-panel { max-width: 760px; width: min(760px, 96vw); }
.hrw-sign { border: 1px dashed var(--line); border-radius: 8px; background: #fff; width: 100%; max-width: 360px; }
.req { color: var(--orange); font-size: 11px; font-weight: 700; }
.hidden-adv { display: none; }
.hws-card { border-left: 4px solid var(--orange); }
.hws-period-nav { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 10px 0 14px; }
.hws-period-nav > b { text-align: center; font-size: 14px; }
.hws-list { display: grid; gap: 10px; }
.hws-person { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: #fff; }
.hws-person.locked { border-left: 4px solid var(--green); }
.hws-person.returned { border-left: 4px solid var(--red); background: #fffafa; }
.hws-person-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hws-person-head small { display: block; color: var(--muted); margin-top: 2px; }
.hws-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0; font-size: 13px; }
.hws-issues { margin: 8px 0; padding-left: 20px; font-size: 13px; }
.hws-issues li { margin: 3px 0; }
.hws-issues li.bad { color: var(--red); }
.hws-issues li.warn { color: var(--amber); }
.hws-actions { margin-top: 10px; }
.fin-quality { border-left: 4px solid var(--green); }
.fin-quality.warn { border-left-color: var(--amber); }
.fin-quality.bad { border-left-color: var(--red); }
.fin-quality-list { display: grid; gap: 6px; }
.fin-quality-list .alert { margin: 0; }
@media (max-width: 768px) {
  .hrw-panel { max-width: 100%; }
  .hrw-steps { font-size: 11px; }
  .hws-period-nav { grid-template-columns: 1fr 1fr; }
  .hws-period-nav > b { grid-column: 1 / -1; grid-row: 1; }
  .hws-period-nav .btn { white-space: normal; }
  .hws-person { padding: 12px; }
  .hws-actions .btn { flex: 1 1 10rem; }
}

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

/* Keep every navigation button fully rounded on desktop and mobile. */
#nav {
  width: 100% !important;
  box-sizing: border-box !important;
}
#nav button {
  align-self: center;
  width: calc(100% - 2px) !important;
  max-width: calc(100% - 2px) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

/* A visible, comfortable menu button on phones. */
@media (max-width: 640px) {
  #sidebar-toggle {
    background: var(--orange) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 12px !important;
    box-shadow: 0 3px 10px rgba(244, 122, 31, .28);
  }
  #sidebar-toggle:hover { background: var(--orange-dark) !important; }
  #sidebar-toggle svg { color: currentColor !important; }
}


/* Payroll v3 — compact strip + table, no laptop H-scroll */
.pay-v3-card { overflow-x: hidden; }
.payroll-board.payroll-v3 { overflow-x: hidden; }
.pay-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.pay-strip-item {
  flex: 1 1 150px;
  padding: 10px 14px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.pay-strip-item:last-child { border-right: 0; }
.pay-strip-item span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.pay-strip-item b { display: block; text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; }
.pay-strip-item small { display: block; text-align: right; color: var(--muted); font-size: 11px; }
.pay-strip-pay b { color: var(--orange); }
.sheet.payroll.payroll-compact { table-layout: fixed; width: 100%; min-width: 0 !important; }
.sheet.payroll.payroll-compact th,
.sheet.payroll.payroll-compact td { text-align: right; vertical-align: top; padding: 8px 6px; }
.sheet.payroll.payroll-compact th:first-child,
.sheet.payroll.payroll-compact td.pay-name { text-align: left; }
.pay-row-empty { opacity: 0.72; }
.pay-row-norate td { background: #fff7ed; }
.pay-auto-tag { display: inline-block; font-size: 10px; font-weight: 700; color: var(--muted); margin-right: 4px; }
.pay-match { color: var(--green); }
.pay-mismatch { color: var(--amber); }
.pay-card .pc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.pay-status-SUMMARY { background: #eef2ff; color: #4338ca; }

/* Payroll 1.5 — one clear workflow, with week/cycle/month previews. */
.pay-simple-header { padding-bottom: 12px; }
.pay-section-tabs,
.pay-mode-switch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-soft);
}
.pay-section-tabs button,
.pay-mode-switch button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 7px 14px;
}
.pay-section-tabs button.active,
.pay-mode-switch button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}
.pay-section-tabs button.active { color: var(--orange-dark); }
.pay-simple-control-card { position: relative; }
.pay-simple-topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.pay-worker-search { width: min(290px, 100%); }
.pay-worker-search span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.pay-worker-search input { width: 100%; }
.pay-period-nav {
  display: grid;
  grid-template-columns: 44px minmax(220px, 1fr) 44px;
  align-items: stretch;
  gap: 8px;
  margin: 14px 0 8px;
}
.pay-period-nav > .btn { min-width: 44px; font-size: 25px; padding: 0; }
.pay-period-label {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  padding: 9px 14px;
  text-align: center;
}
.pay-period-label b { display: block; font-family: Barlow, sans-serif; font-size: 16px; }
.pay-period-label small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.pay-mode-hint { margin: 6px 0 12px; }
.pay-primary-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-primary-actions .btn:first-child { background: var(--orange); color: #fff; }
.pay-primary-actions .btn:nth-child(2) { background: var(--green); color: #fff; border-color: var(--green); }
.pay-primary-actions .btn:disabled { background: #e5e7eb; border-color: #e5e7eb; color: #9ca3af; }
.pay-accounting-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--line);
}
.pay-accounting-label {
  margin-right: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.payroll-cashflow-legacy { margin-top: 14px; }
.pay-advanced { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.pay-advanced > summary { color: var(--muted); cursor: pointer; font-weight: 700; }
.pay-advanced[open] > summary { color: var(--ink); margin-bottom: 8px; }
.pay-card-details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.pay-card-details .pay-details-grid { display: grid; gap: 7px; }
.pay-card-details .pay-details-grid > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pay-card-details .pay-details-grid span { color: var(--muted); font-size: 12px; }
.pay-card-details .pay-details-grid b { text-align: right; }
.pay-history-table { overflow-x: auto; }
.pay-history-table .sheet { min-width: 680px; width: 100%; }
.pay-history-table td small { display: block; }
.pay-history-cards { display: none; gap: 10px; }
.pay-history-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; border: 1px solid var(--line); border-radius: 11px; padding: 12px; }
.pay-history-card small { display: block; color: var(--muted); }
.pay-history-card strong { color: var(--orange-dark); }

/* Worker history 1.5.1 — one month navigator for pay and personal reports. */
.worker-month-nav {
  display: grid;
  grid-template-columns: 44px minmax(210px, 1fr) 44px;
  align-items: stretch;
  gap: 8px;
  margin: 14px 0;
  max-width: 560px;
}
.worker-month-nav > .btn { min-width: 44px; padding: 0; font-size: 21px; }
.worker-month-nav > .btn:disabled { cursor: not-allowed; opacity: .42; }
.worker-month-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 7px 5px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.worker-month-picker span { font-family: Barlow, sans-serif; font-weight: 800; text-transform: capitalize; }
.worker-month-picker input { width: 145px; min-height: 32px; padding: 4px 7px; border-radius: 7px; }
.worker-month-empty { margin: 14px 0 0; }

/* Wynagrodzenie pracownika: jeden równy blok okresu, godzin i wypłaty. */
.worker-pay-month {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 1fr) minmax(150px, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.worker-pay-month > label,
.worker-pay-month > div {
  display: flex;
  min-width: 0;
  min-height: 74px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.worker-pay-month input { width: 100%; min-width: 0; margin: 0; }
.worker-pay-month b { color: var(--ink); font-size: 17px; overflow-wrap: anywhere; }
.worker-report-stats { margin-top: 14px; }
.worker-report-projects,
.worker-report-entries { display: grid; gap: 8px; }
.worker-report-project,
.worker-report-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}
.worker-report-project small,
.worker-report-entry small { display: block; color: var(--muted); margin-top: 2px; }
.worker-report-project > div:last-child,
.worker-report-entry-result { text-align: right; }
.worker-report-entry-result { display: grid; justify-items: end; gap: 4px; }
.worker-report-project strong,
.worker-report-entry strong { font-family: Barlow, sans-serif; font-size: 16px; }

/* Documents 1.5.2 — one simple register, progressive upload and mobile cards. */
.docs-hero .section-head { margin: 0; }
.docs-title-row { align-items: center; gap: 16px; }
.docs-title-row h2 { margin: 0; }
.docs-title-row p { margin: 4px 0 0; max-width: 48rem; }
.docs-add-button { flex: 0 0 auto; }
.docs-notice { margin-bottom: 14px; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

.docs-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.docs-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: left;
  font: inherit;
}
button.docs-summary-item { cursor: pointer; transition: border-color var(--ease), background var(--ease), transform var(--ease); }
button.docs-summary-item:hover { border-color: #fdba74; transform: translateY(-1px); }
.docs-summary-item.active { border-color: var(--orange); background: var(--orange-soft); box-shadow: inset 0 0 0 1px rgba(244, 122, 31, .13); }
.docs-summary-item.warning { border-left: 4px solid var(--amber); }
.docs-summary-item.danger { border-left: 4px solid var(--red); }
.docs-summary-item span { color: var(--muted); font-size: 13px; font-weight: 650; }
.docs-summary-item b { font-family: Barlow, sans-serif; font-size: 24px; }

.docs-add-card,
.docs-tools-card { scroll-margin-top: calc(var(--header-h) + 12px); }
.docs-add-card > summary,
.docs-tools-card > summary,
.docs-missing-card > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  list-style: none;
  cursor: pointer;
}
.docs-add-card > summary::-webkit-details-marker,
.docs-tools-card > summary::-webkit-details-marker,
.docs-missing-card > summary::-webkit-details-marker,
.docs-advanced > summary::-webkit-details-marker,
.document-more > summary::-webkit-details-marker { display: none; }
.docs-add-card > summary::after,
.docs-tools-card > summary::after {
  content: "+";
  flex: 0 0 auto;
  color: var(--orange);
  font-size: 24px;
  font-weight: 700;
}
.docs-add-card[open] > summary::after,
.docs-tools-card[open] > summary::after { content: "−"; }
.docs-add-card summary b,
.docs-tools-card summary b,
.docs-missing-card summary b { display: block; font-family: Barlow, sans-serif; font-size: 17px; }
.docs-add-card summary small,
.docs-tools-card summary small,
.docs-missing-card summary small { display: block; color: var(--muted); margin-top: 2px; }
.docs-add-body,
.docs-tools-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.docs-add-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.docs-add-steps span { padding: 8px 10px; border-radius: 9px; background: var(--orange-soft); color: var(--orange-dark); font-size: 12px; font-weight: 700; text-align: center; }
.docs-add-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.docs-add-grid label { display: block; margin-bottom: 5px; }
.docs-add-wide { grid-column: 1 / -1; }
.docs-upload-help { margin: 6px 0 0; font-size: 12px; }
.docs-upload-button { min-width: 12rem; }
.docs-advanced { margin: 14px 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-soft); }
.docs-advanced > summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.docs-advanced[open] > summary { margin-bottom: 8px; }
.docs-tools-body > .card { box-shadow: none; margin-bottom: 10px; }
.docs-missing-card { background: var(--paper-soft); }
.docs-gap-list { display: grid; gap: 7px; max-height: 26rem; overflow: auto; margin-top: 12px; }
.docs-gap-list .alert { margin: 0; }

.docs-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(3, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.docs-toolbar label { display: block; margin-bottom: 4px; }
.docs-search-field input { width: 100%; }
.docs-result-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.docs-result-head > b { color: var(--muted); font-size: 13px; }
.docs-result-head .btn { min-height: 34px; padding: 5px 10px !important; font-size: 12px; }

.documents-list { display: grid; gap: 10px; }
.document-card { padding: 14px 15px; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 12px; background: #fff; }
.document-card.warning { border-left-color: var(--amber); background: #fffdfa; }
.document-card.danger { border-left-color: var(--red); background: #fffafa; }
.document-card.archived { border-left-color: #94a3b8; background: var(--paper-soft); opacity: .82; }
.document-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.document-card-title { min-width: 0; }
.document-card-title h3 { margin: 2px 0 0; overflow-wrap: anywhere; }
.document-person { display: block; color: var(--orange-dark); font-size: 13px; font-weight: 700; }
.document-card-head .chips { justify-content: flex-end; }
.document-card-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.document-card-meta > div { min-width: 0; }
.document-card-meta span { display: block; color: var(--muted); font-size: 11px; }
.document-card-meta b { display: block; margin-top: 1px; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.document-file-name { font-weight: 500 !important; }
.document-note { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--paper-soft); color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.document-card-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 7px; }
.document-card-actions > .btn,
.document-more > summary { min-height: 38px; padding: 7px 11px !important; font-size: 13px; }
.document-more { position: relative; }
.document-more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.document-more-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper-soft); }
.document-more-actions .btn { min-height: 36px; padding: 6px 10px !important; font-size: 12px; }
.docs-empty { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px; border: 1px dashed var(--line); border-radius: 11px; background: var(--paper-soft); color: var(--muted); }
.worker-docs-archive > summary .badge { margin-left: auto; }

@media (max-width: 760px) {
  .pay-strip-item { border-right: 0; border-bottom: 1px solid var(--line); flex-basis: 50%; }
  .pay-simple-header .section-head { align-items: flex-start; }
  .pay-simple-header .eur-rate-row { width: 100%; }
  .pay-section-tabs { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .pay-section-tabs button { padding-inline: 6px; }
  .pay-simple-topline { align-items: stretch; flex-direction: column; }
  .pay-mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .pay-mode-switch button { padding-inline: 6px; }
  .pay-worker-search { width: 100%; }
  .pay-period-nav { grid-template-columns: 42px minmax(0, 1fr) 42px; }
  .pay-period-label { padding-inline: 7px; }
  .pay-period-label b { font-size: 14px; overflow-wrap: anywhere; }
  .pay-period-label small { display: none; }
  .pay-primary-actions { display: grid; grid-template-columns: 1fr; }
  .pay-primary-actions .btn { width: 100%; }
  .pay-accounting-actions { align-items: stretch; flex-direction: column; }
  .pay-accounting-label { margin: 0; }
  .pay-accounting-actions .btn { width: 100%; }
  .pay-more-row { align-items: stretch; flex-direction: column; }
  .pay-more-row > * { width: 100%; }
  .pay-card .pc-grid { grid-template-columns: 1fr; }
  .pay-card .btn { margin-top: 8px; width: 100%; }
  .pay-history-table { display: none; }
  .pay-history-cards { display: grid; }
  .worker-month-nav { grid-template-columns: 42px minmax(0, 1fr) 42px; max-width: none; }
  .worker-month-picker { grid-template-columns: 1fr; gap: 4px; padding: 6px 8px; }
  .worker-month-picker span { text-align: center; font-size: 14px; }
  .worker-month-picker input { width: 100%; min-width: 0; }
  .worker-pay-month { grid-template-columns: 1fr; gap: 8px; }
  .worker-pay-month > label,
  .worker-pay-month > div { min-height: 0; padding: 12px; }
  .worker-pay-month b { font-size: 18px; }
  .worker-report-project,
  .worker-report-entry { align-items: start; padding: 11px; }
  .worker-report-project > div:last-child,
  .worker-report-entry-result { min-width: 84px; }
  .docs-title-row { align-items: stretch; flex-direction: column; }
  .docs-add-button { width: 100%; }
  .docs-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .docs-summary-item { min-height: 62px; padding: 10px 11px; }
  .docs-summary-item span { font-size: 12px; }
  .docs-summary-item b { font-size: 21px; }
  .docs-add-steps { grid-template-columns: 1fr; }
  .docs-add-steps span { text-align: left; }
  .docs-add-grid,
  .docs-toolbar { grid-template-columns: 1fr; }
  .docs-add-wide { grid-column: auto; }
  .docs-upload-button { width: 100%; }
  .docs-result-head { align-items: stretch; flex-direction: column; }
  .docs-result-head .btn { min-height: 42px; width: 100%; }
  .document-card { padding: 12px; }
  .document-card-head { flex-direction: column; }
  .document-card-head .chips { justify-content: flex-start; }
  .document-card-meta { grid-template-columns: 1fr; gap: 7px; }
  .document-card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-card-actions > .btn { width: 100%; min-height: 44px; }
  .document-more { grid-column: 1 / -1; }
  .document-more > summary { width: 100%; min-height: 44px; justify-content: center; box-sizing: border-box; }
  .document-more-actions { display: grid; grid-template-columns: 1fr; }
  .document-more-actions .btn { width: 100%; min-height: 44px; }
  .docs-empty { align-items: stretch; flex-direction: column; }
  .docs-empty .btn { width: 100%; }
}

.cf-card { overflow-x: hidden; }
.cf-sticky { position: sticky; top: 0; z-index: 4; background: var(--card, #fff); padding-bottom: 8px; }
.cf-actions { flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.cf-strip button.pay-strip-item { background: transparent; border: 0; border-right: 1px solid var(--line); cursor: pointer; text-align: left; font: inherit; }
.cf-strip button.pay-strip-item:last-child { border-right: 0; }
.cf-problems { margin: 8px 0 12px; }
.cf-alert { padding: 8px 10px; border-left: 3px solid var(--amber, #d97706); background: #fff7ed; margin-bottom: 6px; font-size: 13px; }
.cf-alert.critical { border-color: #b91c1c; background: #fef2f2; }
.cf-ready ul { margin: 8px 0 0; padding-left: 18px; }
.cf-ok { color: var(--green, #15803d); }
.cf-warn { color: #b45309; }
.cf-block { color: #b91c1c; font-weight: 600; }
.cf-table-wrap { overflow-x: auto; max-width: 100%; }
.cf-table { width: 100%; min-width: 0; table-layout: auto; }
.cf-formula { font-size: 12px; }
.cf-bal input { min-width: 0; flex: 1; }
.cf-cmp { width: auto; }
@media (max-width: 1024px) {
  .cf-table-wrap { overflow-x: auto; }
}
@media (max-width: 760px) {
  .cf-card table.cf-table { display: none; }
  .cf-card .cf-row { display: none; }
}

/* Accounting 1.6 — one monthly workflow, readable on phone and desktop. */
.accounting-table-wrap { max-width: 100%; overflow-x: auto; padding-bottom: 3px; }
.accounting-months-table { width: 100%; }
.accounting-month-row { cursor: pointer; }
.accounting-month-row:hover td { background: var(--orange-soft); }
.accounting-month-row:focus-visible { outline: 3px solid rgba(244, 122, 31, .3); outline-offset: -3px; }
.accounting-open-hint { margin: 4px 0 12px; }
.accounting-detail-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.accounting-detail-head h2 { margin: 0 0 3px; }
.accounting-detail-kpis { margin-bottom: 14px; }
.accounting-detail-kpis small { display: block; color: var(--muted); margin-top: 3px; }
.accounting-two-column { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 14px; }
.accounting-breakdown { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.accounting-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.accounting-breakdown > div:last-child { border-bottom: 0; }
.accounting-breakdown span { color: var(--muted); }
.accounting-breakdown b { font-variant-numeric: tabular-nums; }
.accounting-readiness .section-head { margin-bottom: 10px; }
.accounting-check-list { display: grid; gap: 7px; }
.accounting-check {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}
button.accounting-check { cursor: pointer; }
.accounting-check > span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; font-weight: 800; }
.accounting-check small { font-weight: 800; font-variant-numeric: tabular-nums; }
.accounting-check.bad-check { border-color: #fecaca; background: #fef2f2; }
.accounting-check.bad-check > span { background: #fee2e2; color: var(--red); }
.accounting-check.warning-check { border-color: #fed7aa; background: #fff7ed; }
.accounting-check.warning-check > span { background: #ffedd5; color: var(--amber); }
.accounting-snapshot {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--green);
  border-radius: 10px;
  background: #f0fdf4;
}
.accounting-snapshot.changed { border-color: #fdba74; border-left-color: var(--amber); background: #fff7ed; }
.accounting-month-switch { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.accounting-month-switch > div { min-width: 0; text-align: center; }
.accounting-month-switch > .btn { flex: 0 0 40px; width: 40px; padding: 0 !important; }
.accounting-close-wizard { border-top: 3px solid var(--orange); }
.accounting-wizard-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.accounting-wizard-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 64px;
  padding: 9px 10px;
  color: var(--muted);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.accounting-wizard-step > span { display: grid; place-items: center; width: 32px; height: 32px; background: #e2e8f0; border-radius: 999px; font-weight: 850; }
.accounting-wizard-step b, .accounting-wizard-step small { display: block; }
.accounting-wizard-step small { margin-top: 2px; }
.accounting-wizard-step.current { color: var(--ink); border-color: #fdba74; background: #fff7ed; }
.accounting-wizard-step.current > span { color: #fff; background: var(--orange); }
.accounting-wizard-step.done { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.accounting-wizard-step.done > span { color: #fff; background: var(--green); }
.accounting-wizard-list { margin-top: 12px; }
.accounting-wizard-list h3 { font-size: 15px; }
.accounting-wizard-item {
  width: 100%;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
  padding: 9px 11px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 9px;
  cursor: pointer;
}
.accounting-wizard-item > span { display: grid; place-items: center; width: 24px; height: 24px; color: var(--red); background: #fee2e2; border-radius: 999px; font-weight: 850; }
.accounting-wizard-item small { min-width: 24px; text-align: center; font-weight: 850; }
.accounting-wizard-item i { color: var(--orange-dark); font-size: 20px; font-style: normal; }
.accounting-wizard-ready { display: flex; align-items: center; gap: 10px; padding: 11px 13px; color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; }
.accounting-wizard-ready > span { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; color: #fff; background: var(--green); border-radius: 999px; }
.accounting-wizard-ready b, .accounting-wizard-ready small { display: block; }
.accounting-wizard-ready small { margin-top: 2px; }
.accounting-wizard-warnings, .accounting-wizard-notes { margin-top: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper-soft); }
.accounting-wizard-warnings > summary, .accounting-wizard-notes > summary { cursor: pointer; font-weight: 750; }
.accounting-wizard-warnings > div { margin-top: 7px; color: var(--muted); }
.accounting-wizard-notes textarea { margin: 8px 0; background: #fff; }
.accounting-wizard-actions { margin-top: 12px; }
.accounting-actions { margin: 10px 0 14px; }
.accounting-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}
.accounting-section > summary::-webkit-details-marker { display: none; }
.accounting-section[open] > summary { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.accounting-document-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.accounting-document-choice {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.accounting-document-choice:hover { border-color: var(--orange); background: var(--orange-soft); }
.accounting-document-choice b { font-size: 16px; }
.accounting-document-choice span { color: var(--muted); }

@media (max-width: 820px) {
  .accounting-two-column { grid-template-columns: 1fr; }
  .accounting-detail-head { grid-template-columns: auto minmax(0, 1fr); }
  .accounting-detail-head > .btn.good { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 640px) {
  .accounting-year-kpis,
  .accounting-detail-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .accounting-year-kpis .stat b,
  .accounting-detail-kpis .stat b { font-size: 17px; overflow-wrap: anywhere; }
  .accounting-detail-head { align-items: start; gap: 9px; }
  .accounting-detail-head > div { min-width: 0; }
  .accounting-detail-head h2 { font-size: 19px; }
  .accounting-month-switch { grid-column: 1 / -1; grid-row: 1; }
  .accounting-detail-head > .btn:first-child { grid-row: 2; }
  .accounting-detail-head > .btn.good { grid-row: 2; }
  .accounting-wizard-steps { grid-template-columns: 1fr; }
  .accounting-wizard-actions .btn { flex: 1 1 100%; }
  .accounting-document-choices { grid-template-columns: 1fr; }
  .accounting-months-table .accounting-open-btn { width: 100%; }
  .accounting-actions .btn { flex: 1 1 100%; }
}

/* Minimal local utility fallback: login and navigation work without external CSS. */
.hidden { display:none !important; }

/* Recovered project workspace and receipt actions. */
.receipts-table-wrap { max-width: 100%; overflow-x: auto; padding-bottom: 4px; }
.receipts-admin-table { min-width: 1060px; }
.receipts-admin-table th:last-child,
.receipts-admin-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  box-shadow: -8px 0 12px -12px rgba(15, 23, 42, .45);
}
.receipts-admin-table tr.ocr-low td:last-child { background: #fff7ed; }
.receipt-actions-cell { min-width: 235px; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.receipt-actions .btn { min-height: 34px; padding: 6px 9px !important; font-size: 11px; white-space: nowrap; }
.receipt-missing { color: var(--red); font-weight: 700; white-space: nowrap; }
.receipt-review-hint { max-width: 15rem; margin-top: 4px; color: var(--red); font-size: 11px; line-height: 1.25; }
.receipt-file-preview img { border: 1px solid var(--line); }

/* Projects workspace */
.project-page-head,
.project-detail-head,
.project-address-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.project-page-head { margin-bottom: 14px; }
.project-page-head h2,
.project-detail-title h2 { margin: 0; }
.project-page-head p,
.project-detail-title p { margin: 3px 0 0; }
.project-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.project-kpi-grid .stat { min-width: 0; }
.project-kpi-grid .stat b { overflow-wrap: anywhere; }
.project-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(150px, 1fr) minmax(140px, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.project-toolbar label { display: block; margin-bottom: 4px; }
.project-result-count { min-width: 74px; text-align: center; padding: 7px 10px; }
.project-result-count span { display: block; color: var(--muted); font-size: 11px; }
.project-result-count b { font-size: 20px; }
.project-list { display: grid; gap: 10px; margin-bottom: 16px; }
.project-list-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) minmax(420px, 2fr) 28px;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 15px 16px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-list-card:hover {
  border-color: var(--orange);
  box-shadow: 0 7px 20px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
}
.project-list-card.is-finished { background: var(--paper-soft); opacity: .82; }
.project-list-main { display: grid; gap: 4px; min-width: 0; }
.project-list-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-list-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.project-list-title b { font-size: 17px; }
.project-list-kpis { display: grid; grid-template-columns: repeat(5, minmax(76px, 1fr)); gap: 8px; }
.project-list-kpis > span { min-width: 0; padding-left: 9px; border-left: 1px solid var(--line); }
.project-list-kpis small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.project-list-kpis b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.project-list-kpis .loss b { color: var(--red); }
.project-list-kpis .profit b { color: var(--green); }
.project-open-arrow { color: var(--orange); font-size: 30px; text-align: right; }
.project-create > summary { cursor: pointer; font-family: Barlow, sans-serif; font-weight: 800; font-size: 18px; }
.project-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 12px;
}
.project-form-grid label { display: block; margin-bottom: 4px; }
.project-billing-edit { margin-top: 14px; }
.project-detail-head { margin-bottom: 12px; }
.project-detail-title { flex: 1; min-width: 0; }
.project-address-row { margin-bottom: 12px; padding: 12px 16px; }
.project-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 10px;
  margin-bottom: 6px;
  scrollbar-width: thin;
}
.project-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.project-tabs button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.project-tab-panel { min-width: 0; }
.project-team-list { display: grid; gap: 8px; }
.project-team-row,
.project-remark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.project-team-row:last-child,
.project-remark:last-child { border-bottom: 0; }
.project-team-add,
.project-remark-add { margin-top: 14px; }
.project-team-add select,
.project-remark-add input { flex: 1; min-width: 180px; }
.project-remark { align-items: flex-start; }
.project-remark small { display: block; color: var(--muted); margin-top: 2px; }
.project-remark p { margin: 5px 0 0; white-space: pre-wrap; }
.project-activity { display: grid; gap: 0; }
.project-activity > div { border-left: 2px solid var(--line); padding: 0 0 14px 14px; margin-left: 6px; }
.project-activity time { color: var(--muted); font-size: 11px; }
.project-activity p { margin: 3px 0 0; }
.project-notes { white-space: pre-wrap; }
.worker-project-list { display: grid; gap: 9px; }
.worker-project-card {
  width: 100%;
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font: inherit;
}
.worker-project-main { display: grid; gap: 4px; min-width: 0; }
.worker-project-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.worker-project-meta { display: grid; justify-items: end; gap: 6px; flex: 0 0 auto; }
.project-mobile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.project-worker-hero h2 { margin-top: 0; }
.project-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-worker-info { margin-top: 0; }
.project-alerts { display: grid; gap: 8px; margin: 0 0 14px; }
.project-alert {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid #bfdbfe;
  border-radius: 11px; background: #eff6ff; color: var(--ink); padding: 10px 12px;
  text-align: left; font: inherit; cursor: pointer;
}
.project-alert.warning { border-color: #fed7aa; background: #fff7ed; }
.project-alert.danger { border-color: #fecaca; background: #fef2f2; }
.tab-count { opacity: .72; font-size: 11px; margin-left: 3px; }
.project-progress { height: 8px; border-radius: 99px; overflow: hidden; background: var(--paper-soft); margin: 10px 0 16px; }
.project-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s; }
.project-task-create { align-items: end; padding: 12px; border-radius: 12px; background: var(--paper-soft); margin-bottom: 12px; }
.project-task-add { align-self: end; }
.project-task-list, .project-document-list, .project-checklist, .project-invoice-lines { display: grid; gap: 8px; }
.project-task, .project-document, .project-invoice-line {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.project-task.overdue { border-left: 4px solid var(--red); }
.project-task.done { opacity: .68; background: var(--paper-soft); }
.project-task.done .project-task-main > b { text-decoration: line-through; }
.project-task-main, .project-document > div, .project-invoice-line > div { display: grid; gap: 5px; min-width: 0; }
.project-task-main p { margin: 0; white-space: pre-wrap; }
.project-task-main small, .project-document small, .project-invoice-line small { color: var(--muted); overflow-wrap: anywhere; }
.project-task-actions, .project-document-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.project-document.archived { opacity: .55; }
.project-forecast { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.project-forecast > div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-soft); }
.project-forecast span, .project-forecast b { display: block; }
.project-forecast span { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.project-finance-table { min-width: 980px; }
.project-finance-table .loss, .project-forecast .loss b { color: var(--red); font-weight: 800; }
.project-finance-table .profit, .project-forecast .profit b { color: var(--green); font-weight: 800; }
.project-check-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff;
}
.project-check-item input { width: 22px; height: 22px; }
.project-check-item span { display: grid; gap: 3px; }
.project-check-item small { color: var(--muted); }
.project-check-item em { color: var(--muted); font-style: normal; font-size: 20px; }
.project-check-item.done { border-color: #bbf7d0; background: #f0fdf4; }
.project-check-item.done em { color: var(--green); }
.calendar-filters { align-items: end; margin-bottom: 12px; }
.calendar-filter-actions { display: flex; gap: 7px; align-self: end; }
.cal-day-cell[onclick], .cal-day[onclick] { cursor: pointer; }
.cal-day-cell[onclick]:hover, .cal-day[onclick]:hover { outline: 2px solid rgba(234, 88, 12, .16); outline-offset: -2px; }

@media (max-width: 900px) {
  .project-list-card { grid-template-columns: minmax(190px, 1fr) minmax(300px, 1.6fr) 22px; gap: 10px; }
  .project-list-kpis { grid-template-columns: repeat(3, minmax(76px, 1fr)); }
}

@media (max-width: 768px) {
  .project-page-head { align-items: flex-start; }
  .project-page-head .btn { min-height: 44px; }
  .project-toolbar { grid-template-columns: 1fr 1fr; }
  .project-toolbar > div:first-child { grid-column: 1 / -1; }
  .project-result-count { align-self: stretch; display: grid; align-content: center; }
  .project-list-card { grid-template-columns: 1fr 18px; padding: 13px; }
  .project-list-main { grid-column: 1; }
  .project-list-kpis { grid-column: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 6px; }
  .project-list-kpis > span { padding: 6px 8px; border: 0; border-radius: 8px; background: var(--paper-soft); }
  .project-open-arrow { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .project-form-grid { grid-template-columns: 1fr; }
  .project-detail-head { align-items: flex-start; flex-wrap: wrap; }
  .project-detail-head .project-detail-title { order: 3; flex-basis: 100%; }
  .project-address-row { align-items: flex-start; flex-direction: column; }
  .project-address-row .btn { width: 100%; }
  .project-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-kpi-grid .stat { padding: 11px; }
  .project-kpi-grid .stat b { font-size: 16px; }
  .project-tabs { margin-left: -4px; margin-right: -4px; }
  .project-tabs button { min-height: 44px; }
  .project-team-row,
  .project-remark { align-items: stretch; flex-direction: column; }
  .project-team-row .btn,
  .project-remark .btn { width: 100%; min-height: 42px; }
  .project-team-add,
  .project-remark-add { flex-direction: column; }
  .project-team-add .btn,
  .project-remark-add .btn { width: 100%; }
  .worker-project-card { min-height: 76px; }
  .project-quick-actions .btn { flex: 1 1 130px; min-height: 46px; }
  .project-alert { align-items: flex-start; }
  .project-task, .project-document, .project-invoice-line { align-items: stretch; flex-direction: column; }
  .project-task-actions, .project-document-actions { width: 100%; flex-wrap: wrap; }
  .project-task-actions > *, .project-document-actions > * { flex: 1 1 120px; min-height: 44px; }
  .project-task-create { padding: 10px; }
  .project-task-add .btn { width: 100%; min-height: 44px; }
  .project-forecast { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-check-item { align-items: start; }
  .calendar-filter-actions { grid-column: 1 / -1; }
  .calendar-filter-actions .btn { flex: 1; min-height: 44px; }
  .receipts-admin-table { min-width: 0; }
  .receipts-admin-table th:last-child,
  .receipts-admin-table td:last-child { position: static; box-shadow: none; background: transparent; }
  .receipt-actions-cell { min-width: 0; }
  .receipt-actions { width: 100%; justify-content: flex-start; }
  .receipt-actions .btn { flex: 1 1 9rem; min-height: 44px; }
}



/* Document register: readable cards without a wide mobile table. */
.documents-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.document-card { border:1px solid var(--line); border-radius:12px; padding:16px; overflow-wrap:anywhere; min-width:0; }
.document-card header { display:flex; align-items:start; justify-content:space-between; gap:10px; }
.docs-advanced { margin-top:12px; }
@media (max-width: 640px) { .documents-grid { grid-template-columns:1fr; } .accounting-months-table { display:block; overflow-x:auto; } }
