/* Command-center theme shared by every authenticated and public screen. */
:root {
  color-scheme: dark;
  --primary: #7168e8;
  --primary-strong: #9cebf1;
  --ink: #ecf4ff;
  --muted: #9babca;
  --line: #294057;
  --surface: #122236;
  --bg: #091625;
  --soft: #1b3150;
  --good: #82e5be;
  --radius: 15px;
  --shadow: 0 15px 34px #01081563;
}
html { scrollbar-color: #395779 #0c1a2c; }
body { background: var(--bg); color: var(--ink); }
::selection { background: #675fd4; color: #fff; }
:focus-visible { outline-color: #8ce4f0; }
.skip-link { background: var(--surface); color: var(--ink); }
a { color: var(--primary-strong); }
a:hover { color: #c8f9fb; }

/* Shell and navigation */
.topbar { background: #0c1b2d; border-bottom-color: #2a405b; box-shadow: 0 5px 26px #030a1760; }
.brand, .brand:hover { color: #f6f9ff; }
.brand-mark { background: linear-gradient(140deg, #756def, #4eb8cf); box-shadow: 0 7px 21px #6563eb59; }
.profile-menu summary:hover { background: #192b43; }
.avatar { background: #253859; color: #b9c6ff; }
.profile-popover { background: #15263b; box-shadow: 0 20px 44px #020816b8; }
.icon-button { background: #172a40; color: #b6c5de; }
.icon-button:hover { background: #243c5c; color: #a9f2f5; }
.icon-button.danger { background: #392239; color: #ffb8c4; border-color: #83445a; }
.icon-button.danger:hover { background: #522a42; }
.app-layout { max-width: none; }
.sidebar { background: #0c1b2c; border-right-color: #263c55; }
.sidebar-heading { color: #8496b4; }
.side-nav a { color: #aabbd3; }
.side-nav a:hover { background: #1b304b; color: #f4f8ff; }
.side-nav a.active { position: relative; background: linear-gradient(90deg, #312f6e, #1d2b51); color: #e3e4ff; box-shadow: inset 2px 0 #8e8eff; }
.side-nav a.active .ui-icon { color: #a6dfff; }
.sidebar-note { border-top: 1px solid #263b55; color: #91a4bf; }
.presence-dot { background: #65e1bc; box-shadow: 0 0 12px #65e1bc99; }
.main-content { background: radial-gradient(ellipse 700px 390px at 52% -90px, #1a34517d, transparent 75%), #091625; }
.public-main { min-height: calc(100vh - 140px); }
.nav-overlay { background: #020817ad; }
h1, h2, h3 { color: #f3f7ff; }
.subtitle, .meta, .help { color: var(--muted); }
.eyebrow { color: #9caee1; }

/* Common surfaces and controls */
.card, .form-section, .form-footer, .filter-panel, .stat, .report-card,
.meeting-card, .rm-group, .tree-directorate, .pipeline-deal, .lead-card {
  background: var(--surface); border-color: var(--line); box-shadow: var(--shadow);
}
.button { background: linear-gradient(125deg, #7770ed, #5d60d9); color: #fff; box-shadow: 0 8px 23px #4c4fc044; }
.button:hover { background: linear-gradient(125deg, #8c85ff, #7172ef); color: #fff; transform: translateY(-1px); }
.button.secondary { background: #182b42; color: #e9f2ff; border-color: #38506e; box-shadow: none; }
.button.secondary:hover { background: #223b58; border-color: #7390b1; color: #fff; }
.button.soft { background: #262b60; color: #d7d5ff; box-shadow: none; }
.text-button { color: #9cebf1; }
.theme-toggle { appearance: none; -webkit-appearance: none; min-height: 36px; padding: 7px 12px; border: 1px solid #3a5270; border-radius: 999px; background: #152942; color: #c9d6eb; box-shadow: none; }
.theme-toggle:hover { background: #203a59; color: #f2f8ff; border-color: #6680a3; }
.field-clear { appearance: none; -webkit-appearance: none; align-self: flex-start; min-height: 31px; margin-top: 2px; padding: 5px 10px; border: 1px solid #395674; border-radius: 8px; background: #162b44; color: #a9edf4; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.2; cursor: pointer; }
.field-clear:hover { background: #223c5a; border-color: #6583a6; color: #effcff; }
.meeting-actions { width: 92px; text-align: center; white-space: nowrap; }
.meeting-actions form { display: inline-flex; margin: 0 2px; vertical-align: middle; }
.meeting-actions .icon-button { display: inline-grid; width: 36px; height: 36px; min-height: 36px; padding: 0; place-items: center; border-radius: 10px; }
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.meetings-table { min-width: 1130px; table-layout: fixed; }
.meeting-col-date { width: 96px; }
.meeting-col-client { width: 220px; }
.meeting-col-owner { width: 182px; }
.meeting-col-summary { width: min(34vw, 430px); }
.meeting-col-status { width: 138px; }
.meeting-col-manager { width: 178px; }
.meeting-col-actions { width: 92px; }
.meetings-table td { overflow-wrap: anywhere; }
.flash { background: #103c39; border-color: #267d69; color: #b3f5d9; }
.flash.error, .form-error { background: #3b2032; border-color: #9c4760; color: #ffbec8; }
.errorlist, .filter-error { color: #ffb2bd; }
.step-number { background: #343467; color: #d3d0ff; }
.form-section legend { color: #f0f5ff; }
input, select, textarea { background: #0c1b2d; border-color: #38506b; color: #eef5ff; color-scheme: dark; }
input::placeholder, textarea::placeholder { color: #8294ae; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #60799b; }
input:focus, select:focus, textarea:focus { border-color: #8daaf8; outline: none; box-shadow: 0 0 0 3px #756ce64a; }
input:disabled { background: #172539; color: #8697ae; }
option { background: #122236; color: #eef5ff; }
.readonly-hint { color: var(--muted); }

/* Search, filters and tabs */
.chip { color: #abbad1; }
.chip:hover { background: #223b56; color: #f4f7ff; }
.chip.active { background: #2e316c; border-color: #6669b5; color: #d9dbff; box-shadow: inset 0 0 0 1px #7779da30; }
.summary-period-buttons .chip.active { box-shadow: 0 4px 13px #02091783; }
.pagination a { background: #172a41; }
.tabs a { color: #a4b4ce; }
.tabs a.active { color: #a5eafa; border-color: #80dbe9; }
.tabs a:hover { background: #1d3250; color: #f4f8ff; }
.search-field .ui-icon { color: #90a3bf; }
.filter-caption, .period-label { color: var(--muted); }

/* Tables, including fixed report columns and mobile card rows */
.table-wrap, table { background: #112136; }
th { background: #1b3048; color: #bfcee3; }
td { color: #e2ebf8; }
tbody tr:hover td { background: #1b3048; }
.scroll-table th:first-child { background: #1b3048; }
.scroll-table td:first-child { background: #112136; }
.scroll-table tbody tr:hover td:first-child { background: #1b3048; }
.report-summary-table tr.report-id-row td { background: #25375b; }
.report-summary-table tr.report-total-row td { background: #17483e; }
.client-name { color: #eef6ff; }
.client-name:hover { color: #a0edf5; }
.empty { color: #a3b5cf; }
.status.issued, .status.good { background: #1b513f; color: #b7f3d0; }
.status.scheduled, .status.info { background: #223d68; color: #c1d7ff; }
.status.none, .status.muted { background: #2b3b51; color: #c3d0df; }
.status.warning, .zero-meetings { background: #584324; color: #ffe2a3; }
.status.danger { background: #602e40; color: #ffd0d8; }
.next-step { background: #1b3150; border-left-color: #8d87ff; }
.org-step { background: #1a3049; border: 1px solid #31465e; }
.org-detail-chain { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rm-group > summary { background: #1b2e48; }
.meeting-card:hover, .report-card:hover { border-color: #466484; }
.stat-link:hover { background: #203653; border-color: #6881bb; color: #fff; box-shadow: 0 10px 26px #02091791; }
.csm-contributions li, .meeting-compact { background: #162940; }
.meeting-compact:hover { background: #233d59; border-color: #6d83b7; }
.assignment { background: #263e62; color: #c6d9ff; }
.assignment.pending { background: #554327; color: #ffe3ab; }
.assignment-link { background: #1d304c; }
.assignment-link .avatar { background: #344a72; color: #d6e1ff; }
.cumulative-report-card { border-color: #7775c5; }

/* Organisation tree */
.tree-root { background: linear-gradient(125deg, #21375c, #172b45); }
.tree-avatar { background: #344b70; color: #d9e4ff; }
.tree-avatar-id { background: linear-gradient(130deg, #7369e4, #438dad); color: #fff; box-shadow: 0 9px 24px #484dc765; }
.tree-branches:before { background: linear-gradient(#8a86f0, #3b607d); }
.tree-node:before { background: #527092; }
.tree-node small { color: #ffd39a; }
.csm-node { background: #1b3151; border-color: #53639b; }
.csm-node .tree-avatar { background: #40467c; }
.rm-node .tree-avatar { background: #233c59; color: #d4e3f6; }

/* PL and lead kanban */
.pipeline-column, .lead-column { background: #132438; border-color: #2a425c; }
.pipeline-column > header, .lead-column > header { color: #eaf2fe; }
.pipeline-count { background: #2c3d59; color: #d4e3fa; }
.pipeline-dropzone.drag-over, .lead-dropzone.drag-over { background: #313a6c; outline-color: #a3a2ff; }
.pipeline-deal, .lead-card { box-shadow: 0 5px 15px #030c1d73; }
.pipeline-deal:hover, .lead-card:hover { border-color: #7286b0; }
.deal-grip { color: #899bb7; }
.deal-owner, .lead-company { color: #a9bce0; }
.deal-next, .lead-comment { background: #233858; color: #cfdaec; }
.deal-next strong, .lead-comment strong { color: #b6ceff; }
.deal-next.overdue { background: #582d3b; }
.deal-next.overdue strong { color: #ffd0d8; }
.deal-next.missing { background: #564026; }
.deal-next.missing strong { color: #ffe0a6; }
.pipeline-paid, .lead-paid, .lead-agreed { background: #15342f; }
.pipeline-paid .pipeline-count, .lead-paid .pipeline-count { background: #245847; color: #b7f3d0; }
.pipeline-refused, .lead-refused { background: #362531; }
.pipeline-refused .pipeline-count { background: #5f3545; color: #ffd0d8; }
.lead-in_pipeline { background: #25294d; }
.lead-linked-label { color: #b8b6ff; }
.pipeline-timeline:before { background: #486183; }
.timeline-dot { background: #8988ec; border-color: #17283f; }

/* Dashboard secondary modules */
.dashboard-kpi { background: var(--surface); }
.dashboard-kpi-warn { background: #3c2e2e; border-color: #70564e; }
.dashboard-kpi-warn strong { color: #ffd196; }
.dashboard-row strong { background: #293b69; color: #c8d5ff; }
.dashboard-row strong.dashboard-zero { background: #5c2330; color: #ffc4cd; }
.dashboard-task time, .dashboard-state { background: #263d62; color: #c8d9ff; }
.dashboard-alerts > a, .dashboard-alerts > div, .dashboard-admin-grid a { background: #192d45; }
.dashboard-alerts > a:hover, .dashboard-admin-grid a:hover { background: #253e5e; border-color: #7182b2; }
.dashboard-meter { background: #243650; }
.dashboard-meter > span { background: linear-gradient(90deg, #837eff, #70dce7); }

@media (max-width: 767px) {
  .sidebar { background: #0c1b2c; box-shadow: 10px 0 45px #020816c9; }
  .responsive-table { background: transparent; }
  .responsive-table tr { background: #14263a; }
  .main-content { padding-bottom: 50px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-history-picker .simple-search { display: grid; grid-template-columns: 1fr; }
  .report-history-picker .field, .report-history-picker .button { width: 100%; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .button:hover, .dashboard-stat-strip a:hover { transform: none; }
}

/* Readable organisation hierarchy: cards carry the hierarchy, not connector lines. */
.org-hierarchy { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.org-directorate { min-width: 0; overflow: hidden; background: #102238; border: 1px solid #304964; border-radius: 18px; box-shadow: 0 14px 32px #030a1760; }
.org-directorate-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px; background: linear-gradient(120deg, #213a60, #182b46); border-bottom: 1px solid #38536f; }
.org-directorate > summary { list-style: none; cursor: pointer; }
.org-directorate > summary::-webkit-details-marker, .structure-mkk-block > summary::-webkit-details-marker { display: none; }
.org-directorate-disclosure { display: grid; width: 28px; height: 28px; place-items: center; flex: none; border: 1px solid #4c6688; border-radius: 999px; background: #172e4b; color: #bbd5f1; }
.org-directorate-disclosure::before { content: "⌄"; font-size: 18px; line-height: 1; transition: transform .16s; }
.org-directorate[open] .org-directorate-disclosure::before { transform: rotate(180deg); }
.org-directorate-header h2 { margin: 2px 0; font-size: 20px; }
.org-directorate-header p { margin: 0; color: #9fb1cb; font-size: 12px; }
.org-directorate-body { padding: 16px; }
.structure-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.structure-person > div { min-width: 0; }
.structure-person strong { display: block; color: #edf5ff; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.structure-avatar { display: grid; width: 32px; height: 32px; place-items: center; flex: none; border: 1px solid #4b668a; border-radius: 10px; background: #294662; color: #dff3ff; font-size: 12px; font-weight: 750; }
.structure-avatar-root { width: 48px; height: 48px; border: 0; border-radius: 15px; background: linear-gradient(135deg, #7c73ee, #4fc2cf); box-shadow: 0 8px 20px #4b53cb66; color: #fff; font-size: 18px; }
.structure-level, .structure-owner-label { display: block; margin-bottom: 2px; color: #9caed0; font-size: 10px; font-weight: 750; letter-spacing: .075em; line-height: 1.35; text-transform: uppercase; }
.structure-owner { min-width: 145px; padding: 10px 12px; border: 1px solid #4a6086; border-radius: 12px; background: #172c49; }
.structure-owner strong { display: block; color: #dce9ff; font-size: 13px; overflow-wrap: anywhere; }
.structure-owner small { display: block; margin-top: 3px; color: #f7d18b; font-size: 11px; }
.structure-section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 9px; color: #aebfda; font-size: 11px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.structure-section-title > span:last-child { display: grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 999px; background: #294360; color: #cfe3ff; font-size: 11px; letter-spacing: 0; }
.structure-section-title-child { margin: 0 0 9px; padding-bottom: 8px; border-bottom: 1px solid #2b435d; font-size: 10px; }
.structure-rm-grid, .structure-ns-list, .structure-mkk-list { display: grid; gap: 10px; }
.structure-unit { min-width: 0; border: 1px solid #304b66; border-radius: 14px; background: #11263e; }
.structure-unit-rm { padding: 13px; }
.structure-unit-ns { padding: 12px; border-color: #36536d; background: #142b45; }
.structure-unit-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.structure-children-block { margin-top: 13px; padding: 12px; border-radius: 11px; background: #0d1e32; }
.structure-mkk-block { margin-bottom: 0; background: #10243a; }
.structure-mkk-block { cursor: pointer; }
.structure-mkk-block > summary { list-style: none; }
.structure-mkk-block > summary.structure-section-title { margin: 0; }
.structure-mkk-block > summary::after { content: "Показать"; margin-left: auto; color: #8edce9; font-size: 10px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.structure-mkk-block[open] > summary::after { content: "Скрыть"; }
.structure-mkk-block > .structure-mkk-list { display: none; margin-top: 9px; }
.structure-mkk-block[open] > .structure-mkk-list { display: grid; }
.structure-mkk-list { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.structure-mkk { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; padding: 10px; border: 1px solid #35516b; border-radius: 10px; background: #172e48; }
.structure-mkk .structure-avatar { width: 28px; height: 28px; border-radius: 9px; background: #31536d; font-size: 11px; }
.structure-mkk .structure-level { font-size: 9px; }
.structure-mkk .structure-person strong { font-size: 13px; }
.structure-empty { margin: 0; padding: 13px; border: 1px dashed #486482; border-radius: 10px; color: #9cb0ca; font-size: 12px; line-height: 1.45; }
.structure-empty-large { padding: 18px; text-align: center; }
.structure-editor { min-width: 0; }
.structure-editor > summary { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 34px; padding: 7px 9px; border: 1px solid #3b5a78; border-radius: 9px; background: #1a3450; color: #a9edf4; font-size: 12px; font-weight: 700; list-style: none; }
.structure-editor > summary::-webkit-details-marker { display: none; }
.structure-editor > summary::after { content: "⌄"; color: #88a4c7; font-size: 15px; line-height: 1; }
.structure-editor[open] > summary { border-color: #7777e8; background: #202d61; color: #e4e4ff; }
.structure-editor[open] > summary::after { transform: rotate(180deg); }
.structure-editor-compact { margin-left: auto; flex: none; }
.structure-editor-compact[open] { flex-basis: 100%; margin-top: 2px; }
.structure-add-root { margin: 0; }
.structure-add-root > summary { min-height: 42px; padding: 9px 12px; color: #e6e6ff; }
.structure-editor-hint { color: #9fb0ca; font-size: 10px; font-weight: 600; }
.structure-editor-panel { display: grid; gap: 10px; margin-top: 9px; padding: 11px; border: 1px solid #425c82; border-radius: 11px; background: #0b1b2e; }
.structure-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.structure-form label { display: grid; min-width: 0; gap: 5px; color: #adbed6; font-size: 11px; font-weight: 700; }
.structure-form input { min-height: 39px; padding: 8px 10px; }
.structure-form .button { min-height: 39px; padding: 8px 12px; font-size: 12px; }
.structure-form-add { padding-top: 10px; border-top: 1px solid #29435e; }
.structure-delete { justify-self: start; color: #ffb7c4; font-size: 12px; }
.structure-delete:hover { color: #ffd4db; }

@media (max-width: 767px) {
  .org-hierarchy { grid-template-columns: 1fr; gap: 14px; }
  .org-directorate-header { align-items: stretch; flex-direction: column; padding: 16px; }
  .org-directorate-body { padding: 12px; }
  .structure-owner { width: 100%; }
  .structure-rm-grid, .structure-mkk-list { grid-template-columns: 1fr; }
  .structure-unit-rm, .structure-unit-ns { padding: 11px; }
  .structure-children-block { padding: 10px; }
  .structure-form { grid-template-columns: 1fr; }
  .structure-form .button { width: 100%; }
  .structure-editor-compact { margin-left: 0; }
  .structure-editor-compact[open] { margin-top: 0; }
}

/* Compact density for day-to-day structure management. */
.org-hierarchy { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.org-directorate { border-radius: 15px; }
.org-directorate-header { gap: 12px; padding: 14px 16px; }
.org-directorate-header h2 { font-size: 17px; }
.structure-avatar-root { width: 40px; height: 40px; border-radius: 12px; font-size: 16px; }
.structure-owner { min-width: 126px; padding: 7px 9px; border-radius: 10px; }
.structure-owner strong { font-size: 12px; }
.org-directorate-body { padding: 11px; }
.structure-add-root > summary { min-height: 36px; padding: 7px 10px; }
.structure-section-title { margin: 11px 0 7px; font-size: 10px; }
.structure-section-title > span:last-child { min-width: 20px; height: 20px; font-size: 10px; }
.structure-unit-rm, .structure-unit-ns { padding: 9px; border-radius: 12px; }
.structure-person { gap: 8px; }
.structure-person strong { font-size: 13px; }
.structure-avatar { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.structure-level { font-size: 9px; }
.structure-editor > summary { min-height: 30px; padding: 5px 8px; font-size: 11px; }
.structure-children-block { margin-top: 8px; padding: 8px; border-radius: 9px; }
.structure-children-block:has(.structure-empty) { padding: 7px 9px; }
.structure-children-block:has(.structure-empty) .structure-section-title { display: none; }
.structure-empty { padding: 0; border: 0; color: #91a8c4; font-size: 11px; line-height: 1.35; }
.structure-empty-large { padding: 12px; border: 1px dashed #486482; }
.structure-editor-panel { gap: 8px; margin-top: 7px; padding: 9px; }
.structure-form { gap: 6px; }
.structure-form input, .structure-form .button { min-height: 35px; padding: 7px 9px; font-size: 11px; }
.structure-mkk { padding: 8px; }

/* MKK names need the full width of a compact card.  The edit control moves
   below the name, instead of leaving a narrow column that splits every word. */
.structure-mkk { display: block; }
.structure-mkk > .structure-editor { display: inline-block; margin: 8px 0 0; max-width: 100%; }
.structure-mkk > .structure-editor[open] { display: block; }

@media (max-width: 767px) {
  .org-directorate-header { padding: 13px; }
  .org-directorate-body { padding: 10px; }
  .structure-unit-rm, .structure-unit-ns { padding: 9px; }
}
