:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #1d2824;
  --muted: #66736d;
  --brand: #1f4b3f;
  --brand-soft: #e5f0ec;
  --accent: #c8945c;
  --danger: #a33a32;
  --ok: #2f7d55;
  --border: #d9dedb;
  --topbar-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* "Шалфей" - onboarding roadmap screens only (DESIGN_SPEC_sage.md). Do not
     reuse on existing screens, do not delete the tokens above. */
  --sg-bg:        #F4F2EC;
  --sg-card:      #FFFFFF;
  --sg-line:      #E6E2D8;

  --sg-head:      #4A6152;
  --sg-head-2:    #5C7565;
  --sg-head-text: #EDF2EE;

  --sg-acc:       #4A6152;
  --sg-acc-soft:  #E8EFE9;
  --sg-acc-text:  #3A4E42;

  --sg-ok:        #7FA05C;
  --sg-ok-soft:   #EFF4E6;
  --sg-warn:      #C08A3E;
  --sg-warn-soft: #FAF0E0;

  --sg-text:      #2A2E2B;
  --sg-text-2:    #6E7570;
  --sg-muted:     #A8ACA6;

  --sg-r-card:    16px;
  --sg-r-stat:    14px;
  --sg-r-btn:     10px;
  --sg-r-chip:     9px;
  --sg-r-phone:   24px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: .8rem 1rem; background: var(--brand); color: white; font-weight: 700; }
button.secondary { background: var(--brand-soft); color: var(--brand); }
button.ghost { background: transparent; border: 1px solid rgba(255,255,255,.5); }
button:disabled { opacity: .55; cursor: not-allowed; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: var(--topbar-height); display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .9rem 1rem; background: var(--brand); color: white; box-shadow: 0 3px 18px rgba(0,0,0,.12); }
.topbar-brand { flex: 0 0 auto; min-width: 0; }
.topbar-brand strong, .topbar-brand span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-brand span { opacity: .8; font-size: .82rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; min-width: 40px; border-radius: 999px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35); color: white; font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; flex: 0 0 auto; }

.topbar.topbar-sage { flex-direction: row; align-items: center; gap: .4rem; padding: .5rem .7rem; background: var(--sg-head); min-height: 0; }
.topbar-sage .topbar-brand { display: none; }
.topbar-sage .topbar-actions { position: relative; flex: 1 1 auto; justify-content: flex-start; gap: .4rem; }
.topbar-sage .tabs { flex: 1 1 auto; justify-content: center; gap: .3rem; }
.topbar-sage .topbar-actions .icon-btn { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; min-width: 32px; background: transparent; border-color: transparent; }
.topbar-sage .tabs button { padding: .4rem .65rem; min-height: 0; font-size: 11.5px; font-weight: 500; border-radius: 8px; background: transparent; color: var(--sg-head-text); border: 0; }
.topbar-sage .tabs button.active { background: #fff; color: var(--sg-acc-text); font-weight: 500; }
.topbar-sage .icon-btn { width: 32px; height: 32px; min-width: 32px; font-size: 15px; }
main { width: min(1120px, 100%); margin: 0 auto; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1rem; box-shadow: 0 8px 28px rgba(31,75,63,.06); }
.login-card { max-width: 430px; margin: 6vh auto; }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: .8rem; background: white; color: var(--ink); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.inline-form label { flex: 1 1 130px; gap: .3rem; font-weight: 600; font-size: .85rem; }
.inline-form input, .inline-form select { padding: .55rem .6rem; }
.inline-form button { flex: 0 0 auto; height: 2.6rem; align-self: end; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2rem; }
.tabs { flex: 1 1 auto; display: flex; justify-content: center; gap: .4rem; overflow-x: auto; scrollbar-width: thin; }
.tabs button { white-space: nowrap; background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.3); }
.tabs button.active { background: white; color: var(--brand); border-color: white; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.metric { padding: 1rem; background: white; border: 1px solid var(--border); border-radius: 16px; }
.metric strong { display: block; font-size: 1.7rem; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; }
.assignment { display: grid; gap: .7rem; }
.assignment h3 { margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge { display: inline-flex; padding: .3rem .55rem; border-radius: 999px; background: #eef1ef; color: #4b564f; font-size: .8rem; font-weight: 700; }
.badge.ok { background: #e0f2e8; color: #1f6b46; }
.badge.warn { background: #f7ead8; color: #87511d; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1rem 0 .7rem; }
.list { display: grid; gap: .7rem; }
.reference-group { margin-bottom: 1.5rem; }
.reference-group h3 { margin: 0 0 .6rem; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.reference-link { display: block; width: 100%; min-height: 44px; padding: .75rem; margin-bottom: .7rem; background: none; border: 1px solid var(--border); border-radius: 12px; text-align: left; font: inherit; font-weight: 500; color: var(--brand); cursor: pointer; }
.reference-link:hover, .reference-link:focus-visible { text-decoration: underline; background: var(--brand-soft); }
.team-member { display: grid; gap: .7rem; }
.progress { height: 10px; background: #e5e8e6; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
dialog { width: min(760px, calc(100% - 1.2rem)); max-height: calc(100vh - 1.2rem); overflow: auto; border: 0; border-radius: 20px; padding: 1rem; }
dialog::backdrop { background: rgba(13, 25, 21, .55); }
.dialog-close { float: right; width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.diff { display: grid; gap: .35rem; }
.diff-item { padding: .55rem .7rem; border-radius: 8px; font-family: ui-monospace, monospace; font-size: .86rem; }
.diff-item.added { background: #e3f5e9; color: #235f3f; }
.diff-item.removed { background: #fae7e5; color: #83302b; text-decoration: line-through; }
.regulation-content { white-space: pre-wrap; line-height: 1.6; background: #f7f8f7; padding: 1rem; border-radius: 12px; }
.rich-editor-toolbar { display: flex; gap: .3rem; margin-bottom: .4rem; }
.rich-editor-toolbar button { padding: .35rem .6rem; min-width: 2.2rem; background: var(--brand-soft); color: var(--brand); border: 1px solid transparent; border-radius: 8px; font-weight: 500; font-size: .9rem; }
.rich-editor-toolbar button:hover { background: var(--border); }
.rich-editor { min-height: 9rem; max-height: 22rem; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: .8rem; background: white; color: var(--ink); line-height: 1.6; }
.rich-editor:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.rich-editor ul, .rich-editor ol { padding-left: 1.4rem; margin: .3rem 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.quiz-question { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.option { display: flex; align-items: flex-start; gap: .5rem; padding: .35rem 0; font-weight: 400; }
.option input { width: auto; margin-top: .25rem; }
.toast {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  background: var(--ink);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 16px;
  box-shadow: 0 12px 42px rgba(0,0,0,0.4);
  font-weight: 600;
  text-align: center;
  max-width: min(480px, calc(100vw - 2rem));
  font-size: 0.95rem;
  pointer-events: none;
  animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 2px solid var(--accent);
}
@keyframes slideDownToast {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
table { width: 100%; border-collapse: collapse; background: white; border-radius: 14px; overflow: hidden; }
th, td { text-align: left; padding: .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid { grid-template-columns: 1fr; }
  main { padding: .75rem; }
  .card { border-radius: 15px; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  td { border-bottom: 0; padding: .4rem .7rem; }
  tr { border-bottom: 1px solid var(--border); padding: .6rem 0; }
}
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; align-items: start; }
.editor-grid form, .editor-grid section { display: grid; gap: .85rem; }
.editor-grid h3 { margin: 0; }
.form-stack { display: grid; gap: .65rem; margin-top: .75rem; }
.check-row { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500; }
.check-row input { width: auto; margin-top: .2rem; }
.draft-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; }
.draft-row[draggable="true"] { cursor: grab; }
.draft-row.dragging { opacity: .4; }
.drag-handle { display: inline-block; margin-right: .4rem; color: var(--muted); cursor: grab; }
.roster-row { display: flex; align-items: center; flex-wrap: nowrap; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; white-space: nowrap; }
.roster-row strong { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.roster-row-edit { overflow-x: visible; white-space: normal; flex-wrap: wrap; }
.roster-row-edit input, .roster-row-edit select { flex: 1 1 130px; width: auto; padding: .45rem .5rem; }
.compact { max-height: 220px; overflow: auto; padding: .25rem; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: end; }
.notice { padding: .75rem; border-radius: 12px; background: #f7ead8; color: #87511d; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: .75rem; }
legend { padding: 0 .35rem; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.loading-card { min-height: 80px; }
@media (max-width: 820px) {
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .two-cols { grid-template-columns: 1fr; }
  .draft-row { align-items: stretch; flex-direction: column; }
  .topbar-brand { flex: 0 1 40%; max-width: 40%; }
  .topbar-brand strong { font-size: .95rem; }
  .topbar-brand span { font-size: .74rem; }
  .tabs { justify-content: flex-start; }
  .tabs button { padding: .55rem .7rem; font-size: .82rem; }
  .topbar-sage .tabs button { padding: .4rem .5rem; font-size: 10.5px; }
  .topbar-sage .tabs button { padding: .4rem .65rem; font-size: 11.5px; }
}

/* ===== "Шалфей" - onboarding roadmap screens (DESIGN_SPEC_sage.md) ===== */

.sg-screen { max-width: 420px; margin: 0 auto; font-size: 13px; color: var(--sg-text); }
.sg-header { background: var(--sg-head); border-radius: var(--sg-r-card); padding: 15px 17px 17px; display: flex; align-items: center; gap: .7rem; }
.sg-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--sg-head-2); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 14px; flex: 0 0 auto; }
.sg-header-name { font-size: 15px; font-weight: 500; color: #fff; }
.sg-header-role { font-size: 12px; font-weight: 400; color: var(--sg-head-text); opacity: .75; }
.sg-path-card { background: var(--sg-card); border: 1px solid var(--sg-line); border-radius: var(--sg-r-card); padding: .85rem .9rem; margin-top: .8rem; }
.sg-path-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .55rem; }
.sg-path-card-head strong { font-size: 14px; font-weight: 500; color: var(--sg-text); }
.sg-path-card-head span { font-size: 12px; color: var(--sg-text-2); white-space: nowrap; }
.sg-progress { height: 6px; border-radius: 999px; background: var(--sg-line); overflow: hidden; }
.sg-progress .sg-fill { display: block; height: 100%; background: var(--sg-ok); width: 0; transition: width .6s cubic-bezier(.2,.8,.3,1), height .6s cubic-bezier(.2,.8,.3,1); }
.sg-mentor-card { background: var(--sg-card); border: 1px solid var(--sg-line); border-radius: var(--sg-r-card); padding: .8rem .9rem; margin-top: .8rem; display: flex; align-items: center; gap: .7rem; }
.sg-mentor-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--sg-acc-soft); color: var(--sg-acc-text); display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 13px; flex: 0 0 auto; }
.sg-mentor-info { flex: 1; min-width: 0; }
.sg-mentor-info strong { display: block; font-size: 13px; font-weight: 500; color: var(--sg-text); }
.sg-mentor-info span { display: block; font-size: 11px; color: var(--sg-text-2); }
.sg-call-btn { width: 36px; height: 36px; min-width: 44px; min-height: 44px; border-radius: 50%; background: var(--sg-acc); color: #fff; display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 16px; flex: 0 0 auto; }
.sg-today-banner { margin-top: .8rem; background: var(--sg-warn-soft); color: var(--sg-warn); border-radius: var(--sg-r-stat); padding: .55rem .8rem; font-size: 12px; font-weight: 500; }
.sg-today-banner.sg-done { background: var(--sg-ok-soft); color: var(--sg-ok); }

.sg-trail { position: relative; margin-top: 1.1rem; padding-left: 0; }
.sg-trail::before { content: ""; position: absolute; left: 46px; top: 0; bottom: 0; width: 3px; background: var(--sg-line); border-radius: 999px; }
.sg-trail-fill { position: absolute; left: 46px; top: 0; width: 3px; background: var(--sg-ok); border-radius: 999px; height: 0; transition: height .6s cubic-bezier(.2,.8,.3,1); }
.sg-day { position: relative; margin-bottom: 1.1rem; }
.sg-day-heading { font-size: 12px; font-weight: 500; color: var(--sg-text-2); margin: 0 0 .5rem 68px; }
.sg-day-past .sg-day-heading { color: var(--sg-muted); text-decoration: line-through; }
/* Node is centered on the 46px trail line and 33px wide, so its right edge
   sits at ~62.5px - everything to the right of it starts at 68px (safe gap)
   to stop text/cards printing over the node (bug reported 2026-08-10). */
.sg-node { position: absolute; left: 46px; top: 2px; transform: translateX(-50%); width: 33px; height: 33px; border-radius: 50%; border: 3px solid var(--sg-bg); background: var(--sg-muted); z-index: 1; }
.sg-node.sg-node-current { background: var(--sg-warn); }
.sg-node.sg-node-done { background: var(--sg-ok); }
.sg-node.sg-node-flag { background: var(--sg-acc); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; }

.sg-step-card { margin-left: 68px; background: var(--sg-card); border: 1px solid var(--sg-line); border-radius: var(--sg-r-card); padding: .65rem .75rem; display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; transition: all .35s cubic-bezier(.2,.8,.3,1); }
.sg-step-card.sg-done { border-color: var(--sg-ok); }
.sg-step-future .sg-step-card { background: transparent; border-style: dashed; }
.sg-chip { width: 26px; height: 26px; border-radius: var(--sg-r-chip); background: var(--sg-bg); color: var(--sg-muted); display: flex; align-items: center; justify-content: center; font-size: 14px; flex: 0 0 auto; }
.sg-chip.sg-done { background: var(--sg-ok); color: #fff; }
.sg-step-body { flex: 1; min-width: 0; }
.sg-step-title { font-size: 13px; font-weight: 500; color: var(--sg-text); }
.sg-step-card.sg-done .sg-step-title { color: var(--sg-muted); text-decoration: line-through; }
.sg-step-meta { font-size: 11px; color: var(--sg-text-2); margin-top: 2px; }
.sg-step-future .sg-step-title, .sg-step-future .sg-step-meta { color: var(--sg-muted); }
.sg-btn { border: 0; border-radius: var(--sg-r-btn); padding: 9px 15px; min-height: 44px; font-size: 13px; font-weight: 500; background: var(--sg-acc); color: #fff; flex: 0 0 auto; }
.sg-btn.sg-btn-soft { background: var(--sg-acc-soft); color: var(--sg-acc-text); }
.sg-btn:active { transform: scale(.96); }
.sg-mentor-contact { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }

.sg-day.sg-day-future .sg-node { opacity: .6; }

@media (prefers-reduced-motion: reduce) {
  .sg-step, .sg-fill, .sg-trail-fill { transition-duration: .01ms !important; }
}

@keyframes sg-pop { 0% { transform: scale(1); } 45% { transform: scale(1.3); } 100% { transform: scale(1); } }
.sg-pop { animation: sg-pop .45s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .sg-pop { animation: none; }
}

/* Manager-facing onboarding views: same tokens, no trail, no animation, red allowed for overdue. */
.sg-manager-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem .75rem; border: 1px solid var(--sg-line); border-radius: var(--sg-r-stat); background: var(--sg-card); }

/* Общее лекало карточки: "Моё обучение" и "Каталог" */
.sg-title { font-size: 15px; font-weight: 500; color: var(--sg-text); margin: 0 0 2px; }
.sg-subtitle { font-size: 12px; color: var(--sg-text-2); margin: 0 0 .7rem; }
.sg-today-card { background: var(--sg-card); border: 1px solid var(--sg-ok); border-radius: var(--sg-r-card); padding: 12px 13px; margin-bottom: 9px; }
.sg-today-card .sg-eyebrow { font-size: 11px; color: var(--sg-text-2); margin-bottom: 2px; }
.sg-today-card .sg-today-title { font-size: 13px; font-weight: 500; color: var(--sg-text); margin-bottom: .6rem; }
.sg-today-card .sg-btn { width: 100%; }
.sg-list-card { background: var(--sg-card); border: 1px solid var(--sg-line); border-radius: var(--sg-r-card); padding: 12px 13px; margin-bottom: 9px; display: flex; align-items: center; gap: .6rem; }
.sg-list-card.sg-done { border-color: var(--sg-ok); }
.sg-list-body { flex: 1; min-width: 0; }
.sg-list-title { font-size: 13px; font-weight: 500; color: var(--sg-text); }
.sg-list-card.sg-done .sg-list-title { color: var(--sg-muted); text-decoration: line-through; }
.sg-list-meta { font-size: 11px; color: var(--sg-text-2); margin-top: 2px; display: flex; align-items: center; gap: 5px; }

/* Справочник: сгруппированные строки, не карточки */
.sg-ref-search { width: 100%; border: 1px solid var(--sg-line); border-radius: var(--sg-r-btn); padding: .7rem .8rem; background: var(--sg-card); color: var(--sg-text); font-size: 13px; margin-bottom: 1rem; }
.sg-ref-group { margin-bottom: 1rem; }
.sg-ref-group-title { font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; color: var(--sg-text-2); margin: 0 0 .5rem; }
.sg-ref-block { background: var(--sg-card); border: 1px solid var(--sg-line); border-radius: var(--sg-r-card); overflow: hidden; }
.sg-ref-row { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 44px; padding: .7rem .8rem; background: none; border: 0; border-top: .5px solid var(--sg-line); text-align: left; font: inherit; font-size: 13px; color: var(--sg-acc-text); cursor: pointer; }
.sg-ref-block .sg-ref-row:first-child { border-top: 0; }
.sg-ref-row .sg-ref-icon { flex: 0 0 auto; color: var(--sg-text-2); }
.sg-ref-row .sg-ref-label { flex: 1; min-width: 0; }
.sg-ref-row .sg-ref-chevron { flex: 0 0 auto; color: var(--sg-muted); }
.sg-manager-overdue { color: var(--danger); font-weight: 500; }