:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --surface-hover: #f4f5f6;

  --text: #16181d;
  --text-soft: #4e5662;
  --text-muted: #7b8491;

  --line: #e1e4e8;
  --line-strong: #cbd0d7;

  --primary: #16181d;
  --primary-hover: #292d33;

  --blue: #285cc4;
  --blue-soft: #edf3ff;

  --green: #1d6f42;
  --green-soft: #edf8f2;

  --amber: #9a5a00;
  --amber-soft: #fff7e6;

  --red: #b42318;
  --red-soft: #fff1f0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow:
    0 1px 2px rgba(16, 24, 40, 0.04),
    0 3px 8px rgba(16, 24, 40, 0.04);

  --sidebar: 248px;

  --ease: cubic-bezier(.2, .75, .25, 1);
}


html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #111315;
  --surface: #191c1f;
  --surface-muted: #202326;
  --surface-hover: #25292d;

  --text: #f2f3f4;
  --text-soft: #c0c5cb;
  --text-muted: #8e969f;

  --line: #2c3035;
  --line-strong: #3a4047;

  --primary: #f5f6f7;
  --primary-hover: #ffffff;

  --blue: #82aaff;
  --blue-soft: #1d2942;

  --green: #6bcf98;
  --green-soft: #173326;

  --amber: #f5bc66;
  --amber-soft: #3b2c14;

  --red: #ff8c83;
  --red-soft: #3c201e;

  --shadow: none;
}


* {
  box-sizing: border-box;
}


html {
  background: var(--bg);
}


body {
  margin: 0;
  min-height: 100vh;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: var(--text);
  background: var(--bg);

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}


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


button,
a {
  touch-action: manipulation;
}


a {
  color: inherit;
  text-decoration: none;
}


button {
  cursor: pointer;
}


svg {
  flex: 0 0 auto;
}


.skip-link {
  position: fixed;
  z-index: 9999;

  top: -60px;
  left: 16px;

  padding: 10px 14px;

  color: white;
  background: #111;

  border-radius: 8px;

  transition: top .18s var(--ease);
}


.skip-link:focus-visible {
  top: 16px;
}


/* ---------- APP ---------- */


.app {
  width: 100%;
  min-height: 100vh;

  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}


.sidebar {
  position: sticky;
  top: 0;

  height: 100vh;

  display: flex;
  flex-direction: column;

  padding: 22px 16px;

  background: var(--surface);
  border-right: 1px solid var(--line);
}


.brand {
  display: flex;
  align-items: center;
  gap: 11px;

  min-height: 48px;

  padding: 4px 8px 20px;
}


.brand-mark {
  width: 36px;
  height: 36px;

  display: grid;
  place-items: center;

  border-radius: 10px;

  color: white;
  background: #16181d;

  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.04em;
}


html[data-theme="dark"] .brand-mark {
  color: #16181d;
  background: #f5f6f7;
}


.brand-copy {
  min-width: 0;
}


.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.015em;
}


.brand-meta {
  margin-top: 2px;

  color: var(--text-muted);

  font-size: 11px;
}


.sidebar-nav {
  display: grid;
  gap: 3px;

  margin-top: 4px;
}


.sidebar-link {
  min-height: 42px;

  display: flex;
  align-items: center;
  gap: 11px;

  padding: 0 11px;

  border-radius: 9px;

  color: var(--text-soft);

  font-size: 13px;
  font-weight: 550;

  transition:
    color .16s var(--ease),
    background-color .16s var(--ease);
}


.sidebar-link svg {
  width: 17px;
  height: 17px;

  color: var(--text-muted);
}


.sidebar-link:hover {
  color: var(--text);
  background: var(--surface-muted);
}


.sidebar-link.is-active {
  color: var(--text);
  background: var(--surface-muted);
}


.sidebar-link.is-active svg {
  color: var(--text);
}


.sidebar-spacer {
  flex: 1;
}


.sidebar-user {
  display: grid;
  gap: 10px;

  padding-top: 16px;

  border-top: 1px solid var(--line);
}


.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 8px;
}


.user-avatar {
  width: 32px;
  height: 32px;

  display: grid;
  place-items: center;

  border-radius: 50%;

  background: var(--surface-muted);
  border: 1px solid var(--line);

  font-size: 12px;
  font-weight: 700;
}


.user-copy {
  min-width: 0;
  flex: 1;
}


.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  font-size: 12px;
  font-weight: 650;
}


.user-role {
  margin-top: 2px;

  color: var(--text-muted);

  font-size: 10px;
  text-transform: capitalize;
}


.sidebar-bottom-actions {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 7px;
}


/* ---------- MAIN ---------- */


.main {
  min-width: 0;

  padding:
    32px
    clamp(24px, 4vw, 64px)
    64px;

  animation: main-in .32s var(--ease);
}


@keyframes main-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.main-inner {
  width: min(100%, 1320px);

  margin: 0 auto;
}


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

  margin-bottom: 28px;
}


.page-heading {
  min-width: 0;
}


.page-eyebrow {
  margin-bottom: 7px;

  color: var(--text-muted);

  font-size: 11px;
  font-weight: 650;

  letter-spacing: .08em;
  text-transform: uppercase;
}


h1,
h2,
h3 {
  margin: 0;

  color: var(--text);

  text-wrap: balance;

  letter-spacing: -.035em;
}


h1 {
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.08;
}


h2 {
  font-size: 18px;
  line-height: 1.2;
}


h3 {
  font-size: 14px;
  line-height: 1.3;
}


.page-description {
  max-width: 700px;

  margin: 9px 0 0;

  color: var(--text-soft);

  font-size: 14px;
  line-height: 1.6;
}


.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;

  flex-wrap: wrap;
}


/* ---------- TABS ---------- */


.tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;

  width: fit-content;

  margin-bottom: 24px;
  padding: 4px;

  background: var(--surface-muted);

  border: 1px solid var(--line);
  border-radius: 10px;
}


.tab-button {
  min-height: 34px;

  padding: 0 12px;

  border: 0;
  border-radius: 7px;

  color: var(--text-soft);
  background: transparent;

  font-size: 12px;
  font-weight: 600;

  transition:
    color .16s var(--ease),
    background-color .16s var(--ease),
    box-shadow .16s var(--ease);
}


.tab-button:hover {
  color: var(--text);
}


.tab-button.is-active {
  color: var(--text);
  background: var(--surface);

  box-shadow:
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(16,24,40,.04);
}


.tab-panel {
  display: none;
}


.tab-panel.is-active {
  display: block;

  animation: tab-in .22s var(--ease);
}


@keyframes tab-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ---------- GRID ---------- */


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


.span-12 {
  grid-column: span 12;
}


.span-8 {
  grid-column: span 8;
}


.span-7 {
  grid-column: span 7;
}


.span-6 {
  grid-column: span 6;
}


.span-5 {
  grid-column: span 5;
}


.span-4 {
  grid-column: span 4;
}


/* ---------- CARDS ---------- */


.card {
  min-width: 0;

  background: var(--surface);

  border: 1px solid var(--line);
  border-radius: var(--radius-md);

  box-shadow: var(--shadow);
}


.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;

  padding: 19px 20px 0;
}


.card-title {
  min-width: 0;
}


.card-description {
  margin: 6px 0 0;

  color: var(--text-muted);

  font-size: 12px;
  line-height: 1.5;
}


.card-body {
  padding: 20px;
}


.card-section + .card-section {
  margin-top: 20px;
  padding-top: 20px;

  border-top: 1px solid var(--line);
}


/* ---------- METRICS ---------- */


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


.metric {
  padding: 17px;

  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}


.metric-label {
  color: var(--text-muted);

  font-size: 11px;
  font-weight: 600;

  letter-spacing: .015em;
}


.metric-value {
  margin-top: 8px;

  color: var(--text);

  font-size: 27px;
  font-weight: 720;
  letter-spacing: -.045em;

  font-variant-numeric: tabular-nums;
}


.metric-note {
  margin-top: 5px;

  color: var(--text-muted);

  font-size: 11px;
}


/* ---------- STATUS ---------- */


.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  min-height: 26px;

  padding: 0 9px;

  border-radius: 999px;

  font-size: 11px;
  font-weight: 650;
}


.status-dot {
  width: 6px;
  height: 6px;

  border-radius: 50%;
}


.status.success {
  color: var(--green);
  background: var(--green-soft);
}


.status.success .status-dot {
  background: var(--green);
}


.status.warning {
  color: var(--amber);
  background: var(--amber-soft);
}


.status.warning .status-dot {
  background: var(--amber);
}


.status.neutral {
  color: var(--text-soft);
  background: var(--surface-muted);
}


/* ---------- FORMS ---------- */


.form-stack {
  display: grid;
  gap: 16px;
}


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


.field {
  min-width: 0;

  display: grid;
  gap: 7px;
}


label {
  color: var(--text-soft);

  font-size: 12px;
  font-weight: 620;
}


input,
select,
textarea {
  width: 100%;
  min-width: 0;

  color: var(--text);
  background: var(--surface);

  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);

  transition:
    border-color .15s var(--ease),
    box-shadow .15s var(--ease),
    background-color .15s var(--ease);
}


input,
select {
  min-height: 42px;

  padding: 0 11px;
}


textarea {
  min-height: 126px;

  padding: 11px;

  line-height: 1.55;

  resize: vertical;
}


textarea.message-input {
  min-height: 190px;

  white-space: pre-wrap;
  tab-size: 4;
}


input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}


select {
  color: var(--text);
  background-color: var(--surface);
}


.field-help {
  color: var(--text-muted);

  font-size: 11px;
  line-height: 1.5;
}


input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;

  border-color: var(--blue);

  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--blue), transparent 82%);
}


/* ---------- BUTTONS ---------- */


.button {
  min-height: 38px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  padding: 0 13px;

  border: 1px solid transparent;
  border-radius: 8px;

  font-size: 12px;
  font-weight: 620;

  transition:
    background-color .15s var(--ease),
    border-color .15s var(--ease),
    color .15s var(--ease),
    transform .15s var(--ease);
}


.button:hover {
  transform: translateY(-1px);
}


.button:active {
  transform: translateY(0);
}


.button-primary {
  color: var(--surface);
  background: var(--primary);
}


html[data-theme="dark"] .button-primary {
  color: #111315;
}


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


.button-secondary {
  color: var(--text);
  background: var(--surface);

  border-color: var(--line-strong);
}


.button-secondary:hover {
  background: var(--surface-hover);
}


.button-danger {
  color: var(--red);
  background: var(--red-soft);

  border-color:
    color-mix(
      in srgb,
      var(--red),
      transparent 78%
    );
}


.button-icon {
  width: 38px;
  height: 38px;

  padding: 0;

  color: var(--text-soft);
  background: transparent;

  border: 1px solid var(--line);
}


.button-icon:hover {
  color: var(--text);
  background: var(--surface-muted);
}


button:focus-visible,
a:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--blue), transparent 78%);
}


/* ---------- DM PREVIEW ---------- */


.dm-preview-wrap {
  display: grid;
  gap: 10px;
}


.dm-preview-label {
  color: var(--text-muted);

  font-size: 11px;
  font-weight: 600;

  letter-spacing: .03em;
  text-transform: uppercase;
}


.dm-device {
  padding: 18px;

  border: 1px solid var(--line);
  border-radius: var(--radius-md);

  background: var(--surface-muted);
}


.dm-thread {
  display: grid;
  gap: 10px;
}


.dm-account {
  display: flex;
  align-items: center;
  gap: 9px;

  padding-bottom: 12px;

  border-bottom: 1px solid var(--line);
}


.dm-avatar {
  width: 29px;
  height: 29px;

  display: grid;
  place-items: center;

  border-radius: 50%;

  color: var(--surface);
  background: var(--text);

  font-size: 10px;
  font-weight: 700;
}


.dm-account-name {
  color: var(--text);

  font-size: 11px;
  font-weight: 650;
}


.dm-bubble {
  max-width: 88%;

  margin-left: auto;

  padding: 10px 12px;

  border-radius:
    14px
    14px
    4px
    14px;

  color: var(--text);

  background: var(--surface);

  border: 1px solid var(--line);

  font-size: 12px;
  line-height: 1.5;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
}


/* ---------- AUTOMATIONS ---------- */


.automation-list {
  display: grid;
  gap: 12px;
}


.automation {
  padding: 16px;

  background: var(--surface-muted);

  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}


.automation-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;

  margin-bottom: 16px;
}


.automation-name {
  font-size: 13px;
  font-weight: 680;
}


.automation-id {
  margin-top: 3px;

  color: var(--text-muted);

  font-size: 10px;
}


.automation-actions {
  display: flex;
  gap: 7px;

  margin-top: 14px;

  flex-wrap: wrap;
}


/* ---------- ACTIVITY ---------- */


.activity-list {
  display: grid;
}


.activity {
  display: grid;
  grid-template-columns:
    minmax(145px, .7fr)
    minmax(0, 1.6fr)
    minmax(100px, .7fr);

  gap: 20px;

  padding: 15px 0;

  border-bottom: 1px solid var(--line);
}


.activity:first-child {
  padding-top: 0;
}


.activity:last-child {
  padding-bottom: 0;

  border-bottom: 0;
}


.activity-result {
  color: var(--text);

  font-size: 12px;
  font-weight: 650;
}


.activity-comment {
  min-width: 0;

  color: var(--text-soft);

  font-size: 12px;
  line-height: 1.5;

  overflow-wrap: anywhere;
}


.activity-meta {
  text-align: right;

  color: var(--text-muted);

  font-size: 10px;
  line-height: 1.55;
}


/* ---------- SETTINGS ---------- */


.settings-list {
  display: grid;
}


.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;

  padding: 16px 0;

  border-bottom: 1px solid var(--line);
}


.setting-row:first-child {
  padding-top: 0;
}


.setting-row:last-child {
  padding-bottom: 0;

  border-bottom: 0;
}


.setting-copy {
  min-width: 0;
}


.setting-title {
  color: var(--text);

  font-size: 12px;
  font-weight: 650;
}


.setting-description {
  margin-top: 4px;

  color: var(--text-muted);

  font-size: 11px;
  line-height: 1.5;
}


/* ---------- TABLE ---------- */


.table-wrap {
  width: 100%;

  overflow-x: auto;

  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}


table {
  width: 100%;
  min-width: 820px;

  border-collapse: collapse;

  font-size: 12px;
}


th,
td {
  padding: 13px 14px;

  border-bottom: 1px solid var(--line);

  text-align: left;
  vertical-align: middle;
}


th {
  color: var(--text-muted);
  background: var(--surface-muted);

  font-size: 10px;
  font-weight: 680;

  letter-spacing: .04em;
  text-transform: uppercase;
}


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


tbody tr:hover {
  background: var(--surface-muted);
}


/* ---------- EMPTY ---------- */


.empty {
  padding: 28px;

  text-align: center;

  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
}


.empty-title {
  color: var(--text);

  font-size: 13px;
  font-weight: 650;
}


.empty-text {
  max-width: 420px;

  margin: 7px auto 0;

  color: var(--text-muted);

  font-size: 11px;
  line-height: 1.55;
}


/* ---------- TOAST ---------- */


.toast-region {
  position: fixed;
  z-index: 5000;

  top: 20px;
  right: 20px;

  width: min(360px, calc(100vw - 40px));

  pointer-events: none;
}


.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;

  padding: 13px 14px;

  color: var(--text);
  background: var(--surface);

  border: 1px solid var(--line);
  border-radius: 10px;

  box-shadow:
    0 12px 32px rgba(16,24,40,.14);

  opacity: 0;
  transform: translateY(-6px);

  transition:
    opacity .2s var(--ease),
    transform .2s var(--ease);
}


.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}


.toast-dot {
  width: 7px;
  height: 7px;

  margin-top: 5px;

  border-radius: 50%;

  background: var(--green);
}


.toast-copy {
  min-width: 0;
}


.toast-title {
  color: var(--text);

  font-size: 12px;
  font-weight: 680;
}


.toast-text {
  margin-top: 3px;

  color: var(--text-muted);

  font-size: 11px;
  line-height: 1.5;
}


/* ---------- LOGIN ---------- */


.login-page {
  min-height: 100vh;

  display: grid;
  place-items: center;

  padding: 28px;

  background: var(--bg);
}


.login-shell {
  width: min(920px, 100%);

  display: grid;
  grid-template-columns: 1fr 420px;

  overflow: hidden;

  background: var(--surface);

  border: 1px solid var(--line);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow);
}


.login-intro {
  padding: clamp(32px, 5vw, 58px);

  display: grid;
  align-content: center;

  background: var(--surface-muted);

  border-right: 1px solid var(--line);
}


.login-intro-mark {
  width: 40px;
  height: 40px;

  display: grid;
  place-items: center;

  margin-bottom: 30px;

  color: white;
  background: #16181d;

  border-radius: 11px;

  font-size: 14px;
  font-weight: 750;
}


.login-intro h1 {
  max-width: 500px;
}


.login-intro p {
  max-width: 500px;

  margin: 14px 0 0;

  color: var(--text-soft);

  font-size: 13px;
  line-height: 1.65;
}


.login-features {
  display: grid;
  gap: 12px;

  margin-top: 30px;
}


.login-feature {
  display: flex;
  gap: 10px;

  color: var(--text-soft);

  font-size: 12px;
}


.login-feature svg {
  width: 16px;
  height: 16px;

  color: var(--text);
}


.login-panel {
  padding: 38px;

  display: grid;
  align-content: center;
}


.login-panel h2 {
  font-size: 22px;
}


.login-panel-description {
  margin: 7px 0 22px;

  color: var(--text-muted);

  font-size: 12px;
  line-height: 1.5;
}


.login-error {
  margin-bottom: 15px;
  padding: 11px 12px;

  color: var(--red);
  background: var(--red-soft);

  border-radius: var(--radius-sm);

  font-size: 11px;
  line-height: 1.5;
}


/* ---------- RESPONSIVE ---------- */


.mobile-header {
  display: none;
}


@media (max-width: 1100px) {
  .span-8,
  .span-7,
  .span-6,
  .span-5,
  .span-4 {
    grid-column: span 12;
  }
}


@media (max-width: 860px) {
  .app {
    display: block;
  }


  .sidebar {
    position: fixed;
    z-index: 2000;

    top: 0;
    left: 0;

    width: min(280px, 86vw);
    height: 100vh;

    transform: translateX(-102%);

    transition: transform .24s var(--ease);

    box-shadow:
      14px 0 36px rgba(16,24,40,.12);
  }


  body.nav-open .sidebar {
    transform: translateX(0);
  }


  .mobile-header {
    position: sticky;
    z-index: 1500;

    top: 0;

    height: 58px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 14px;

    background:
      color-mix(
        in srgb,
        var(--surface),
        transparent 6%
      );

    backdrop-filter: blur(12px);

    border-bottom: 1px solid var(--line);
  }


  .mobile-brand {
    font-size: 13px;
    font-weight: 700;
  }


  .main {
    padding: 24px 16px 44px;
  }


  .page-header {
    flex-direction: column;
  }


  .header-actions {
    width: 100%;
  }


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


  .form-grid {
    grid-template-columns: 1fr;
  }


  .activity {
    grid-template-columns: 1fr;
    gap: 5px;
  }


  .activity-meta {
    text-align: left;
  }


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


@media (max-width: 700px) {
  .login-page {
    padding: 14px;
  }


  .login-shell {
    grid-template-columns: 1fr;
  }


  .login-intro {
    padding: 28px 24px;

    border-right: 0;
    border-bottom: 1px solid var(--line);
  }


  .login-features {
    display: none;
  }


  .login-intro-mark {
    margin-bottom: 20px;
  }


  .login-panel {
    padding: 28px 24px;
  }


  .tab-bar {
    width: 100%;

    overflow-x: auto;
  }


  .tab-button {
    flex: 0 0 auto;
  }


  .button {
    min-height: 42px;
  }
}


@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;

    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;

    transition-duration: .001ms !important;
  }
}
