/* =========================================================
   ФондПульс — design tokens
   ========================================================= */
:root {
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-muted: #f6f8fc;
  --surface-hover: #eef2fb;

  --text: #16192b;
  --text-muted: #667085;
  --text-faint: #97a1b6;

  --border: #e3e7f0;
  --border-strong: #cbd3e5;

  --primary: #3457ea;
  --primary-dark: #2540bd;
  --primary-soft: #eaf0ff;

  --success: #17924f;
  --success-soft: #e4f7ec;
  --success-border: #b7e6cb;

  --warning: #b76e00;
  --warning-soft: #fef3e0;
  --warning-border: #f5d999;

  --danger: #d13438;
  --danger-dark: #a8262a;
  --danger-soft: #fdeaea;
  --danger-border: #f3c3c4;

  --info: #0284c7;
  --info-soft: #e0f4fd;
  --info-border: #b7e6f8;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 10px 26px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 44px rgba(16, 24, 40, .12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================================
   Reset & base
   ========================================================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
h1 { margin: 0 0 8px; }
h2 { margin: 0 0 12px; }
p { margin: 0 0 8px; }
table { border-collapse: collapse; width: 100%; }

::selection { background: var(--primary-soft); color: var(--primary-dark); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft), 0 0 0 1.5px var(--primary);
  border-radius: var(--radius-sm);
}

/* =========================================================
   Layout
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 16px;
  text-decoration: none;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand-mark {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6c8bff);
  color: #fff;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 15px; height: 15px; }
.topnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.topnav a, .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .12s ease, color .12s ease;
}
.topnav a:hover, .link-button:hover { background: var(--surface-hover); color: var(--text); }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: transparent; cursor: pointer; font-family: inherit; }

.container { width: min(1120px, calc(100% - 32px)); margin: 24px auto 64px; }
.page-narrow { max-width: 720px; margin-left: auto; margin-right: auto; }

/* =========================================================
   Cards & headings
   ========================================================= */
.hero, .page-head, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.hero { padding: 36px; margin-bottom: 20px; }
.hero h1, .page-head h1 { margin: 0 0 8px; font-size: clamp(28px, 4.6vw, 44px); }
.hero p, .page-head p { margin: 0; color: var(--text-muted); }
.eyebrow {
  margin: 0 0 8px !important;
  display: inline-flex;
  text-transform: uppercase;
  color: var(--primary) !important;
  letter-spacing: .08em;
  font-size: 11.5px;
  font-weight: 800;
}
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 24px 28px; margin-bottom: 20px; }
.card { padding: 22px; }
.card.narrow { width: min(420px, 100%); margin: 64px auto; }
.success { border-color: var(--success-border); }
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 13.5px;
}
.error-text { color: var(--danger); font-weight: 600; }

/* =========================================================
   Buttons & form controls
   ========================================================= */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s ease, transform .06s ease;
}
.button:hover { background: var(--primary-dark); }
.button:active { transform: translateY(1px); }
.button.secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong); }
.button.secondary:hover { background: var(--surface-hover); border-color: var(--text-faint); }
.button.danger { background: var(--danger); }
.button.danger:hover { background: var(--danger-dark); }

select, input[type="month"], input[type="date"], input[type="password"], input[type="number"], input[type="text"] {
  min-height: 42px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s ease;
}
select:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.login-form { display: grid; gap: 16px; }
.login-form label, .tool-form label, .report-filter-form label { display: grid; gap: 6px; color: var(--text-muted); font-size: 12px; font-weight: 700; }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* =========================================================
   Department select
   ========================================================= */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.dept-card {
  position: relative;
  display: block;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.dept-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow-md); }
.dept-code { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.dept-meta { display: block; margin-top: 4px; color: var(--text-muted); font-size: 13px; }

/* =========================================================
   Department dashboard (date tabs)
   ========================================================= */
.tabs-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 28px; }
.date-tab {
  position: relative;
  display: grid;
  align-content: center;
  min-height: 100px;
  padding: 18px 20px 18px 24px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.date-tab:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-md); }
.date-tab::before { content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 4px; border-radius: 999px; background: var(--primary); }
.date-tab strong { display: block; margin-bottom: 8px; font-size: 18px; line-height: 1.15; letter-spacing: -.01em; color: var(--text); }
.date-tab small { display: inline-flex; width: fit-content; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); color: var(--text-muted); font-size: 12px; font-weight: 600; }
.locked-list { display: flex; flex-wrap: wrap; gap: 8px; }
.locked-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
}
.locked-pill::before {
  content: '';
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--success);
}

/* =========================================================
   Entry form (data entry — optimised for touch)
   ========================================================= */
.container { margin: 16px auto 56px; }
.page-head.entry-page-head { padding: 18px 22px; margin-bottom: 14px; }
.page-head.entry-page-head h1 { margin-bottom: 0; font-size: clamp(24px, 4.2vw, 36px); }
.page-head.entry-page-head .eyebrow { margin-bottom: 6px !important; }

.entry-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.entry-progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
.entry-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #6c8bff);
  transition: width .25s ease;
}
.entry-progress-fill.is-complete { background: linear-gradient(90deg, var(--success), #37c477); }
.entry-progress-label {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.entry-form { display: grid; gap: 12px; }
.entry-section { padding: 6px; }
.entry-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
}
.entry-section-title { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.entry-section-count {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.entry-section-count.is-complete { background: var(--success-soft); color: var(--success); }

.entry-list { display: grid; gap: 8px; }
.entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  transition: border-color .15s ease, background .15s ease;
}
.entry-row.is-filled { border-color: var(--success-border); background: var(--success-soft); }
.entry-row-label { min-width: 0; flex: 1; font-size: 14.5px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.entry-row-fields { display: flex; gap: 8px; flex-shrink: 0; }
.entry-field { display: grid; justify-items: center; gap: 4px; }
.entry-field span { color: var(--text-muted); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
input.num-input {
  width: 60px;
  min-height: 44px;
  padding: 4px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
input.num-input::-webkit-outer-spin-button, input.num-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
input.num-input { -moz-appearance: textfield; }
input.num-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 15;
  padding: 14px 0 4px;
  margin-top: 4px;
  background: linear-gradient(transparent, var(--bg) 40%);
}
.entry-actions { align-items: center; gap: 10px 12px; }
.entry-action-note { color: var(--text-muted); font-size: 12.5px; line-height: 1.3; }

/* =========================================================
   Admin tools
   ========================================================= */
.admin-tools { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.tool-form { display: flex !important; align-items: end; gap: 12px; flex-wrap: wrap; }
.danger-form { align-items: center; padding-left: 18px; border-left: 1px solid var(--border); }
.danger-form div { display: grid; gap: 2px; }
.danger-form strong { color: var(--danger); }
.danger-form small { max-width: 360px; color: var(--text-muted); }

/* =========================================================
   Admin summary table
   ========================================================= */
.admin-sheet { margin-bottom: 34px; }
.admin-sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 0 0 12px; flex-wrap: wrap; }
.admin-sheet-head h2 { margin: 0; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend span {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 30px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-muted);
  font-size: 12px; font-weight: 700;
}
.dot { width: 11px; height: 11px; border: 1px solid rgba(22,25,43,.14); border-radius: 999px; }
.dot.empty { background: #fff; }
.dot.missed { background: var(--danger-soft); border-color: var(--danger-border); }
.dot.partial { background: var(--warning-soft); border-color: var(--warning-border); }
.dot.filled { background: var(--success-soft); border-color: var(--success-border); }
.dot.zero { background: var(--info-soft); border-color: var(--info-border); }

.admin-table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
th, td { border: 1px solid var(--border); }
th { background: var(--surface-muted); }

.admin-summary-table { min-width: 980px; table-layout: fixed; font-size: 12px; }
.admin-summary-table th, .admin-summary-table td { padding: 0; text-align: center; vertical-align: middle; }
.admin-summary-table thead th { position: sticky; top: 0; z-index: 3; height: 38px; padding: 8px 10px; font-weight: 800; }
.admin-summary-table th:first-child { position: sticky; left: 0; z-index: 4; width: 104px; padding: 8px 10px; text-align: left; white-space: nowrap; }
.admin-summary-table tbody th:first-child { background: var(--surface-muted); font-variant-numeric: tabular-nums; font-weight: 700; }
.admin-summary-table td { height: 52px; min-width: 74px; }
.status-empty { background: #fff; }
.status-missed { background: var(--danger-soft); }
.status-partial { background: var(--warning-soft); }
.status-filled { background: var(--success-soft); }
.status-zero { background: var(--info-soft); }
.admin-progress {
  display: inline-flex !important; align-items: center; justify-content: center;
  min-width: 40px; min-height: 26px; margin: 0 auto;
  border-radius: 999px; color: var(--text); font-size: 12px; font-weight: 800;
  text-decoration: none; font-variant-numeric: tabular-nums;
  transition: background .12s ease;
}
.admin-progress:hover { background: rgba(255,255,255,.7); }
.lock-form { display: inline-flex; margin: 3px 0 0; }
.lock-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 26px; padding: 0;
  border: 1px solid rgba(22,25,43,.12); border-radius: 9px;
  background: rgba(255,255,255,.75); color: var(--text);
  cursor: pointer; transition: background .12s ease;
}
.lock-button:hover { background: #fff; }
.lock-button:disabled { opacity: .55; cursor: wait; }
.admin-summary-table td.is-updating { opacity: .7; }
.lock-icon { position: relative; display: inline-block; width: 13px; height: 13px; border: 1.7px solid currentColor; border-radius: 3px; }
.lock-icon::before { content: ''; position: absolute; width: 8px; height: 7px; border: 1.7px solid currentColor; border-bottom: 0; border-radius: 7px 7px 0 0; background: transparent; }
.lock-icon.locked::before { left: 1px; top: -8px; }
.lock-icon.unlocked::before { left: -5px; top: -8px; transform: rotate(-32deg); transform-origin: right bottom; }

/* =========================================================
   Reports
   ========================================================= */
.report-filter-form { display: grid; gap: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, max-content)); align-items: end; gap: 12px; }
.department-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.check-pill:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.check-pill input { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.report-filter-actions { display: flex; justify-content: flex-end; gap: 10px; }

.report-table { min-width: 980px; font-size: 12px; border-collapse: separate; border-spacing: 0; }
.report-table th, .report-table td { padding: 6px 8px; text-align: center; vertical-align: middle; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.col-indicator, .report-table td:first-child {
  position: sticky; left: 0; z-index: 2;
  width: 25ch; min-width: 25ch; max-width: 25ch;
  background: var(--surface); white-space: nowrap; text-align: left;
}
.report-table thead th[colspan="2"] { position: sticky; top: 0; z-index: 3; background: var(--surface-muted); font-weight: 800; min-width: 88px; padding-bottom: 4px; }
.report-table thead th.sticky-col { z-index: 30; }
.report-table thead tr:nth-child(2) th { font-size: 11.5px; font-weight: 700; color: var(--text-muted); }
.total-group { background: var(--primary-soft); font-weight: 700; width: 56px; min-width: 56px; }
.report-table th:not(.col-indicator):not(.total-group), .report-table td:not(:first-child):not(.total-group) { width: 44px; min-width: 44px; }
.report-table .report-row-category td, .report-table .report-row-category td:first-child { background: var(--success-soft); font-weight: 800; }
.report-table .report-row-total td, .report-table .report-row-total td:first-child { background: var(--primary-soft); font-weight: 900; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 860px) {
  .entry-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
  .admin-tools { display: grid; }
  .danger-form { padding-top: 16px; padding-left: 0; border-top: 1px solid var(--border); border-left: 0; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  .topnav { gap: 2px; }
  .container { width: min(100% - 20px, 1120px); margin-top: 14px; }
  .page-head { align-items: flex-start; flex-direction: column; padding: 20px; }
  .page-head.entry-page-head { padding: 16px; }
  .actions-row, .tool-form, .report-filter-actions { display: grid !important; grid-template-columns: 1fr; width: 100%; }
  .button, .actions-row form, .actions-row form .button { width: 100%; }
  .dept-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-tab { min-height: 88px; padding: 16px 18px 16px 22px; }
  .date-tab strong { font-size: 17px; }

  .entry-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .entry-row-fields { justify-content: stretch; }
  .entry-field { flex: 1; }
  input.num-input { width: 100%; min-height: 48px; font-size: 17px; }
  .entry-action-note { display: block; }
}
@media print {
  .topbar, .page-head, .sticky-actions, .report-filter-card, .entry-progress { display: none !important; }
  body { background: #fff; }
  .container { width: 100%; margin: 0; }
}
