:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #667169;
  --paper: #f4f6f1;
  --surface: #ffffff;
  --line: #dfe5dc;
  --accent: #196b4b;
  --accent-dark: #0e4e36;
  --accent-soft: #dcefe5;
  --warm: #f1e7d7;
  --danger: #a23737;
  --shadow: 0 24px 70px rgba(28, 54, 40, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

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

button { cursor: pointer; }

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

.brand-mark {
  display: grid;
  width: 3.1rem;
  height: 3.1rem;
  place-items: center;
  border-radius: 1rem;
  color: #fff;
  background: var(--accent);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.brand-mark.small {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  font-size: 0.72rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 15% 12%, #d8ecdf 0, transparent 28rem),
    radial-gradient(circle at 86% 88%, #eadfcd 0, transparent 30rem),
    var(--paper);
}

.login-shell {
  display: grid;
  width: min(1050px, 100%);
  grid-template-columns: 1.15fr 0.85fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 2rem;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.brand-panel {
  min-height: 610px;
  padding: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(145deg, rgba(10, 73, 49, 0.97), rgba(25, 107, 75, 0.9)),
    var(--accent);
  color: #fff;
}

.brand-panel .eyebrow {
  margin-top: 2.2rem;
  color: #b8dfca;
}

.brand-panel h1 {
  max-width: 11ch;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 5vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.lead {
  max-width: 47ch;
  margin: 1.8rem 0 0;
  color: #d9ece1;
  font-size: 1.05rem;
  line-height: 1.7;
}

.signal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2.4rem;
}

.signal-row span {
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #e5f2ea;
  font-size: 0.78rem;
}

.login-card {
  padding: 4rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.login-card form {
  display: grid;
  gap: 1.2rem;
  margin-top: 2.2rem;
}

.login-card label {
  display: grid;
  gap: 0.5rem;
  color: #38443c;
  font-size: 0.84rem;
  font-weight: 750;
}

input {
  width: 100%;
  padding: 0.88rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  outline: none;
  color: var(--ink);
  background: #fbfcfa;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 107, 75, 0.12);
}

select,
textarea {
  width: 100%;
  padding: 0.88rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  outline: none;
  color: var(--ink);
  background: #fbfcfa;
}

select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 107, 75, 0.12);
}

.login-card button {
  margin-top: 0.35rem;
  padding: 0.95rem 1.1rem;
  border: 0;
  border-radius: 0.85rem;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.login-card button:hover { background: var(--accent-dark); }
.login-card button:disabled { opacity: 0.6; cursor: wait; }

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.83rem;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.product,
.operator {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.product {
  color: inherit;
  text-decoration: none;
}

.product span:last-child,
.operator span {
  display: grid;
  gap: 0.15rem;
}

.product small,
.operator small {
  color: var(--muted);
  font-size: 0.73rem;
}

.operator { text-align: right; }

.topnav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-button {
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 0.65rem;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.nav-button:hover,
.nav-button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.button-secondary {
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.workspace {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(310px, 380px) 1fr;
}

.conversation-sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 1.5rem 1.1rem 0;
  border-right: 1px solid var(--line);
  background: #fafbf8;
}

.sidebar-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 0.4rem 1.1rem;
}

.sidebar-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.count {
  display: grid;
  min-width: 2rem;
  height: 2rem;
  place-items: center;
  padding: 0 0.55rem;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 800;
}

.search { display: block; }

.conversation-list {
  min-height: 0;
  margin-top: 1rem;
  overflow-y: auto;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  padding: 1rem 0.8rem;
  border: 0;
  border-top: 1px solid var(--line);
  text-align: left;
  background: transparent;
}

.conversation-item:hover,
.conversation-item.active {
  border-radius: 0.9rem;
  background: var(--accent-soft);
}

.avatar {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-dark);
  background: var(--warm);
  font-weight: 900;
}

.conversation-copy {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.conversation-copy strong,
.conversation-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy span {
  color: var(--muted);
  font-size: 0.8rem;
}

.conversation-item time {
  color: var(--muted);
  font-size: 0.7rem;
}

.conversation-panel {
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(244, 246, 241, 0.9), rgba(244, 246, 241, 0.9)),
    repeating-linear-gradient(
      45deg,
      transparent 0,
      transparent 18px,
      rgba(25, 107, 75, 0.035) 18px,
      rgba(25, 107, 75, 0.035) 19px
    );
}

.empty-state {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 1rem 0 0.3rem;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
}

.empty-state p { margin: 0; }

.empty-icon {
  display: grid;
  width: 4rem;
  height: 4rem;
  place-items: center;
  border-radius: 1.3rem;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 1.8rem;
  letter-spacing: 0.1em;
}

#conversation-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.reply-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.reply-composer textarea {
  min-height: 3rem;
  max-height: 9rem;
  resize: vertical;
}

.reply-composer button,
.stack-form button {
  align-self: stretch;
  padding: 0.8rem 1.25rem;
  border: 0;
  border-radius: 0.8rem;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.reply-composer button:hover,
.stack-form button:hover { background: var(--accent-dark); }
.reply-composer button:disabled { opacity: 0.6; cursor: wait; }
.reply-composer .form-error {
  grid-column: 1 / -1;
}

.admin-workspace {
  min-height: calc(100vh - 72px);
  padding: 2rem;
  overflow-y: auto;
}

.admin-heading {
  max-width: 1200px;
  margin: 0 auto 1.5rem;
}

.admin-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.admin-heading p:last-child {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.admin-grid {
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 0 auto;
}

.admin-card {
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(30, 48, 38, 0.04);
}

.admin-card h2 {
  margin: 0 0 1.1rem;
  font-size: 1.15rem;
}

.operators-card {
  max-width: 1200px;
  margin: 1.25rem auto 0;
}

.stack-form {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 1.3rem;
}

.stack-form label {
  display: grid;
  gap: 0.4rem;
  color: #38443c;
  font-size: 0.8rem;
  font-weight: 750;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.8rem;
}

th {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-title select { max-width: 260px; }

.identity-cell {
  display: grid;
  gap: 0.2rem;
}

.identity-cell small { color: var(--muted); }

.status-badge {
  display: inline-block;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.status-badge.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.status-badge.inactive {
  color: var(--danger);
  background: #f6dddd;
}

.table-action {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface);
  font-size: 0.74rem;
  font-weight: 700;
}

.table-action:disabled { opacity: 0.45; cursor: not-allowed; }

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.45rem 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.conversation-header h2 { margin: 0.4rem 0 0; font-size: 1.25rem; }
.conversation-header time { color: var(--muted); font-size: 0.78rem; }

.channel-pill {
  display: inline-block;
  margin: 0;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 2rem;
  overflow-y: auto;
}

.message {
  max-width: min(72%, 680px);
  padding: 0.85rem 1rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 1rem 1rem 1rem 0.25rem;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(30, 48, 38, 0.05);
}

.message.outgoing {
  align-self: flex-end;
  border-color: #bddbc9;
  border-radius: 1rem 1rem 0.25rem 1rem;
  background: var(--accent-soft);
}

.message p { margin: 0; line-height: 1.5; }
.message time {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
}

.empty-list {
  padding: 2rem 0.8rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .login-page { padding: 1rem; }
  .login-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: auto; padding: 2.3rem; }
  .brand-panel h1 { font-size: 2.8rem; }
  .login-card { padding: 2.3rem; }
  .workspace { grid-template-columns: 1fr; }
  .conversation-sidebar { border-right: 0; }
  .conversation-panel { display: none; }
  .operator span { display: none; }
  .topnav { margin-left: auto; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-workspace { padding: 1rem; }
}
