:root {
  color-scheme: light;
  --bg: #e8f1fb;
  --panel: rgba(255, 255, 255, 0.88);
  --card: #ffffff;
  --text: #17212b;
  --muted: #6d7d8d;
  --line: rgba(81, 107, 132, 0.2);
  --primary: #2aabee;
  --primary-dark: #168acd;
  --accent: #7edb91;
  --danger: #e15555;
  --own-bubble: #d7f7c2;
  --other-bubble: #ffffff;
  --shadow: 0 24px 80px rgba(31, 66, 99, 0.16);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #111827;
  --panel: rgba(24, 35, 50, 0.92);
  --card: #1f2937;
  --text: #f3f6fb;
  --muted: #a6b3c2;
  --line: rgba(217, 226, 239, 0.15);
  --other-bubble: #263244;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(42, 171, 238, 0.28), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(126, 219, 145, 0.24), transparent 34%),
    var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell, .admin-login {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}
.auth-card, .admin-login__card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.logo, .avatar {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-weight: 900;
}
h1, h2, h3 { margin: 0; }
.brand p, .muted { color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.tab, .chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--text);
  font-weight: 800;
}
.tab.active, .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
  background: var(--card);
  color: var(--text);
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(42, 171, 238, 0.14); }
.button {
  border: 0;
  border-radius: 14px;
  padding: 11px 15px;
  background: rgba(114, 136, 158, 0.14);
  color: var(--text);
  font-weight: 900;
}
.button.primary { background: var(--primary); color: #fff; box-shadow: 0 10px 20px rgba(42, 171, 238, 0.22); }
.button.danger { background: var(--danger); color: #fff; }
.button.small { padding: 7px 10px; border-radius: 999px; font-size: 12px; }

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 330px;
  width: min(1440px, calc(100vw - 24px));
  height: min(920px, calc(100vh - 24px));
  margin: 12px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}
.sidebar, .rightbar, .chat-panel { min-width: 0; overflow: hidden; background: var(--panel); }
.sidebar, .rightbar { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); }
.rightbar { border-left: 1px solid var(--line); }
.profile { display: flex; gap: 10px; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); }
.profile__body { min-width: 0; flex: 1; }
.profile strong, .profile span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { color: #d99b00; font-weight: 900; }
.nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 12px; border-bottom: 1px solid var(--line); }
.nav button { border: 0; border-radius: 14px; padding: 10px; background: transparent; color: var(--text); font-weight: 900; }
.nav button.active { background: rgba(42, 171, 238, 0.16); color: var(--primary-dark); }
.list, .right-content { overflow: auto; padding: 12px; }
.row, .card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: var(--card);
  margin-bottom: 10px;
}
.row { display: flex; gap: 10px; align-items: center; text-align: left; width: 100%; color: var(--text); }
button.row { border: 1px solid var(--line); }
button.row:hover, button.row.active { border-color: rgba(42, 171, 238, 0.55); background: rgba(42, 171, 238, 0.09); }
.row__body { min-width: 0; flex: 1; }
.row__title { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; background: rgba(42, 171, 238, 0.13); color: var(--primary-dark); font-size: 12px; font-weight: 900; }
.status-icon { border: 0; background: transparent; font-size: 18px; }

.chat-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.35); }
.chat-head__body { min-width: 0; flex: 1; }
.chat-head__body span { display: block; color: var(--muted); font-size: 13px; }
.messages { display: flex; flex-direction: column; gap: 10px; overflow: auto; padding: 18px; }
.empty { display: grid; height: 100%; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.message { max-width: min(650px, 78%); padding: 10px 12px; border-radius: 18px; background: var(--other-bubble); box-shadow: 0 4px 16px rgba(26, 42, 58, 0.08); }
.message.own { align-self: flex-end; background: var(--own-bubble); color: #17212b; }
.message__text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.message__meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 6px; color: var(--muted); font-size: 12px; }
.message.own .message__meta { color: rgba(23, 33, 43, 0.64); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 46px; }
.reacts { display: flex; gap: 5px; margin-top: 6px; }
.reacts button { border: 0; border-radius: 999px; padding: 4px 8px; background: rgba(42, 171, 238, 0.12); }

.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.grid { display: grid; gap: 10px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.review-score { font-size: 28px; font-weight: 900; }
.positive { color: #20a45a; }
.negative { color: var(--danger); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 20; max-width: 420px; padding: 13px 16px; border-radius: 16px; background: #17212b; color: white; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }
.incoming-call, .call-overlay { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(10, 20, 31, 0.52); }
.incoming-call > div, .call-window { width: min(460px, 100%); padding: 24px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.incoming-call p { color: var(--muted); }
.call-window { width: min(760px, 100%); }
.call-videos { display: grid; grid-template-columns: 1fr 150px; gap: 12px; min-height: 280px; margin: 16px 0; }
.call-videos video { width: 100%; height: 100%; min-height: 130px; border-radius: 18px; background: #121b26; object-fit: cover; }
.call-videos.audio-only video { display: none; }
.call-videos.audio-only::after { content: "☎"; display: grid; min-height: 240px; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; font-size: 84px; }

.admin-shell { width: min(1280px, calc(100vw - 24px)); margin: 12px auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-card { border: 1px solid var(--line); border-radius: 22px; padding: 16px; background: var(--panel); }
.admin-list { max-height: 300px; overflow: auto; }
pre { white-space: pre-wrap; overflow: auto; padding: 12px; border-radius: 14px; background: rgba(0,0,0,0.08); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 310px minmax(0, 1fr); height: auto; min-height: 100vh; margin: 0; width: 100vw; border-radius: 0; }
  .rightbar { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .message { max-width: 90%; }
  .two { grid-template-columns: 1fr; }
}
