:root {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --text: #1f2430;
  --muted: #6a7488;
  --border: #cfd7e6;
  --primary: #5856d6;
  --primary-strong: #4745bf;
  --primary-soft: #e9e8ff;
  --sidebar-bg: #2f3542;
  --sidebar-text: #d7deef;
  --sidebar-hover: #3b4354;
  --success: #2eb85c;
  --danger: #e55353;
  --shadow: 0 14px 34px rgba(33, 42, 61, 0.12);
  --shadow-soft: 0 4px 14px rgba(33, 42, 61, 0.1);
}

* { box-sizing: border-box; }

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;
}

.title-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn .icon,
.nav-link .icon,
.rail-title .icon,
.rail-label .icon,
.table-link .icon,
.summary-link .icon {
  margin-right: 6px;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f9fbff 0%, #f1f4f9 100%);
  position: relative;
  min-height: 100vh;
}

.desktop-only-overlay {
  display: none;
}

.app-shell::before {
  content: "";
  position: absolute;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 190px;
  background: var(--sidebar-bg);
  border-right: 1px solid #27303e;
  pointer-events: none;
  z-index: 1;
}

.public-main {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

.public-page {
  width: min(960px, 100%);
}

.public-hero-title {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.fixed-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  display: grid;
  grid-template-columns: 140px 1fr 360px;
  align-items: center;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(33,42,61,.08);
}

.topbar-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #39476b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.topbar-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: #475569;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  display: inline-block;
  text-decoration: none;
}

.lang-btn.active {
  background: #2f6fd8;
  border-color: #2f6fd8;
  color: #fff;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  background: #fff;
  min-width: 170px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2f6fd8;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-meta {
  min-width: 0;
  line-height: 1.1;
}

.user-name {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: #6b7280;
}

.fixed-sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  width: 190px;
  background: var(--sidebar-bg);
  border-right: 1px solid #27303e;
  padding: 12px 10px;
  overflow: auto;
  z-index: 20;
}

.brand {
  color: #9ea8be;
  font-weight: 700;
  letter-spacing: .08em;
  font-size: 11px;
  margin-bottom: 10px;
  padding: 0 6px;
}

.nav-group { margin-bottom: 10px; }

.nav-link {
  display: flex;
  align-items: center;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
  margin: 4px 0;
  font-size: 13px;
  font-weight: 600;
  transition: all .18s ease;
  border-left: 3px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  background: var(--sidebar-hover);
  color: #ffffff;
  border-left-color: #8e8cff;
}

.with-rails {
  margin-top: 56px;
  margin-left: 190px;
  margin-right: 330px;
  min-height: calc(100vh - 56px);
}

.right-rail {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 330px;
  padding: 12px 10px;
  border-left: 1px solid var(--border);
  background: #f8faff;
  overflow: auto;
}

.rail-card {
  background: #fff;
  border: 1px solid #dde3ef;
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.rail-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #3a4270;
  display: flex;
  align-items: center;
}

.rail-label {
  font-size: 11px;
  color: #8a95a5;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 10px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.rail-input { height: 34px; font-size: 13px; }

.btn-sm { padding: 7px 10px; font-size: 12px; }

.current-case {
  background: #ecf9ef;
  color: #0f7b6c;
  border: 1px solid #d8f0df;
  border-radius: 6px;
  font-size: 12px;
  padding: 7px 9px;
  font-weight: 700;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
}

.progress-bar {
  height: 8px;
  background: #edf2fb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: #2f6fd8;
}

.progress-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-list li {
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  border: 1px solid #e8edf6;
  display: flex;
  align-items: center;
}

.progress-list li.ok {
  background: #effbf2;
  border-color: #d9efdf;
  color: #17663f;
}

.progress-list li.pending {
  background: #fff6ea;
  border-color: #f6dfbf;
  color: #9a670f;
}

.rail-note {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  background: #f8fbff;
  border: 1px solid #e6edf8;
  border-radius: 6px;
  padding: 8px;
}

.page {
  padding: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.btn {
  background: linear-gradient(180deg, #6a69e8 0%, var(--primary-strong) 100%);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(88, 86, 214, 0.34);
  transition: transform .15s ease, box-shadow .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(88, 86, 214, 0.4); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid #cdd2dc;
}

.input, textarea, select {
  width: 100%;
  border: 1px solid #cfd5df;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #a8a6f0;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

textarea { min-height: 120px; }

.form-row { margin-bottom: 12px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
}

.table tbody tr:hover {
  background: #f2f6ff;
}
.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.badge {
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.badge-success {
  background: #e8f7f3;
  border-color: #cfeee7;
  color: var(--success);
}
.badge-danger {
  background: #fdecec;
  border-color: #f7d5d3;
  color: var(--danger);
}

.kv { color: var(--muted); font-size: 14px; }
pre {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  color: #334155;
}

a { color: var(--primary-strong); }

a:hover { text-decoration: underline; }

.table-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.summary-link {
  display: inline-flex;
  align-items: center;
}

.card-narrow { max-width: 560px; }
.card-medium { max-width: 720px; }
.card-wide { max-width: 860px; }
.card-spaced { margin-top: 16px; }

.badge-inline { display: inline-block; margin-bottom: 12px; }
.kv-spaced-top { margin-top: 12px; }

.hr-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.decision-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 260px;
}

.action-row {
  display: flex;
  gap: 8px;
}

.input-compact { width: 110px; }

.btn-link {
  text-decoration: none;
  display: inline-block;
}

.pre-wrap { white-space: pre-wrap; }

.platform-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
}

.agree-option {
  margin-top: 4px;
  font-weight: 500;
}

.agree-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #2f6fd8;
  cursor: pointer;
}

.trial-block {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #e6eaf2;
  background: #f8fafc;
}

.trial-block-warning {
  border-color: #f2d6aa;
  background: #fff6ea;
}

.trial-block-danger {
  border-color: #f4c7c3;
  background: #fdeeee;
}

.list-tight {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.mindmap-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  overflow: auto;
}

.mindmap-wrap .mermaid {
  min-height: 260px;
}

.avatar-settings-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 14px;
  align-items: start;
}

.avatar-current-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}

.avatar-current-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f3f6fc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 30px;
  font-weight: 700;
  color: #3b4b7a;
}

.avatar-current-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-cropper-wrap {
  width: 100%;
  max-width: 440px;
  min-height: 240px;
  border: 1px dashed #cfd7e6;
  border-radius: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
  background: #fafcff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#avatar-cropper-image {
  display: none;
  max-width: 100%;
}

@media (max-width: 1280px) {
  .right-rail {
    width: 280px;
    display: block;
  }
  .with-rails {
    margin-right: 280px;
  }
}

@media (max-width: 1100px) {
  .right-rail {
    width: 240px;
    display: block;
  }
  .with-rails {
    margin-right: 240px;
  }
}

@media (max-width: 920px) {
  .avatar-settings-grid {
    grid-template-columns: 1fr;
  }

  .app-shell::before {
    width: 170px;
  }
  .fixed-sidebar {
    width: 170px;
    display: block;
  }
  .right-rail {
    width: 220px;
    display: block;
  }
  .with-rails {
    margin-left: 170px;
    margin-right: 220px;
  }
  .fixed-topbar {
    grid-template-columns: 80px 1fr 260px;
  }
  .user-role {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell::before {
    width: 150px;
  }
  .fixed-sidebar {
    width: 150px;
    display: block;
  }
  .right-rail {
    width: 200px;
    display: block;
  }
  .with-rails {
    margin-left: 150px;
    margin-right: 200px;
  }
}

@media (max-width: 1199px) {
  body > *:not(.desktop-only-overlay) {
    display: none !important;
  }

  .desktop-only-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.78);
  }

  .desktop-only-card {
    max-width: 560px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #d4dceb;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    padding: 18px 20px;
  }

  .desktop-only-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #1e293b;
  }

  .desktop-only-card p {
    margin: 0 0 10px;
    color: #475569;
  }

  .desktop-only-card hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 12px 0;
  }
}
