:root {
  color-scheme: dark;
  --bg: #0d1016;
  --panel: #151a22;
  --panel-2: #1b222d;
  --text: #f0f4f8;
  --muted: #94a3b8;
  --line: #293241;
  --accent: #58c4b8;
  --accent-2: #f2c14e;
  --danger: #ef476f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
small, .muted { color: var(--muted); }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  padding: 24px 16px;
  background: #111720;
  border-right: 1px solid var(--line);
  z-index: 20;
  pointer-events: auto;
}
.brand {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 28px;
}
.brand span { color: var(--accent); }
nav { display: grid; gap: 6px; position: relative; z-index: 21; }
nav a, .list-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  pointer-events: auto;
}
nav a:hover, .list-item:hover { background: var(--panel-2); color: white; }
.nav-group {
  border-radius: 8px;
  color: #cbd5e1;
}
.nav-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-parent span {
  color: var(--muted);
}
.nav-group:not(.open) .nav-submenu {
  display: none;
}
.nav-group:hover .nav-submenu,
.nav-group:focus-within .nav-submenu {
  display: grid;
}
.nav-parent:hover,
.nav-group.open .nav-parent {
  background: var(--panel-2);
  color: white;
}
.nav-submenu {
  display: grid;
  gap: 4px;
  margin: 4px 0 4px 12px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.nav-submenu a {
  padding: 8px 10px;
  color: var(--muted);
}
.nav-submenu a:hover { color: white; }

.shell { margin-left: 240px; min-height: 100vh; position: relative; z-index: 1; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
}
.topbar p { color: var(--muted); margin-bottom: 2px; }
.topbar h1 { font-size: 26px; margin-bottom: 0; }
.userbar { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.top-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #10251f;
  color: var(--accent);
  font-weight: 800;
}
.content { padding: 28px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.metric span { display: block; color: var(--muted); }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.wide { grid-column: span 1; overflow-x: auto; }
.lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.employee-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.employee-hero h2 { margin-bottom: 4px; }
.employee-hero p { color: var(--muted); margin-bottom: 0; }
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.profile-avatar.big { font-size: 40px; }
.avatar-form { gap: 12px; }
.rating-badge {
  min-width: 116px;
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  background: #10251f;
  border: 1px solid #256d5f;
}
.rating-badge strong {
  display: block;
  font-size: 32px;
  line-height: 1;
  color: var(--accent);
}
.rating-badge span {
  display: block;
  margin-top: 6px;
  color: #cbd5e1;
}
.issue-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

form { display: grid; gap: 12px; }
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-form select { min-width: 220px; }
.inline-form button { padding: 9px 12px; }
label { display: grid; gap: 6px; color: var(--muted); }
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
}
.checkbox-row input {
  width: auto;
  margin-top: 4px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f141c;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #07110f;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #223044;
  color: #cfe1ff;
}
.timeline { display: grid; gap: 12px; padding-left: 20px; }
.timeline li { padding: 12px; background: #10161f; border: 1px solid var(--line); border-radius: 8px; }
.timeline span, .timeline code { display: block; color: var(--muted); margin-top: 4px; white-space: pre-wrap; }
.messages { display: grid; gap: 10px; margin-bottom: 14px; }
.messages.tall { min-height: 360px; }
.message, .notice {
  background: #10161f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.chat-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 150px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.chat-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: #10161f;
}
.chat-list h2 { margin: 4px 4px 10px; }
.chat-list-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  color: #cbd5e1;
}
.chat-list-item:hover,
.chat-list-item.active {
  background: var(--panel-2);
  color: white;
}
.chat-list-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #10251f;
  color: var(--accent);
  font-weight: 800;
}
.chat-list-item strong,
.chat-list-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-list-item span { color: var(--muted); font-size: 13px; }
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.team-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161f;
}
.team-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}
.team-card strong,
.team-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-card span { color: var(--muted); }
.chat-window {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  background: #0d1016;
}
.chat-empty {
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #111720;
}
.chat-header h2 { margin-bottom: 2px; }
.chat-header p { margin-bottom: 0; color: var(--muted); }
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow-y: auto;
}
.chat-bubble {
  width: fit-content;
  max-width: min(640px, 78%);
  padding: 10px 12px;
  border-radius: 8px;
  background: #18212d;
  border: 1px solid var(--line);
}
.chat-bubble.mine {
  align-self: flex-end;
  background: #10332d;
  border-color: #256d5f;
}
.bubble-meta {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.chat-bubble p { margin-bottom: 0; white-space: pre-wrap; }
.chat-photo,
.chat-video {
  display: block;
  max-width: 360px;
  max-height: 320px;
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  margin-bottom: 8px;
}
.chat-audio {
  width: 300px;
  max-width: 100%;
  margin-bottom: 8px;
}
.chat-file {
  display: inline-flex;
  padding: 8px 10px;
  border-radius: 8px;
  background: #10161f;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.transcript { display: block; margin-top: 6px; }
.chat-composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #111720;
}
.chat-composer textarea {
  min-height: 44px;
  max-height: 140px;
}
.attach-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 26px;
  cursor: pointer;
}
.attach-button input { display: none; }
.release {
  background: #10161f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.release + .release { margin-top: 10px; }
.release strong { display: block; margin-bottom: 6px; }
.access-scale {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.access-scale span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161f;
  color: #cbd5e1;
}
.access-scale b { color: var(--accent); }
.message p, .notice p { margin-bottom: 6px; }
.notice.unread { border-color: var(--accent-2); }
.regulation-document {
  display: grid;
  gap: 18px;
}
.regulation-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.regulation-section:last-child { border-bottom: 0; }
.regulation-section ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}
.regulation-accept { border-color: var(--accent-2); }
.list, .notices { display: grid; gap: 10px; }
.list-item { border: 1px solid var(--line); background: #10161f; }
.list-item span { display: block; color: var(--muted); }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

@media (max-width: 900px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  .sidebar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .shell { margin-left: 0; }
  .topbar, .lead-head, .employee-hero { align-items: flex-start; flex-direction: column; }
  .metrics, .split { grid-template-columns: 1fr; }
  .chat-shell { grid-template-columns: 1fr; }
  .chat-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-composer { grid-template-columns: 44px minmax(0, 1fr); }
  .chat-composer button { grid-column: 1 / -1; }
}
