:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #17202f;
  --muted: #657084;
  --border: #dce3ec;
  --accent: #0f8b8d;
  --accent-dark: #0a6668;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(22, 32, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 22px 16px;
  background: #111827;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #e7fbf8;
  color: var(--accent-dark);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #a7b0c0;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 6px;
}

nav a,
.logout button {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

nav a.active,
nav a:hover,
.logout button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.logout {
  margin-top: auto;
}

.main {
  margin-left: 260px;
  padding: 34px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.page-header p {
  margin: 8px 0 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metrics article,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 20px;
}

.metrics span {
  display: block;
  font-size: 34px;
  font-weight: 750;
}

.metrics small {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.narrow {
  max-width: 820px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(520px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 650;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.13);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: auto;
}

button,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 13px;
  text-decoration: none;
  cursor: pointer;
}

button.primary,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button.primary:hover,
.button.primary:hover {
  background: var(--accent-dark);
}

button.danger {
  color: var(--danger);
}

.actions,
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions.spaced {
  margin: 14px 0;
}

.toolbar {
  margin-bottom: 14px;
}

.toolbar input {
  max-width: 420px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions form {
  margin: 0;
}

code,
.block {
  border-radius: 7px;
  background: #eef3f8;
  color: #163b45;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  padding: 3px 6px;
}

.block {
  display: block;
  padding: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row span,
.muted {
  color: var(--muted);
}

.notice {
  padding: 13px 14px;
  margin-bottom: 15px;
  border-radius: 8px;
  background: #e7fbf8;
  color: #154e51;
}

.media-current {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: #334155;
  font-size: 13px;
}

.media-current span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chat-layout {
  align-items: start;
}

.chat-panel {
  min-height: 620px;
}

.thread {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.bubble.outgoing {
  justify-self: end;
  background: #e7fbf8;
  border-color: #b7e6df;
}

.bubble.incoming {
  justify-self: start;
}

.bubble.system {
  justify-self: center;
  max-width: 92%;
  background: #eef3f8;
  color: var(--muted);
}

.bubble-meta,
.bubble small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.send-box {
  margin-top: 14px;
}

.automation-step {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.automation-step:last-child {
  border-bottom: 0;
}

.automation-step p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.danger-note {
  background: #fff1f0;
  color: #842029;
}

.steps {
  display: grid;
  gap: 10px;
  padding-left: 22px;
  color: #334155;
  line-height: 1.55;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 26px;
}

.login-card p {
  margin: 0;
}

@media (max-width: 940px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  nav {
    display: flex;
  }

  .logout {
    margin-left: auto;
    margin-top: 0;
  }

  .main {
    margin-left: 0;
    padding: 22px;
  }

  .metrics,
  .grid.two,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .sidebar {
    display: grid;
  }

  nav {
    flex-wrap: wrap;
  }

  .page-header,
  .actions,
  .toolbar,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

  .main {
    padding: 16px;
  }

  h1 {
    font-size: 25px;
  }
}
