:root {
  --bg: #F4F7FA;
  --surface: #FFFFFF;
  --text: #1E2A38;
  --accent: #FF8A00;
  --accent-dark: #123C63;
  --neutral: #5B6B7C;
  --green: #2E7D5B;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; color: var(--text); margin: 0 0 0.5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }

.hidden { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: var(--accent-dark); color: #fff;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand-logo { border-radius: 8px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  padding: 8px 12px; border-radius: 8px; font-size: 0.95rem;
  transition: background 200ms var(--ease), color 200ms var(--ease);
}
.tab:hover { background: rgba(255,255,255,0.14); }
.tab.active { background: var(--accent); color: #fff; }
.tab.tab-hidden { display: none; }

.rolebox { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.role-label { color: #fff; font-size: 0.9rem; }
#roleSel {
  padding: 6px 10px; border-radius: 8px; border: 0; font-size: 0.95rem;
  background: var(--surface); color: var(--text);
}

/* ===== Layout ===== */
main { max-width: 1120px; margin: 0 auto; padding: 16px; }
.screen { animation: fadeUp 250ms var(--ease); }
.screen-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.section { margin: 32px 0; }
.section h2 { margin-bottom: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type=search], .toolbar select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #d7dee7; font-size: 0.95rem;
}
.hint { color: var(--neutral); font-size: 0.9rem; }
.empty { text-align: center; padding: 24px; color: var(--neutral); }
.footer { margin-top: 40px; padding: 16px; text-align: center; color: var(--neutral); border-top: 1px solid #e4eaf0; }

/* ===== Hero ===== */
.hero {
  display: grid; grid-template-columns: 1fr; gap: 16px; align-items: center;
  background: linear-gradient(135deg, var(--accent-dark) 0%, #1d4a78 100%);
  color: #fff; border-radius: 16px; padding: 24px; overflow: hidden;
}
.hero-copy h1 { color: #fff; }
.hero-copy p { color: #eaf0f6; max-width: 44ch; }
.hero-img { width: 100%; height: auto; border-radius: 12px; display: block; }
.wide-img { width: 100%; height: auto; border-radius: 12px; display: block; margin-bottom: 12px; }

/* ===== Buttons ===== */
.btn {
  display: inline-block; border: 0; border-radius: 10px; cursor: pointer;
  padding: 10px 18px; font-size: 0.95rem; font-weight: 600;
  transition: transform 200ms var(--ease), background 200ms var(--ease), box-shadow 200ms var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #e57c00; }
.btn-ghost { background: transparent; color: var(--accent-dark); border: 1px solid var(--accent-dark); }
.btn-ghost:hover { background: rgba(18,60,99,0.08); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Forms ===== */
.lead-form, .login-card {
  display: grid; grid-template-columns: 1fr; gap: 12px;
  background: var(--surface); border-radius: 16px; padding: 20px;
  box-shadow: 0 2px 10px rgba(30,42,56,0.06);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.9rem; color: var(--text); font-weight: 500; }
.field input, .field select {
  padding: 10px 12px; border-radius: 8px; border: 1px solid #d7dee7; font-size: 1rem;
  background: var(--surface);
}
.field input.invalid, .field select.invalid { border-color: #c0392b; background: #fdf3f2; }
.consent label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.form-result { font-weight: 600; min-height: 1.2em; }
.form-result.ok { color: var(--green); }
.form-result.err { color: #c0392b; }
.login-card { max-width: 420px; margin: 40px auto; }
.err-msg { color: #c0392b; font-size: 0.85rem; }

/* ===== Capabilities / avatars ===== */
.cap-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
}
.cap {
  background: var(--surface); border-radius: 12px; padding: 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 0.9rem;
  box-shadow: 0 1px 6px rgba(30,42,56,0.05);
}
.avatar-row { display: flex; flex-wrap: wrap; gap: 20px; }
.avatar { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--neutral); }

/* ===== Slots ===== */
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.slot {
  background: var(--surface); border-radius: 10px; padding: 12px; border-left: 4px solid var(--green);
  font-size: 0.9rem;
}
.slot.occupied { border-left-color: var(--neutral); opacity: 0.65; }

/* ===== Kanban ===== */
.kanban { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.kcol {
  background: #e9eef4; border-radius: 12px; padding: 10px; min-width: 210px; flex: 1;
}
.kcol h3 { font-size: 0.95rem; padding: 4px 8px; border-radius: 8px; color: #fff; display: inline-block; }
.kcol[data-status="Новая"] h3 { background: var(--accent); }
.kcol[data-status="В работе"] h3 { background: var(--accent-dark); }
.kcol[data-status="Выполнена"] h3 { background: var(--green); }
.kcol[data-status="Оплачена"] h3 { background: var(--text); }
.kcol[data-status="Отменена"] h3 { background: var(--neutral); }
.kcards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.card {
  background: var(--surface); border-radius: 10px; padding: 10px; cursor: grab;
  box-shadow: 0 1px 5px rgba(30,42,56,0.08); font-size: 0.9rem;
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.5; }
.card.urgent { border-left: 4px solid #c0392b; }
.card.vip { border-left: 4px solid #9b59b6; }
.card .tag { font-size: 0.72rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; color: #fff; }
.tag.urgent { background: #c0392b; }
.tag.vip { background: #9b59b6; }
.kcol.drag-over { outline: 2px dashed var(--accent); }
.card .meta { color: var(--neutral); font-size: 0.8rem; }

/* ===== Lists / tables ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-row, .customer-card {
  background: var(--surface); border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 6px rgba(30,42,56,0.05);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.customer-card.deleted { opacity: 0.6; }
.list-row .grow { flex: 1; min-width: 160px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; color: #fff;
}
.badge.Новая { background: var(--accent); }
.badge.В\ работе { background: var(--accent-dark); }
.badge.Выполнена { background: var(--green); }
.badge.Оплачена { background: var(--text); }
.badge.Отменена { background: var(--neutral); }
.badge.утверждён { background: var(--green); }
.badge.отклонён { background: #c0392b; }
.badge.черновик { background: var(--neutral); }

.panel {
  background: var(--surface); border-radius: 12px; padding: 16px; margin: 14px 0;
  box-shadow: 0 1px 6px rgba(30,42,56,0.05);
}

/* ===== Dashboard ===== */
.pulse-banner {
  background: var(--accent); color: #fff; border-radius: 12px; padding: 12px 16px;
  font-weight: 600; margin-bottom: 14px; animation: fadeUp 250ms var(--ease);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.stat-card { background: var(--surface); border-radius: 12px; padding: 16px; box-shadow: 0 1px 6px rgba(30,42,56,0.05); }
.stat-card .num { font-size: 1.8rem; font-weight: 700; }
.stat-card .lbl { color: var(--neutral); font-size: 0.85rem; }
canvas { max-width: 100%; height: auto; }

.progress-bars { display: flex; flex-direction: column; gap: 12px; }
.pb-row { display: flex; align-items: center; gap: 10px; }
.pb-label { min-width: 110px; font-size: 0.9rem; }
.pb-track { flex: 1; height: 14px; background: #e9eef4; border-radius: 8px; overflow: hidden; }
.pb-fill { height: 100%; border-radius: 8px; transition: width 250ms var(--ease); }
.pb-seg { display: inline-block; height: 100%; }
.pb-seg.n { background: var(--accent); }
.pb-seg.w { background: var(--accent-dark); }
.pb-seg.r { background: var(--green); }
.pb-seg.o { background: var(--text); }

/* ===== Switch ===== */
.switch { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 0.95rem; }

/* ===== Animation ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 720px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .lead-form { grid-template-columns: 1fr 1fr; }
  .lead-form .field-wide { grid-column: 1 / -1; }
  h1 { font-size: 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
