:root {
  color-scheme: dark;
  --bg: #000000;
  --panel: #0b0b0c;
  --line: #1e1e21;
  --line-soft: #141417;
  --text: #ececf0;
  --muted: #8f9198;
  --accent: #4169e1;
  --accent-press: #355ad1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  background: #000000;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.brand-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.brand-wordmark {
  width: 120px;
  height: auto;
  display: block;
}

.top-actions {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 12px;
  z-index: 20;
  min-width: 170px;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080808;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 1px solid var(--line);
  background: #080808;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}

.topbar.menu-open .top-actions {
  display: flex;
}

.top-actions .nav-btn {
  width: 100%;
  text-align: center;
}

.user-chip {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  background: #050505;
}

.nav-btn {
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #080808;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.nav-btn:hover {
  border-color: #2a2a2f;
  background: #101012;
  transform: translateY(-1px);
}

.nav-btn:active {
  transform: translateY(0);
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  min-height: 100vh;
  gap: 12px;
  padding: 12px;
}

.layout.no-details-layout {
  grid-template-columns: 300px 1fr;
}

.panel {
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 0;
  overflow: hidden;
}

.panel-title {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.panel-title-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-with-action .nav-btn {
  text-transform: none;
  letter-spacing: normal;
}

.list-filters {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.list-filters input,
.list-filters select {
  width: 100%;
  background: #070707;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.list {
  max-height: calc(100vh - 90px);
  overflow: auto;
  scroll-behavior: smooth;
}

.list-item {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color 120ms ease;
}

.list-item.active,
.list-item:hover {
  background: rgba(10, 132, 255, 0.2);
}

.list-name {
  font-weight: 600;
  font-size: 14px;
}

.list-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  gap: 10px;
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
}

.chat-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.chat-user-link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.chat-user-link:hover .chat-title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mobile-back {
  display: none;
}

.messages {
  height: calc(100vh - 200px);
  overflow: auto;
  padding: 12px;
  scroll-behavior: smooth;
}

.msg-row {
  display: flex;
  margin-bottom: 8px;
  transition: transform 120ms ease, opacity 120ms ease;
}

.msg-row.out {
  justify-content: flex-end;
}

.msg {
  max-width: 76%;
  border: 1px solid #232327;
  border-radius: 10px;
  padding: 9px 11px;
  background: #101014;
}

.msg-row.out .msg {
  background: rgba(10, 132, 255, 0.18);
  border-color: rgba(10, 132, 255, 0.42);
}

.msg-meta {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  background: #030303;
}

.composer input,
.composer textarea {
  flex: 1;
  background: #080808;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.composer textarea {
  min-height: 44px;
  max-height: 180px;
  resize: vertical;
  font: inherit;
}

.composer input:focus,
.composer textarea:focus,
.list-filters input:focus,
.list-filters select:focus,
.auth-card input:focus,
.inline-form input:focus,
.inline-form select:focus,
.table input:focus {
  outline: none;
  border-color: rgba(10, 132, 255, 0.8);
  background: #0b0b0d;
}

button {
  background: linear-gradient(180deg, #4b74ee 0%, var(--accent) 100%);
  color: #fff;
  border: 1px solid #3358cd;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 20px rgba(65, 105, 225, 0.32);
  transition: transform 120ms ease, filter 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

button:hover {
  background: linear-gradient(180deg, #5780ff 0%, #456fe8 100%);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 10px 24px rgba(65, 105, 225, 0.38);
}

button:active {
  transform: translateY(0);
  background: var(--accent-press);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 6px 14px rgba(65, 105, 225, 0.28);
}

.ghost {
  background: #09090a;
  border: 1px solid var(--line);
  color: var(--text);
}

.danger {
  background: #8f2f39;
  border-color: #7f2932;
}

.detail {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.hidden-details {
  display: none;
}

.profile-form {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 8px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.profile-form input,
.profile-form textarea {
  width: 100%;
  background: #080808;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

.profile-form textarea {
  resize: vertical;
}

.hint,
.empty {
  padding: 14px;
  color: var(--muted);
}

.center-empty {
  display: grid;
  place-items: center;
  height: 100%;
}

.auth-shell,
.settings-shell {
  min-height: 100vh;
  display: block;
  padding: 12px;
}

.auth-card,
.settings-card {
  width: 100%;
  max-width: 680px;
  margin: 24px auto 0;
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 14px;
}

.auth-shell {
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(65, 105, 225, 0.16), transparent 65%),
    linear-gradient(#000, #000);
}

.login-card {
  max-width: 840px;
  width: min(95vw, 840px);
  text-align: center;
  padding: 10px 36px 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

.login-card::before {
  content: none;
}

.login-card > * {
  position: relative;
  z-index: 1;
}

.login-card h1 {
  text-align: center;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: 560;
  margin: 0 0 18px;
  color: #d9dbe3;
}

.login-icon {
  display: block;
  margin: 0 auto 10px;
  width: min(170px, 26vw);
  height: auto;
}

.login-wordmark {
  display: block;
  margin: 0 auto 14px;
  width: min(360px, 58vw);
  height: auto;
}

.login-card p {
  text-align: center;
  margin-bottom: 32px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.login-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #b6bac6;
  letter-spacing: -0.01em;
  font-weight: 500;
}

.login-card label {
  text-align: center;
}

.login-card input {
  margin-left: auto;
  margin-right: auto;
  width: min(92%, 520px);
  height: 64px;
  border-radius: 22px;
  font-size: 16px;
  padding: 0 20px;
  border: 2px solid transparent;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.login-action {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.login-action button {
  min-width: 300px;
  height: 58px;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid #2723c7;
  background: linear-gradient(180deg, #272072 0%, #211b5d 100%);
  color: #2821ff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 6px 18px rgba(33, 27, 93, 0.6),
    0 0 0 1px rgba(39, 35, 199, 0.15);
}

.login-action button:hover {
  background: linear-gradient(180deg, #2c247d 0%, #241e66 100%);
  border-color: #3732e0;
  color: #3b34ff;
}

.login-action button:active {
  background: linear-gradient(180deg, #221c5f 0%, #1b174f 100%);
  transform: translateY(0);
  color: #2721ef;
}

.login-card input::placeholder {
  color: transparent;
  font-size: 16px;
}

.login-card input:focus {
  outline: none;
  border-color: #2f34ff;
  box-shadow:
    0 0 0 1px rgba(47, 52, 255, 0.55),
    0 0 16px rgba(47, 52, 255, 0.45),
    0 0 30px rgba(47, 52, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background: linear-gradient(90deg, #2a2b31 0%, #2c2d34 100%);
}

/* Phone step: always-active frame, with jet-black fill. */
.phone-step-form .phone-step-input {
  border-color: #2f34ff;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(47, 52, 255, 0.55),
    0 0 16px rgba(47, 52, 255, 0.45),
    0 0 30px rgba(47, 52, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background: #000;
}

.phone-step-form .phone-step-input:focus {
  background: #000;
}

.phone-step-form .phone-step-input::placeholder {
  color: #b6bac6;
  text-align: center;
}

.phone-step-form .phone-step-input:focus::placeholder {
  color: transparent;
}

/* OTP step: centered text only in verification input. */
.otp-step-form .otp-step-input {
  text-align: center;
}

.settings-card.wide {
  max-width: 1100px;
  border: none;
}

.auth-card h1,
.settings-card h1 {
  margin: 0 0 8px;
}

.auth-card p,
.settings-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.auth-card label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
}

.auth-card:not(.login-card) input,
.inline-form input,
.inline-form select,
.table input {
  width: 100%;
  margin-top: 6px;
  background: #080808;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.error {
  margin-bottom: 12px;
  border: 1px solid #9d404a;
  background: rgba(157, 64, 74, 0.14);
  color: #ffdce0;
  padding: 10px 12px;
  border-radius: 8px;
}

.success {
  margin-bottom: 12px;
  border: 1px solid #2f6f54;
  background: rgba(47, 111, 84, 0.18);
  color: #d9ffe7;
  padding: 10px 12px;
  border-radius: 8px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto auto;
  gap: 8px;
  margin-bottom: 16px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.check input {
  width: auto;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
  background: #060606;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.inline input {
  width: 160px;
  margin: 0;
  padding: 8px;
}

/* Minimal scrollbar styling for smoother dark UI feel */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #060607;
}

::-webkit-scrollbar-thumb {
  background: #2a2a30;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a43;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    min-height: calc(100vh - 56px);
    width: 100%;
    padding: 0;
    gap: 0;
  }
  .layout.no-details-layout {
    grid-template-columns: 1fr;
  }
  .left,
  .right,
  .center {
    max-height: none;
  }
  .messages {
    height: 46vh;
  }
  .inline-form {
    grid-template-columns: 1fr;
  }
  .topbar {
    position: sticky;
    top: 0;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
  }

  .brand-wordmark {
    width: 105px;
  }

  /* Mobile flow: list -> chat -> details (single screen at a time). */
  body.view-list .center,
  body.view-list .right {
    display: none;
  }
  body.view-list .left {
    display: block;
    width: 100%;
    border-left: none;
    border-right: none;
  }

  body.view-chat .left,
  body.view-chat .right {
    display: none;
  }
  body.view-chat .center {
    display: block;
    width: 100%;
    border-left: none;
    border-right: none;
  }

  body.view-details .left,
  body.view-details .center {
    display: none;
  }
  body.view-details .right {
    display: block;
    width: 100%;
    border-left: none;
    border-right: none;
  }

  .mobile-back {
    display: inline-flex;
  }

  .chat-header #ai-btn {
    margin-left: auto;
  }
  .auth-card,
  .settings-card {
    margin-top: 12px;
  }
  .login-card h1 {
    font-size: 20px;
  }
  .login-field {
    font-size: 13px;
  }
  .login-card input,
  .login-action button {
    height: 52px;
    font-size: 15px;
  }
}
