:root {
  --pam-navy:       #3D4359;
  --pam-teal:       #0F7597;
  --pam-skyblue:    #82C9E1;
  --pam-gold:       #CDAA2A;
  --pam-coral:      #ED887B;
  --pam-lavender:   #BFAEE5;
  --pam-lavender-10:#F1ECFA;
  --pam-lime:       #BCED5D;
  --pam-lightblue:  #D7F3FC;
  --pam-grey:       #9397A3;
  --pam-yellow:     #F8E18D;
  --pam-peach:      #FFA565;
  --bg:             #F6F4FA;
  --panel:          #FFFFFF;
  --border:         #E4E0EC;
  --text:           #3D4359;
  --text-muted:     #7C7E8C;
  --shadow:         0 2px 12px rgba(61,67,89,0.06);
  --shadow-lg:      0 8px 32px rgba(61,67,89,0.10);
  --radius:         14px;
  --radius-sm:      8px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Unbounded', 'Roboto', sans-serif; color: var(--pam-navy); letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 700; margin: 0 0 8px; }
h2 { font-size: 20px; font-weight: 700; margin: 32px 0 16px; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
a { color: var(--pam-teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.view-login {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--pam-lavender-10) 0%, var(--pam-lightblue) 100%);
  display: flex; align-items: center; justify-content: center; padding: 40px 20px;
}
.login-grid {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px;
  max-width: 1080px; width: 100%;
  background: var(--panel); border-radius: 24px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-hero {
  background: var(--pam-navy); color: #E8E5F0;
  padding: 48px 44px; display: flex; flex-direction: column; gap: 16px;
}
.login-logo {
  display: inline-block; background: var(--pam-lavender); color: var(--pam-navy);
  font-family: 'Unbounded', sans-serif; font-weight: 900; font-size: 30px;
  padding: 8px 22px; border-radius: 16px; align-self: flex-start; margin-bottom: 4px;
}
.login-tagline { font-size: 11px; color: var(--pam-lavender); text-transform: uppercase; letter-spacing: 1.5px; }
.login-hero h1 { color: #fff; font-size: 34px; line-height: 1.15; margin-top: 12px; }
.login-hero p { color: #C8C4D8; font-size: 14px; }
.login-features { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 10px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #D8D4E4; }
.login-features span {
  background: var(--pam-lavender); color: var(--pam-navy);
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.login-card { padding: 48px 44px; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 24px; }
.tab { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--text-muted); }
.tab.active { background: var(--panel); color: var(--pam-navy); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.auth-form input, .profile-form input, .search-input {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text); background: var(--panel); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus, .profile-form input:focus, .search-input:focus {
  outline: none; border-color: var(--pam-lavender); box-shadow: 0 0 0 3px var(--pam-lavender-10);
}
.muted-link { color: var(--text-muted); font-size: 12px; text-align: center; }

/* ========== BUTTONS ========== */
.btn { border: 0; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500;
  padding: 12px 20px; border-radius: var(--radius-sm); transition: transform .1s, background .15s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pam-navy); color: #fff; }
.btn-primary:hover { background: #2c3145; box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--pam-navy); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ========== APP SHELL ========== */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--pam-navy); color: #E8E5F0;
  padding: 22px 18px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar .logo {
  display: inline-block; background: var(--pam-lavender); color: var(--pam-navy);
  font-family: 'Unbounded', sans-serif; font-weight: 900; font-size: 22px;
  padding: 6px 18px; border-radius: 14px; align-self: flex-start;
}
.sidebar .tagline { font-size: 10px; color: var(--pam-lavender); text-transform: uppercase; letter-spacing: 1.5px; margin: 6px 0 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  background: transparent; border: 0; color: #C8C4D8;
  padding: 11px 14px; border-radius: var(--radius-sm); text-align: left; cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 500; display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--pam-lavender); color: var(--pam-navy); }
.nav-icon { font-size: 14px; opacity: 0.9; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.user-avatar {
  width: 36px; height: 36px; min-width: 36px; min-height: 36px;
  border-radius: 50%; aspect-ratio: 1; flex-shrink: 0;
  background: var(--pam-skyblue); color: var(--pam-navy);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.user-name { font-size: 12px; color: #fff; font-weight: 500; }
.user-role { font-size: 11px; color: var(--pam-lavender); }
.logout { width: 100%; background: transparent; border: 1px solid rgba(255,255,255,0.15); color: #C8C4D8;
  padding: 8px; border-radius: var(--radius-sm); cursor: pointer; margin-top: 8px; font-family: inherit; font-size: 12px; }
.logout:hover { background: rgba(255,255,255,0.06); }

/* ========== MAIN ========== */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.breadcrumbs { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--bg); border: 1px solid var(--border); width: 36px; height: 36px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--pam-lavender-10); }

.view { padding: 32px; flex: 1; }
.page-head { margin-bottom: 24px; }
.page-sub { color: var(--text-muted); font-size: 14px; max-width: 720px; margin: 0; }
.back-link { font-size: 13px; color: var(--pam-teal); cursor: pointer; margin-bottom: 10px; }
.back-link:hover { text-decoration: underline; }
.section-title { margin-top: 40px; }

/* ========== DASHBOARD ========== */
.progress-track { background: var(--panel); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.progress-bar { height: 10px; background: var(--bg); border-radius: 100px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pam-lavender), var(--pam-skyblue)); border-radius: 100px; }
.progress-labels { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.progress-labels span:nth-child(2) { color: var(--pam-navy); font-weight: 700; }

.cards-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  background: var(--panel); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  border-top: 4px solid var(--pam-lavender);
}
.card-accent-cyan { border-top-color: var(--pam-skyblue); }
.card-accent-lime { border-top-color: var(--pam-lime); }
.card-accent-peach { border-top-color: var(--pam-peach); }
.card-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-muted); font-weight: 700; }
.card-title { font-size: 16px; font-weight: 500; color: var(--pam-navy); }
.card-title .big { display: block; font-family: 'Unbounded'; font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.card-meta { font-size: 12px; color: var(--text-muted); margin-top: auto; }
.card .btn { align-self: flex-start; margin-top: 8px; }

/* STAGES */
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stage {
  background: var(--panel); border-radius: var(--radius-sm); padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 6px; min-height: 130px;
}
.stage:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stage.done { background: var(--pam-lavender-10); border-color: var(--pam-lavender); }
.stage.current { background: linear-gradient(180deg, var(--pam-lavender) 0%, var(--pam-lavender-10) 100%); border-color: var(--pam-lavender); }
.stage-num { font-family: 'Unbounded'; font-size: 18px; font-weight: 700; color: var(--pam-navy); }
.stage-title { font-size: 12px; font-weight: 500; color: var(--pam-navy); flex: 1; }
.stage-meta { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stage.done .stage-meta { color: var(--pam-teal); }
.stage.current .stage-meta { color: var(--pam-navy); font-weight: 700; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 18px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 16px; align-items: center; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.doc-row:hover { background: var(--pam-lavender-10); border-color: var(--pam-lavender); }
.doc-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--pam-lightblue); display: grid; place-items: center; font-size: 16px; }
.doc-name { font-weight: 500; color: var(--pam-navy); }
.doc-stage { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.doc-status { font-size: 11px; padding: 4px 10px; border-radius: 100px; background: var(--bg); color: var(--text-muted); font-weight: 500; }
.doc-status.draft { background: var(--pam-yellow); color: #7A5C00; }
.doc-status.ready { background: var(--pam-lime); color: #3D5F0F; }
.doc-status.sent { background: var(--pam-skyblue); color: var(--pam-navy); }

/* ========== PROFILE ========== */
.profile-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.profile-tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 100px; align-self: start; }
.profile-tab {
  background: transparent; border: 0; text-align: left; padding: 11px 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; color: var(--text-muted); cursor: pointer; font-weight: 500;
}
.profile-tab.active { background: var(--panel); color: var(--pam-navy); box-shadow: var(--shadow); }
.profile-form { background: var(--panel); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-family: 'Unbounded'; font-weight: 700; font-size: 16px; color: var(--pam-navy); margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.profile-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.profile-form textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text); font-family: inherit; background: var(--panel); min-height: 76px; resize: vertical; width: 100%; box-sizing: border-box; }
.profile-form textarea:focus { outline: none; border-color: var(--pam-teal); box-shadow: 0 0 0 3px rgba(15,117,151,.12); }
.label-block { display: block !important; margin-bottom: 18px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 100px;
  font-size: 12px !important; color: var(--text) !important; cursor: pointer; background: var(--panel);
  transition: background .15s, border-color .15s;
}
.chip:has(input:checked) { background: var(--pam-lavender); border-color: var(--pam-lavender); }
.chip input { width: 14px; height: 14px; accent-color: var(--pam-navy); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ========== TEMPLATES ========== */
.search-row { display: flex; gap: 14px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 240px; max-width: 420px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
  background: var(--panel); border: 1px solid var(--border); padding: 8px 14px; border-radius: 100px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; font-family: inherit; font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-pill:hover { background: var(--pam-lavender-10); }
.filter-pill.active { background: var(--pam-navy); color: #fff; border-color: var(--pam-navy); }

.templates-list { display: flex; flex-direction: column; gap: 16px; }
.tpl-group { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tpl-group-head { padding: 16px 20px; background: var(--pam-lavender-10); display: flex; align-items: center; gap: 14px; }
.tpl-group-num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--pam-navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; font-family: 'Unbounded';
  flex-shrink: 0;
}
.tpl-group-title { font-weight: 700; color: var(--pam-navy); font-size: 15px; }
.tpl-group-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tpl-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0; }
.tpl-item {
  padding: 16px 20px; border-top: 1px solid var(--border); border-right: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
  display: flex; flex-direction: column; gap: 6px;
}
.tpl-item:hover { background: var(--pam-lavender-10); }
.tpl-item-name { font-weight: 500; color: var(--pam-navy); font-size: 14px; }
.tpl-item-meta { font-size: 11px; color: var(--text-muted); }
.tpl-item-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700;
  color: var(--pam-teal); background: var(--pam-lightblue); padding: 2px 8px; border-radius: 4px; align-self: flex-start; }

/* ========== TEMPLATE DETAIL ========== */
.tpl-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; align-items: stretch; }
.tpl-side { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; max-height: calc(100vh - 200px); }
.tpl-side h3 { margin: 0; }
.tpl-fields { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.tpl-autosave-hint { font-size: 11px; color: #059669; text-align: right; margin-top: 2px; transition: opacity .3s; }
.tpl-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.tpl-field input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text); font-family: inherit; }
.tpl-field.auto { background: var(--pam-lavender-10); padding: 8px 10px; border-radius: 6px; }
.tpl-field.auto label::after { content: " · з профілю"; font-weight: 600; color: var(--pam-navy); opacity: 0.65; }
.tpl-field.auto input { border-color: var(--pam-lavender); background: #fff; }
.tpl-field-empty { border: 2px solid #f0c000 !important; background: #fffbea !important; }
.tpl-field-empty::placeholder { color: #a07800; }
.tpl-note { background: #f5f5f5; border-left: 3px solid #bbb; border-radius: 4px; padding: 10px 14px; margin-bottom: 16px; font-size: 12px; color: #777; line-height: 1.5; }

.ai-box {
  background: linear-gradient(135deg, var(--pam-lavender) 0%, var(--pam-skyblue) 100%);
  border-radius: var(--radius); padding: 16px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
}
.ai-box > div:nth-child(2) { grid-column: 2; }
.ai-box .btn { grid-column: 1 / -1; background: var(--pam-navy); color: #fff; }
.ai-icon { font-size: 22px; background: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--pam-navy); }
.ai-title { font-weight: 700; color: var(--pam-navy); font-size: 14px; }
.ai-sub { font-size: 11px; color: var(--pam-navy); opacity: 0.75; }

.tpl-preview { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; flex: 1; height: calc(100vh - 200px); display: flex; flex-direction: column; }
.tpl-toolbar { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); background: var(--bg); flex-wrap: wrap; }
.tpl-toolbar .btn:last-child { margin-left: auto; }
.tpl-doc { background: #e8e8e8; padding: 20px; overflow-y: auto; min-height: 500px; max-height: calc(100vh - 200px); flex: 1; }
.tpl-doc h1 { font-size: 16px; font-weight: 700; text-align: center; margin: 0 0 16px; font-family: "Times New Roman", Georgia, serif; }
.tpl-doc h2 { font-size: 15px; font-weight: 700; text-align: center; margin: 20px 0 14px; font-family: "Times New Roman", Georgia, serif; }
.tpl-doc h3 { font-size: 14px; font-weight: 700; margin: 16px 0 10px; font-family: "Times New Roman", Georgia, serif; }
.tpl-doc p { margin: 0 0 12px; text-align: justify; font-size: 14px; }
.tpl-doc ul, .tpl-doc ol { margin: 0 0 12px; padding-left: 24px; }
.tpl-doc li { margin-bottom: 6px; font-size: 14px; }
.tpl-doc table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13px; }
.tpl-doc td, .tpl-doc th { border: 1px solid #aaa; padding: 6px 8px; vertical-align: top; }
.tpl-doc th { background: #f0f0f0; font-weight: 700; }
.tpl-doc .doc-header { text-align: center; margin-bottom: 30px; }
.tpl-doc .doc-title { font-size: 15px; font-weight: 700; margin: 30px 0 20px; text-align: center; text-transform: uppercase; }
.tpl-doc .field-val { background: var(--pam-yellow); padding: 1px 4px; border-radius: 3px; font-weight: 500; color: var(--pam-navy); }
.tpl-doc .sig-row { display: flex; justify-content: space-between; margin-top: 40px; font-size: 13px; }

/* ========== ROADMAP ========== */
.roadmap { display: flex; flex-direction: column; gap: 16px; }
.roadmap-stage {
  background: var(--panel); border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 56px 1fr auto; gap: 20px; align-items: flex-start;
  border-left: 4px solid var(--pam-lavender);
}
.roadmap-stage.done { border-left-color: var(--pam-lime); }
.roadmap-stage.current { border-left-color: var(--pam-peach); background: var(--pam-lavender-10); }
.roadmap-num {
  width: 56px; height: 56px; border-radius: 50%; background: var(--pam-navy); color: #fff;
  display: grid; place-items: center; font-family: 'Unbounded'; font-weight: 700; font-size: 20px;
}
.roadmap-stage.done .roadmap-num { background: var(--pam-lime); color: var(--pam-navy); }
.roadmap-stage.current .roadmap-num { background: var(--pam-peach); }
.roadmap-content h3 { margin-bottom: 4px; }
.roadmap-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.roadmap-docs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.roadmap-doc-chip {
  font-size: 11px; background: var(--bg); color: var(--text); padding: 4px 10px; border-radius: 100px;
  border: 1px solid var(--border); cursor: pointer;
}
.roadmap-doc-chip:hover { background: var(--pam-lavender); border-color: var(--pam-lavender); }
.roadmap-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; color: var(--text-muted); }
.roadmap-stage.done .roadmap-status { color: var(--pam-teal); }
.roadmap-stage.current .roadmap-status { color: var(--pam-peach); }

/* ========== HELP ========== */
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.help-card {
  background: var(--panel); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit; border: 1px solid transparent; transition: border-color .15s, transform .15s;
}
.help-card:hover { border-color: var(--pam-lavender); transform: translateY(-2px); text-decoration: none; }
.help-card h3 { margin: 0 0 6px; }
.help-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ========== TOAST / MODAL ========== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--pam-navy); color: #fff; padding: 12px 22px; border-radius: 100px;
  box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; z-index: 1000;
  animation: slideUp .3s ease-out;
}
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.modal {
  position: fixed; inset: 0; background: rgba(61,67,89,0.5);
  display: grid; place-items: center; z-index: 1000; padding: 20px;
}
.modal-card { background: var(--panel); border-radius: var(--radius); padding: 32px; max-width: 520px; width: 100%; position: relative; box-shadow: var(--shadow-lg); }
.modal-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: var(--bg); cursor: pointer; font-size: 14px; color: var(--text-muted); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .cards-3 { grid-template-columns: 1fr 1fr; }
  .stages { grid-template-columns: repeat(3, 1fr); }
  .tpl-grid { grid-template-columns: 1fr; }
  .tpl-side { position: static; }
  .login-grid { grid-template-columns: 1fr; max-width: 540px; }
  .login-hero { padding: 36px 32px; }
  .login-card { padding: 36px 32px; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar-footer { display: none; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav-item { flex-shrink: 0; }
  .view { padding: 20px; }
  .cards-3 { grid-template-columns: 1fr; }
  .stages { grid-template-columns: 1fr 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-tabs { flex-direction: row; overflow-x: auto; position: static; }
  .profile-tab { flex-shrink: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 14px 20px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}

/* ===== Progress status card (step 1) ===== */
.progress-status-body { display: flex; flex-direction: column; gap: 14px; margin: 10px 0 14px; }
.progress-status-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.progress-status-label { font-size: 13px; color: #333; display: flex; align-items: center; gap: 6px; }
.progress-status-label .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.progress-status-label .dot-self { background: #f5b942; }
.progress-status-label .dot-approved { background: #3db57a; }
.progress-status-value { font-size: 13px; font-weight: 600; color: #111; }
.progress-status-bar { grid-column: 1 / -1; height: 6px; background: #eee; border-radius: 3px; overflow: hidden; }
.progress-status-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #a78bfa, #7c3aed); transition: width .4s ease; }
.progress-status-row:nth-child(2) .progress-status-bar > span { background: linear-gradient(90deg, #6ee7b7, #10b981); }

/* ===== Template detail editor (step 2) ===== */
textarea.autogrow { width: 100%; min-height: 60px; padding: 8px 10px; font: inherit; border: 1px solid #d6d6e1; border-radius: 6px; resize: none; overflow: hidden; background: #fff; color: #222; box-sizing: border-box; }
textarea.autogrow:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.tpl-upload-stub { background: #faf5ff; border: 1px dashed #c4b5fd; padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.tpl-upload-stub input[type="file"] { display: block; margin: 6px 0; font-size: 12px; color: #777; }
.tpl-upload-hint { font-size: 11.5px; color: #7c3aed; line-height: 1.4; }

/* ===== Stage detail ===== */
.stage-detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.stage-detail-main { display: flex; flex-direction: column; gap: 24px; }
.stage-detail-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

/* Metadata badge pills */
.stage-meta-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stage-meta-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-type     { background: #E6F1FB; color: #0C447C; }
.badge-diff-low { background: #EAF3DE; color: #3B6D11; }
.badge-diff-mid { background: #FAEEDA; color: #854F0B; }
.badge-diff-high{ background: #FCEBEB; color: #A32D2D; }
.badge-duration { background: #F1EFE8; color: #5F5E5A; }
.badge-who      { background: #EEEDFE; color: #3C3489; }

/* Steps ordered list */
.stage-steps-list { margin: 10px 0 0; padding-left: 22px; }
.stage-steps-list li { line-height: 1.8; margin-bottom: 10px; color: #333; font-size: 14px; padding-left: 4px; }

/* Warning box */
.stage-warning-box { background: #FAEEDA; border-left: 4px solid #E07A1F; border-radius: 8px; padding: 16px; font-size: 13.5px; color: #4A2E08; line-height: 1.55; }
.stage-warning-box strong { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: #854F0B; }

/* Result box */
.stage-result-box { background: #EAF3DE; border-left: 4px solid #4A9022; border-radius: 8px; padding: 16px; font-size: 13.5px; color: #1E4208; line-height: 1.55; }
.stage-result-box strong { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: #3B6D11; }

/* Unified "Документи етапу" section */
.stage-docs-list { margin-top: 8px; }
.stage-doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 0.5px solid #eee; font-size: 13px; }
.stage-doc-row:last-child { border-bottom: none; }
.stage-doc-row-fill { cursor: pointer; }
.stage-doc-row-fill:hover .stage-doc-title { color: #3C3489; text-decoration: underline; }
.stage-doc-row-local { cursor: pointer; }
.stage-doc-row-local:hover .stage-doc-title { color: #0C447C; text-decoration: underline; }
.doc-type-badge { display: inline-flex; align-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 3px 8px; border-radius: 20px; white-space: nowrap; flex-shrink: 0; }
.doc-type-info { background: #E6F1FB; color: #0C447C; }
.doc-type-fill { background: #EEEDFE; color: #3C3489; }
.stage-doc-title { flex: 1; color: var(--pam-teal); text-decoration: none; line-height: 1.5; }
.stage-doc-title:hover { text-decoration: underline; }
.stage-doc-row-fill .stage-doc-title { color: var(--text); }

.stage-status-card { display: flex; flex-direction: column; gap: 12px; }
.stage-badge-row { display: flex; flex-direction: column; gap: 6px; }
.stage-badge { padding: 8px 10px; border-radius: 6px; font-size: 13px; background: #f6f5fa; color: #666; border: 1px solid #eee; }
.stage-badge.active.stage-badge-self { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.stage-badge.active.stage-badge-approved { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.stage-report-display { padding: 10px 12px; background: #f9fafb; border-left: 3px solid #7c3aed; border-radius: 4px; font-size: 13px; }
.stage-report-display .report-label { font-weight: 600; margin-bottom: 4px; color: #333; }
.stage-report-display .report-text { color: #444; line-height: 1.5; }
.stage-report-display .report-meta { font-size: 11.5px; color: #888; margin-top: 6px; }

.stage-mini-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.stage-mini-badge { font-size: 11px; padding: 2px 8px; background: #f6f5fa; border-radius: 10px; color: #555; }

.roadmap-stage.clickable { cursor: pointer; transition: all .15s; }
.roadmap-stage.clickable:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,58,237,.15); border-color: #c4b5fd; }

/* Mark-form overlay */
.stage-mark-form { position: fixed; inset: 0; background: rgba(30,25,50,.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.stage-mark-form-inner { background: #fff; border-radius: 12px; padding: 24px; max-width: 500px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.stage-mark-form-inner h3 { margin: 0 0 8px; }
.mark-form-sub { color: #666; font-size: 13.5px; line-height: 1.5; margin: 0 0 16px; }
.stage-mark-form-inner label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #333; }
.stage-mark-form-inner textarea { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 10px; font: inherit; border: 1px solid #d6d6e1; border-radius: 6px; resize: vertical; min-height: 80px; }
.stage-mark-form-inner input[type="file"] { margin-top: 4px; font-size: 12px; color: #777; display: block; }
.mark-form-hint { display: block; margin-top: 6px; font-size: 11.5px; color: #9a91b7; font-weight: 400; font-style: italic; }
.stage-mark-form-inner .req { color: #e11d48; }
.mark-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.stage-admin-comment { background: #fff7ed; border-color: #fed7aa; }

@media (max-width: 960px) {
  .stage-detail-grid { grid-template-columns: 1fr; }
  .stage-detail-side { position: static; }
}

/* ===== Businesses repeater (step 4) ===== */
.section-hint { color: #666; font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
.businesses-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.business-empty { padding: 18px; background: #faf9fe; border: 1px dashed #d6d0ef; border-radius: 8px; text-align: center; color: #777; font-size: 13.5px; }
.business-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px; background: #faf9fe; border: 1px solid #ede9fe; border-radius: 8px; }
.business-num { width: 26px; height: 26px; border-radius: 50%; background: #7c3aed; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.business-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.business-fields input { padding: 6px 8px; border: 1px solid #d6d6e1; border-radius: 5px; font-size: 13px; background: #fff; }
.business-fields input:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.1); }
.business-remove { width: 30px; height: 30px; background: none; border: none; cursor: pointer; border-radius: 4px; font-size: 14px; opacity: .6; transition: all .15s; }
.business-remove:hover { opacity: 1; background: #fee2e2; }

/* ===== Notes (step 4) ===== */
.notes-toolbar { margin-bottom: 14px; }
.notes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.notes-empty { padding: 40px 20px; text-align: center; color: #777; background: #faf9fe; border: 1px dashed #d6d0ef; border-radius: 10px; }
.notes-empty-icon { font-size: 32px; margin-bottom: 8px; }
.note-card { background: #fff; border: 1px solid #eee; border-radius: 8px; padding: 14px; cursor: pointer; transition: all .15s; }
.note-card:hover { border-color: #7c3aed; box-shadow: 0 4px 12px rgba(124,58,237,.1); transform: translateY(-1px); }
.note-card-title { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; color: #222; }
.note-card-body { font-size: 13px; color: #555; line-height: 1.45; margin-bottom: 10px; }
.note-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: #888; gap: 6px; flex-wrap: wrap; }
.note-stage-chip { padding: 2px 8px; background: #ede9fe; color: #6d28d9; border-radius: 10px; font-size: 11px; font-weight: 500; }
.note-editor { position: fixed; inset: 0; background: rgba(30,25,50,.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.note-editor-inner { background: #fff; border-radius: 12px; padding: 24px; max-width: 560px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto; }
.note-editor-inner h3 { margin: 0 0 16px; }
.note-editor-inner label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #333; }
.note-editor-inner input[type="text"], .note-editor-inner textarea, .note-editor-inner select { width: 100%; box-sizing: border-box; margin-top: 4px; padding: 8px 10px; font: inherit; border: 1px solid #d6d6e1; border-radius: 6px; background: #fff; }
.note-editor-inner textarea { resize: vertical; min-height: 100px; }
.note-editor-inner input:focus, .note-editor-inner textarea:focus, .note-editor-inner select:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.15); }
.note-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.note-editor-actions [data-note-delete] { margin-right: auto; color: #dc2626; }

/* ===== Help (step 4) ===== */
.help-section { margin-bottom: 28px; }
.help-section-pinned { background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%); border: 1px solid #fde68a; border-radius: 12px; padding: 18px 22px; }
.help-section-pinned .help-section-title { color: #78350f; }
.help-section-title { font-size: 17px; margin: 0 0 4px; color: #222; }
.help-section-sub { color: #666; font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.help-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.help-card { background: #fff; border: 1px solid #eee; border-radius: 8px; padding: 14px; display: block; text-decoration: none; color: inherit; transition: all .15s; }
.help-card:hover { border-color: #7c3aed; box-shadow: 0 4px 12px rgba(124,58,237,.1); }
.help-card h3 { font-size: 14px; margin: 0 0 6px; color: #222; }
.help-card p { font-size: 13px; color: #555; line-height: 1.5; margin: 0; }
.help-card-link { margin-top: 8px; font-size: 11.5px; color: #7c3aed; font-weight: 500; }
.help-section-pinned .help-card { background: #fffbeb; border-color: #fde68a; }
.help-section-pinned .help-card:hover { border-color: #d97706; }

/* Assistant */
.help-assistant { background: #faf5ff; border: 1px solid #e9d5ff; border-radius: 12px; padding: 18px 22px; }
.help-assistant .help-section-title { color: #581c87; }
.assistant-box { display: flex; gap: 8px; margin-bottom: 12px; }
.assistant-box input { flex: 1; padding: 10px 12px; border: 1px solid #d6d6e1; border-radius: 6px; font: inherit; }
.assistant-box input:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.15); }
.assistant-results { display: flex; flex-direction: column; gap: 10px; }
.assistant-intro { font-size: 13px; color: #6d28d9; font-weight: 500; margin-bottom: 4px; }
.assistant-result { background: #fff; border: 1px solid #e9d5ff; border-radius: 8px; padding: 14px; }
.assistant-result-card h4 { font-size: 14px; margin: 0 0 6px; color: #222; }
.assistant-result-card p { font-size: 13px; color: #555; line-height: 1.5; margin: 0 0 10px; }
.assistant-feedback { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid #f3e8ff; font-size: 12.5px; color: #666; flex-wrap: wrap; }
.feedback-thanks { color: #059669; font-weight: 500; font-size: 13px; }
.feedback-details { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.feedback-details textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d6d6e1; border-radius: 6px; font: inherit; resize: vertical; }
.feedback-details textarea:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 2px rgba(124,58,237,.15); }
.assistant-no-result { background: #fff; border: 1px solid #fde68a; border-radius: 8px; padding: 14px; }
.no-result-text { font-size: 14px; margin-bottom: 10px; color: #92400e; }
.no-result-feedback p { font-size: 13px; color: #666; margin: 0 0 8px; }
.no-result-feedback textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d6d6e1; border-radius: 6px; font: inherit; resize: vertical; margin-bottom: 8px; }

@media (max-width: 720px) {
  .business-fields { grid-template-columns: 1fr; }
  .business-row { grid-template-columns: auto 1fr auto; }
}

/* ===== Document preview modal ===== */
.doc-preview-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 1000; overflow-y: auto; }
.doc-preview-modal { background: white; border-radius: 12px; width: 100%; max-width: 800px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
.doc-preview-bar { flex-shrink: 0; padding: 16px 20px; background: #1a1a2e; color: white; display: flex; align-items: center; justify-content: space-between; }
.doc-preview-title { font-size: 14px; font-weight: 500; }
.doc-preview-bar-actions { display: flex; gap: 8px; align-items: center; }
.doc-preview-dl { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); color: #fff; font-size: 13px; cursor: pointer; padding: 5px 12px; border-radius: 4px; transition: background .15s; white-space: nowrap; }
.doc-preview-dl:hover { background: rgba(255,255,255,.28); }
.doc-preview-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; padding: 4px 10px; border-radius: 4px; transition: background .15s; }
.doc-preview-close:hover { background: rgba(255,255,255,.15); }
.doc-preview-page { flex: 1; overflow-y: auto; padding: 0; background: #e8e8e8; }

.tpl-doc .docx-wrapper,
.doc-preview-page .docx-wrapper {
  background: #e8e8e8 !important;
  padding: 20px !important;
}
.tpl-doc .docx-wrapper > section.docx,
.tpl-doc .docx-wrapper > .docx,
.doc-preview-page .docx-wrapper > section.docx,
.doc-preview-page .docx-wrapper > .docx {
  background: white !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15) !important;
  margin: 0 auto 20px auto !important;
}
.docx-wrapper { background: #e8e8e8 !important; padding: 20px !important; }
.docx-wrapper section.docx { background: white !important; box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; }

/* ===== Auth error message ===== */
.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Email verification screen ===== */
.verify-card {
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}
.verify-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--pam-teal);
}
.verify-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--pam-navy);
  margin: 0 0 4px;
}
.verify-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 4px;
}
.verify-body strong {
  color: var(--pam-navy);
  word-break: break-all;
}
.verify-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}
.verify-spam {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.disclaimer-footer {
  margin-top: auto;
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  background: white;
  text-align: center;
}
.disclaimer-footer img.logobar {
  display: block;
  max-width: 600px;
  width: 100%;
  margin: 12px auto 0;
  background: white;
  padding: 8px;
  border-radius: 6px;
}
.login-disclaimer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}
.logobar-login {
  display: block;
  max-width: 100%;
  width: 420px;
  margin: 12px auto 0;
  background: white;
  padding: 8px;
  border-radius: 6px;
}


.login-video {
  margin-top: 24px;
  border-radius: 8px;
  overflow: hidden;
}

.sidebar-video-link {
  display: block;
  font-size: 11px;
  color: var(--pam-lavender);
  text-decoration: none;
  margin: -16px 0 16px;
  opacity: 0.8;
}
.sidebar-video-link:hover {
  opacity: 1;
}
