:root {
  /* Светлая тема */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 8px 24px rgba(0,0,0,0.10);
  --border-color: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --radius: 12px;
  --transition: 0.2s ease;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --header-height: 64px;
  --toolbar-height: 48px;
}

/* Тёмная тема */
body.dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 8px 24px rgba(0,0,0,0.5);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background 0.3s, color 0.3s;
}
a { text-decoration: none; color: inherit; cursor:pointer; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ШАПКА */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
.logo { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 4px; white-space:nowrap; }
.logo span { color: var(--accent); }
.logo i { font-style: normal; background: var(--accent); color: #fff; padding: 0 8px; border-radius: 30px; font-size: 13px; margin-left: 4px; }

.header-search {
  flex: 1;
  max-width: 400px;
  min-width: 180px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 8px 16px 8px 40px;
  border: 1px solid var(--border-color);
  border-radius: 30px;
  background: var(--bg-secondary);
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}
.header-search .clear-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  font-size: 14px;
}
.header-search .clear-icon.visible { display: block; }

.header-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.danger:hover { border-color: var(--red); color: var(--red); }

.btn-login {
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-login:hover { border-color: var(--accent); color: var(--accent); }

.lang-select-wrapper select {
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 30px;
  background: var(--bg-secondary);
  font-size: 14px;
  color: var(--text-primary);
  appearance: none;
  cursor: pointer;
  font-family: var(--font);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
.lang-select-wrapper select:focus { outline: none; border-color: var(--accent); }

/* ХЛЕБНЫЕ КРОШКИ */
#breadcrumbs {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-primary);
}
#breadcrumbs a { color: var(--accent); text-decoration: none; }
#breadcrumbs a:hover { text-decoration: underline; }

/* ОСНОВНАЯ ОБЛАСТЬ */
#app { min-height: 70vh; padding: 16px 0; }

/* АНИМАЦИИ */
.page-enter { animation: fadeIn 0.3s ease forwards; }
.page-leave { animation: fadeOut 0.15s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-12px); } }

/* ФУТЕР */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 12px 0;
  margin-top: 20px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); transition: var(--transition); }
.footer-links a:hover { color: var(--accent); }

/* АДАПТИВНОСТЬ */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: 4px; }
  .header-search { max-width: 100%; }
  .header-actions { justify-content: center; }
}

/* Стили для вкладок и тулбара (договор) */
.toolbar .tabs button {
  padding: 4px 16px;
  border-radius: 30px;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.toolbar .tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.toolbar .tabs button:hover {
  border-color: var(--accent);
}

/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .header-actions {
    justify-content: center;
  }
  .container {
    padding: 0 10px;
  }
  .logo {
    font-size: 18px;
  }
  .nav-menu {
    gap: 8px;
    justify-content: center;
  }
  .nav-menu a {
    font-size: 13px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    top: 56px;
  }
  .toolbar .tabs {
    justify-content: center;
  }
  .toolbar .actions {
    justify-content: center;
  }
  .contract-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .contract-header .actions {
    justify-content: center;
  }
  .editor-area textarea {
    min-height: 200px;
    font-size: 14px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .analysis-report .risk-item {
    font-size: 13px;
  }
  .balance-bar .bar {
    height: 8px;
  }
  .modal-box {
    width: 95%;
    padding: 16px;
  }
  .comparison-view .side-by-side {
    grid-template-columns: 1fr;
  }
  .segment-grid {
    flex-wrap: wrap;
    justify-content: center;
  }
  .segment-card {
    min-width: 70px;
    max-width: 100px;
  }
  .quick-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .quick-item input {
    width: 100%;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
  .feed-scroll {
    animation-duration: 24s;
  }
  .hero h1 {
    font-size: 24px;
  }
  .hero .sub {
    font-size: 14px;
  }
  .scenario-card {
    padding: 12px 8px;
  }
  .scenario-card .icon {
    font-size: 28px;
  }
  .scenario-card .title {
    font-size: 14px;
  }
  .scenario-card .desc {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .logo {
    font-size: 16px;
  }
  .btn-icon {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  .btn-login {
    font-size: 12px;
    padding: 4px 12px;
  }
  .lang-select-wrapper select {
    font-size: 12px;
    padding: 4px 24px 4px 8px;
  }
  .toolbar .tabs button {
    font-size: 12px;
    padding: 2px 10px;
  }
  .toolbar .actions button {
    font-size: 11px;
    padding: 2px 8px;
  }
  .contract-header .type-select {
    font-size: 12px;
  }
  .contract-header .doc-title {
    font-size: 14px;
  }
  .modal-box h2 {
    font-size: 18px;
  }
}

/* Модальные окна (глобальные) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-box .close-btn {
  position: absolute; top: 12px; right: 16px;
  font-size: 24px; cursor: pointer; color: var(--text-muted);
  background: none; border: none;
}
