:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --text: #14222E;
  --accent: #175CD3;
  --accent-dark: #0B3B8A;
  --neutral: #66748C;
  --err: #D64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 34, 46, .06), 0 8px 24px rgba(20, 34, 46, .08);
  --ease: cubic-bezier(0.2, 0.0, 0.0, 1.0);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
.hidden { display: none !important; }

h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 24px; font-weight: 600; margin: 0 0 16px; }
h3 { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.lead { font-size: 17px; color: var(--neutral); }
.muted { color: var(--neutral); }
.small { font-size: 13px; }
.overline { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 8px; }
em { color: var(--err); font-style: normal; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid #E6EBF0;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 30px; height: 30px; }
.brand-name { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab {
  border: none; background: transparent; color: var(--text); cursor: pointer;
  font-size: 15px; font-weight: 600; padding: 8px 12px; border-radius: 8px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { font-size: 13px; color: var(--neutral); font-weight: 600; }
.role-switch {
  border: 1px solid #D5DCE4; border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-weight: 600; background: var(--surface); color: var(--text);
}
.offline-banner { background: #E1EAF8; color: var(--accent-dark); text-align: center; padding: 8px; font-weight: 600; font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; padding: 10px 16px; border-radius: 8px;
  text-decoration: none; transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: rgba(23, 92, 211, .08); }
.btn-ghost { background: transparent; color: var(--neutral); border: 1px solid #D5DCE4; }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn-danger:hover { background: rgba(214, 69, 69, .08); }

/* Screens */
.screen { display: none; padding: 24px 16px; max-width: 1200px; margin: 0 auto; }
.screen.active { display: block; animation: fadeUp .3s var(--ease); }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Hero */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 32px; }
.hero-img { width: 100%; height: 100%; object-fit: cover; min-height: 220px; }
.hero-copy { padding: 24px 28px; }

/* Sections */
.section { margin-bottom: 32px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(20, 34, 46, .12); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.feature-img { border-radius: 10px; margin-bottom: 12px; width: 100%; height: 150px; object-fit: cover; }

/* Lead section */
.lead-section { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.lead-img { border-radius: var(--radius); width: 100%; max-height: 220px; object-fit: cover; margin-bottom: 12px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea {
  border: 1px solid #D5DCE4; border-radius: 8px; padding: 10px 12px; font-size: 15px;
  font-family: inherit; background: var(--surface); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field.checkbox { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 500; }
.field.checkbox input { width: 18px; height: 18px; }
.err { color: var(--err); font-size: 13px; font-weight: 500; min-height: 16px; }
.err:empty { display: none; }
.form-result { font-size: 14px; font-weight: 600; }
.form-result.ok { color: var(--accent-dark); }
.form-result.fail { color: var(--err); }

.inline-form { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }

/* Contacts */
.contact-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.contact-list li { display: flex; align-items: center; gap: 10px; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }
.h-icon { width: 22px; height: 22px; vertical-align: -4px; margin-right: 6px; }

/* Auth */
.auth-card { max-width: 420px; margin: 24px auto; text-align: center; }
.auth-icon { width: 48px; height: 48px; margin: 0 auto 12px; }
.auth-card .form { text-align: left; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kcol { background: #ECEFF3; border-radius: var(--radius); padding: 10px; min-height: 160px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; padding: 4px 4px 10px; }
.kcol-head .count { background: var(--surface); border-radius: 20px; padding: 1px 8px; font-size: 12px; color: var(--neutral); }
.klane { display: flex; flex-direction: column; gap: 8px; }
.kcard {
  background: var(--surface); border-radius: 10px; padding: 10px 12px; cursor: grab;
  border-left: 4px solid var(--neutral); box-shadow: 0 1px 3px rgba(20,34,46,.08);
  transition: box-shadow .2s var(--ease);
}
.kcard.dragging { opacity: .5; }
.kcard:hover { box-shadow: var(--shadow); }
.kcard .ktitle { font-weight: 600; font-size: 14px; }
.kcard .kmeta { font-size: 12px; color: var(--neutral); }
.kcard.prio-Срочный { border-left-color: var(--accent); }
.kcard.prio-VIP { border-left-color: var(--accent-dark); background: #EEF4FF; }
.kcard.prio-Обычный { border-left-color: var(--neutral); }
.kcard.over { outline: 2px dashed var(--accent); }
.status-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.chip-icon { width: 14px; height: 14px; }
.chip-new { color: var(--neutral); background: #ECEFF3; }
.chip-work { color: var(--accent); background: #E8F0FD; }
.chip-done { color: var(--text); background: #E6EBF0; }
.chip-paid { color: var(--accent-dark); background: #E1EAF8; }
.chip-cancel { color: var(--neutral); background: #ECEFF3; }

/* Clients */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 24px; }
.client-card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.client-card .avatar { width: 40px; height: 40px; border-radius: 50%; margin-bottom: 10px; background: #E8F0FD; }
.client-card h3 { font-size: 16px; }
.client-card .contact { font-size: 14px; color: var(--neutral); }
.client-actions { display: flex; gap: 8px; margin-top: 12px; }
.client-actions .btn { font-size: 13px; padding: 6px 10px; }

/* Reports */
.report-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 24px; }
.segments { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.seg-row { display: flex; align-items: center; gap: 10px; }
.seg-label { width: 96px; font-size: 13px; font-weight: 600; }
.seg-bar { flex: 1; height: 12px; background: #ECEFF3; border-radius: 20px; overflow: hidden; }
.seg-fill { height: 100%; border-radius: 20px; background: var(--accent); transition: width .25s var(--ease); }
.seg-val { width: 40px; text-align: right; font-size: 13px; font-weight: 700; }
.chart-wrap { width: 100%; }
.summary-list { list-style: none; padding: 0; margin: 0; }
.summary-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #ECEFF3; font-size: 15px; }
.summary-list li b { font-size: 18px; }
.export-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Notifications */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #ECEFF3; cursor: pointer; font-weight: 600; }
.switch-row > span:first-child { display: flex; align-items: center; gap: 8px; }
.switch-row input { display: none; }
.slider { width: 44px; height: 24px; background: #C7CFD9; border-radius: 20px; position: relative; transition: background .2s var(--ease); }
.slider::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .2s var(--ease); }
.switch-row input:checked + .slider { background: var(--accent); }
.switch-row input:checked + .slider::after { transform: translateX(20px); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #ECEFF3; }
.table th { color: var(--neutral); font-weight: 700; }

/* Empty state */
.empty-state { text-align: center; padding: 32px; color: var(--neutral); }
.empty-state img { width: 120px; margin: 0 auto 12px; }

/* Footer */
.footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 16px; border-top: 1px solid #E6EBF0; color: var(--neutral); font-size: 14px; }
.footer-icon { width: 24px; height: 24px; }

/* Responsive */
@media (max-width: 820px) {
  .hero, .lead-section, .report-grid { grid-template-columns: 1fr; }
  .topbar { gap: 8px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  h1 { font-size: 28px; }
}

@media (max-width: 480px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .tabs { justify-content: center; }
  .topbar-right { justify-content: center; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  .screen.active { animation: none; }
  .card:hover { transform: none; }
  .seg-fill { transition: none; }
}
