@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Manrope:wght@400;600;800&display=swap');
:root {
  --ink: #172126;
  --muted: #66737a;
  --paper: #e9edf1;
  --paper-warm: #f7f1e8;
  --panel: rgba(255,255,255,.78);
  --panel-strong: #ffffff;
  --line: #cbd6dc;
  --line-soft: #dce4e8;
  --brand: #315f70;
  --brand-deep: #203f49;
  --accent: #c08332;
  --accent-soft: #fde9c7;
  --danger: #9b3c35;
  --ok: #417a65;
  --shadow: 0 28px 80px rgba(52, 69, 78, .16);
  --radius-xl: 10px;
  --radius-md: 18px;
}
* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: clip; }
body {
  margin: 0;
  min-height: 100%;
  overflow-x: clip;
  color: var(--ink);
  font-family: Manrope, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.88) 0 220px, transparent 420px),
    radial-gradient(circle at 92% 12%, rgba(210,226,233,.9) 0 260px, transparent 500px),
    linear-gradient(120deg, var(--paper), var(--paper-warm));
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { min-height: 100vh; max-width: 100%; overflow-x: clip; }
.side {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 22px 34px 16px;
  background: rgba(236, 242, 245, .78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(189, 204, 212, .75);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 22px;
  align-items: center;
}
.brand {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 42px;
  line-height: .86;
  letter-spacing: -.045em;
  color: var(--brand-deep);
}
.brand small {
  display: block;
  margin-top: 8px;
  font-family: Manrope, sans-serif;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; min-width: 0; }
.nav a, .nav button, .nav summary {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255,255,255,.68);
  border: 1px solid rgba(197, 210, 216, .88);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(52,69,78,.05);
}
.nav a:hover, .nav button:hover, .nav summary:hover { text-decoration: none; transform: translateY(-1px); }
.nav form { margin: 0; }
.nav button { font: inherit; cursor: pointer; }
.nav a.active, .nav-menu.active > summary, .nav-menu[open] > summary {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: #f7fbfc;
}
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; user-select: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(197, 210, 216, .96);
  border-radius: 10px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 22px 54px rgba(52,69,78,.18);
}
.nav-dropdown a, .nav-dropdown button {
  width: 100%;
  min-height: 36px;
  justify-content: flex-start;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
}
.nav-dropdown a.active {
  background: #dfecf2;
  border-color: transparent;
  color: var(--brand-deep);
}
.nav-dropdown form { width: 100%; }
.nav-menu-note {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}
.userline {
  grid-column: 1 / -1;
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.main { width: 100%; max-width: 1800px; min-width: 0; margin: 0 auto; padding: 34px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; min-width: 0; }
.topbar > * { min-width: 0; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
h1 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(42px, 6vw, 68px);
  line-height: .86;
  letter-spacing: -.045em;
  color: var(--brand-deep);
}
h2 { margin: 0 0 14px; font-size: 22px; letter-spacing: -.02em; }
h3, h4 { letter-spacing: -.02em; }
.muted { color: var(--muted); }
.btn {
  border: 0;
  border-radius: 10px;
  background: var(--brand-deep);
  color: white;
  padding: 11px 16px;
  font-weight: 800;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: Manrope, sans-serif;
  box-shadow: 0 14px 32px rgba(32,63,73,.18);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.warn { background: var(--accent); color: #241606; }
.grid { display: grid; gap: 18px; min-width: 0; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  min-width: 0;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid rgba(201, 214, 221, .9);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.metric { font-size: 42px; font-weight: 800; letter-spacing: -.06em; color: var(--brand-deep); }
.toolbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search { display: flex; gap: 8px; flex: 1; min-width: 280px; max-width: 100%; }
input, select, textarea, .form-control, .form-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 11px 13px;
  background: rgba(255,255,255,.88);
  color: var(--ink);
  font: inherit;
  outline: none;
}
select:not([multiple]):not(.flatpickr-monthDropdown-months) {
  height: 46px;
  min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(49,95,112,.12); }
.form-select option { white-space: normal; }
input[type="checkbox"] { width: auto; min-width: 18px; height: 18px; padding: 0; accent-color: var(--brand-deep); }
.form-check-input { width: 18px; min-width: 18px; height: 18px; padding: 0; display: inline-block; vertical-align: middle; }
textarea { resize: vertical; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border-radius: 10px; -webkit-overflow-scrolling: touch; }
.table-wrap::before { display: none; }
.table-wrap table { width: 100%; min-width: 680px; border-collapse: collapse; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 13px 15px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: rgba(222, 232, 237, .82);
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.45); }
.pill { display: inline-flex; align-items: center; border-radius: 999px; background: #dfecf2; color: var(--brand); padding: 5px 10px; font-size: 12px; font-weight: 800; }
.pill.warn { background: var(--accent-soft); color: #875313; }
.pill.danger { background: #f2d6d2; color: var(--danger); }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 24px; }
.field-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.field-value { margin-top: 5px; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; min-width: 0; }
.form-row.full { grid-column: 1 / -1; }
.errorlist { color: var(--danger); margin: 6px 0; padding-left: 18px; }
.empty { padding: 20px; color: var(--muted); background: rgba(255,255,255,.58); border: 1px dashed var(--line); border-radius: 22px; }
.message-stack { margin-bottom: 18px; }
.message-stack .card { padding: 13px 16px; }
.audit-banner {
  margin-bottom: 18px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(192, 131, 50, .42);
  background: linear-gradient(135deg, rgba(253, 233, 199, .92), rgba(255,255,255,.82));
}
.audit-banner strong { color: #6f4210; }
.audit-banner .audit-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pagination { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.pagination .page-state { color: var(--muted); font-weight: 800; }
.error-page { max-width: 760px; margin: 0 auto; text-align: center; }
.error-page h1 { margin-bottom: 16px; }
@media (max-width: 1050px) {
  .side { grid-template-columns: 1fr; }
  .nav { justify-content: flex-start; }
  .userline { text-align: left; }
  .grid.cards { grid-template-columns: 1fr 1fr; }
  .detail, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .side { position: static; padding: 12px 14px; gap: 10px; }
  .main { padding: 18px 12px; }
  .topbar { display: block; }
  .topbar .btn, .topbar a.btn { margin-top: 10px; }
  .topbar-actions { justify-content: flex-start; margin-top: 10px; }
  .topbar .topbar-actions .btn, .topbar .topbar-actions a.btn { margin-top: 0; }
  .grid.cards { grid-template-columns: 1fr; }
  .search { min-width: 100%; flex-wrap: wrap; }
  .brand { font-size: 30px; }
  .brand small { margin-top: 5px; font-size: 9px; letter-spacing: .12em; }
  .nav { gap: 6px; }
  .nav a, .nav button, .nav summary { min-height: 34px; padding: 7px 10px; font-size: 12px; }
  .nav-dropdown {
    position: static;
    min-width: 100%;
    margin-top: 6px;
    box-shadow: none;
  }
  .userline { margin-top: 0; font-size: 11px; }
  .card { padding: 16px; border-radius: 22px; }
  .metric { font-size: 34px; }
  h1 { font-size: clamp(34px, 12vw, 46px); overflow-wrap: anywhere; }
  h2 { overflow-wrap: anywhere; }
  .table-wrap {
    border: 1px solid rgba(201, 214, 221, .9);
    background: rgba(255,255,255,.62);
  }
  .table-wrap::before {
    content: "Прокрутите таблицу вбок, чтобы увидеть все столбцы →";
    display: block;
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 100%;
    padding: 9px 12px;
    color: var(--muted);
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
    font-weight: 800;
  }
}

/* Shared layout utilities replacing template-level inline styles. */
.m-0 { margin: 0; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-22 { margin-top: 22px; }
.mb-4 { margin-bottom: 4px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-18 { margin-bottom: 18px; }
.mb-24 { margin-bottom: 24px; }
.ml-10 { margin-left: 10px; }
.position-relative { position: relative; }
.cursor-pointer { cursor: pointer; }
.align-center { align-items: center; }

.flex-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.flex-actions--compact { gap: 8px; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.form-actions--nowrap { flex-wrap: nowrap; }
.form-actions--centered { align-items: center; }

.center-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.stack-14 {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inline-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.workflow-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-single { grid-template-columns: 1fr; }
.metric-26 { font-size: 26px; }
.metric-28 { font-size: 28px; }
.metric-32 { font-size: 32px; }

.btn.btn-danger {
  background: var(--danger);
}

.contract-tree-item {
  padding: 14px;
  border: 1px solid #dde3ea;
  border-radius: 8px;
  background: #fff;
}

.heading-reset { margin: 0; }
.row-current { background: #f4f8fb; }

.hierarchy-scroll {
  margin: 0 0 18px;
  overflow-x: auto;
}

.hierarchy-row {
  display: flex;
  align-items: center;
  min-width: max-content;
  gap: 8px;
  font-size: 14px;
}

.subcontractors-block--embedded {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #dde3ea;
}

.heading-sm { font-size: 18px; }

.login-card {
  position: relative;
  max-width: 560px;
  margin: 34px auto 0;
  overflow: hidden;
}

.login-decoration {
  position: absolute;
  inset: auto -80px -120px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(192, 131, 50, .16);
}

.login-eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.login-title {
  margin-bottom: 18px;
  font-size: clamp(46px, 7vw, 78px);
}

.login-sso-button {
  width: 100%;
  min-height: 48px;
  justify-content: center;
}

.login-error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #c96565;
  border-radius: 5px;
  background: #fff5f5;
  color: #7f2020;
}

.login-admin-details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.login-admin-details summary {
  width: fit-content;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.login-admin-details summary:focus-visible {
  outline: 3px solid rgba(35, 96, 112, .28);
  outline-offset: 4px;
}

.login-local-form {
  margin-top: 18px;
}

/* Personalized dashboard */
.dashboard-subtitle { margin: 12px 0 0; }
.dashboard-create-actions .btn { min-height: 46px; }
.dashboard-create-actions svg { width: 19px; height: 19px; flex: 0 0 19px; }
.dashboard-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 5px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.dashboard-tab {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.dashboard-tab:hover { background: rgba(255, 255, 255, .64); color: var(--ink); }
.dashboard-tab.active { background: var(--brand-deep); color: #fff; }
.dashboard-tab:focus-visible,
.dashboard-kpi:focus-visible,
.dashboard-action-row:focus-visible {
  outline: 3px solid rgba(192, 131, 50, .58);
  outline-offset: 2px;
}
.dashboard-panel[hidden] { display: none; }
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.dashboard-kpi {
  min-width: 0;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  box-shadow: 0 16px 38px rgba(52,69,78,.09);
}
.dashboard-kpi:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.dashboard-kpi span { color: var(--muted); font-size: 14px; font-weight: 600; }
.dashboard-kpi strong { color: var(--brand-deep); font-size: 38px; line-height: 1; }
.dashboard-kpi small { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.dashboard-kpi--danger { border-left: 5px solid var(--danger); }
.dashboard-kpi--danger strong { color: var(--danger); }
.dashboard-kpi-money { font-size: 24px !important; overflow-wrap: anywhere; }
.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  margin-top: 30px;
}
.dashboard-section { min-width: 0; }
.dashboard-section--spaced { margin-top: 30px; }
.dashboard-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.dashboard-section-heading h2 { margin: 2px 0 0; }
.dashboard-section-heading > a { flex: 0 0 auto; font-size: 13px; font-weight: 800; }
.dashboard-eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.dashboard-action-list { border-top: 1px solid var(--line); }
.dashboard-action-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}
.dashboard-action-row:hover { background: rgba(255,255,255,.48); text-decoration: none; }
.dashboard-action-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #dfecf2;
  color: var(--brand-deep);
}
.dashboard-action-icon svg { width: 18px; height: 18px; }
.dashboard-action-copy { min-width: 0; display: grid; gap: 4px; }
.dashboard-action-copy strong,
.dashboard-action-copy small { overflow-wrap: anywhere; }
.dashboard-action-copy small { color: var(--muted); }
.dashboard-table { table-layout: auto; }

@media (max-width: 1050px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-columns { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .dashboard-header { margin-bottom: 14px; }
  .dashboard-create-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-create-actions .btn { justify-content: center; margin-top: 0 !important; padding: 10px 12px; }
  .dashboard-tabs { margin-right: -12px; margin-left: -12px; padding-right: 12px; padding-left: 12px; }
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-kpi { min-height: 112px; padding: 14px; }
  .dashboard-kpi strong { font-size: 31px; }
  .dashboard-kpi-money { font-size: 18px !important; }
  .dashboard-action-row { grid-template-columns: 36px minmax(0, 1fr); }
  .dashboard-action-row > .pill { grid-column: 2; justify-self: start; }
  .dashboard-section-heading { align-items: start; }
}

@media (max-width: 390px) {
  .dashboard-kpis { grid-template-columns: 1fr; }
  .dashboard-kpi { min-height: 96px; }
}
