:root {
  color-scheme: dark;
  --bg: #090909;
  --panel: #111112;
  --panel-2: #171719;
  --line: rgba(226, 196, 124, 0.18);
  --text: #f7f1e4;
  --muted: #a7a09a;
  --gold: #e7c76f;
  --danger: #ff6868;
  --ok: #67ddb2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, rgba(231, 199, 111, 0.18), transparent 32rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--gold);
  color: #161208;
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 1rem;
}

button.ghost {
  background: transparent;
  color: var(--text);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.crm-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.1rem;
  border-right: 1px solid var(--line);
  background: rgba(9, 9, 9, 0.86);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
}

.nav {
  display: grid;
  gap: 0.45rem;
}

.nav button {
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav button.active {
  color: var(--text);
  border-color: rgba(231, 199, 111, 0.55);
  background: rgba(231, 199, 111, 0.1);
}

.session-card,
.notice {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 1rem;
  color: var(--muted);
}

.main {
  min-width: 0;
  padding: 1.2rem;
}

.login-view {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 2.4rem);
}

.login-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 17, 18, 0.92);
  padding: 1.5rem;
}

.login-logo img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}

.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  margin: 0 0 0.35rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

.muted,
.status {
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.form,
.inline-form,
.composer {
  display: grid;
  gap: 0.75rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0d0e;
  color: var(--text);
  padding: 0.9rem 1rem;
}

textarea {
  min-height: 126px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric,
.panel,
.thread,
.admin-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 17, 18, 0.88);
  padding: 1rem;
}

.metric span,
.thread header span,
.item small {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: clamp(2.2rem, 5vw, 4rem);
  margin-top: 0.4rem;
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 1rem;
}

.list,
.cards {
  display: grid;
  gap: 0.75rem;
}

.item,
.card,
.message,
.note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.9rem;
}

.item {
  text-align: left;
}

.item strong,
.card strong {
  display: block;
  margin-bottom: 0.25rem;
}

.thread {
  display: grid;
  gap: 1rem;
  min-height: 68vh;
}

.messages {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  max-height: 48vh;
  overflow: auto;
}

.message[data-direction="OUTBOUND"] {
  border-color: rgba(103, 221, 178, 0.28);
}

.message[data-sensitive="true"] {
  border-color: rgba(255, 104, 104, 0.5);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  margin-bottom: 1rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.compact {
  max-height: 58vh;
  overflow: auto;
}

@media (max-width: 920px) {
  .crm-shell,
  .split,
  .grid,
  .admin-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
