:root {
  --navy: #0b1b3a;
  --navy-2: #12264d;
  --navy-3: #1a3370;
  --primary: #1a73e8;
  --primary-hover: #155fc0;
  --primary-soft: #e8f1fd;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5b677a;
  --line: #e6ebf3;
  --ok: #137333;
  --ok-bg: #e6f4ea;
  --warn: #b06000;
  --warn-bg: #fff4e5;
  --err: #c5221f;
  --err-bg: #fce8e6;
  --info: #185abc;
  --info-bg: #e8f0fe;
  --sidebar-w: 248px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 27, 58, 0.06), 0 8px 24px rgba(11, 27, 58, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, #081428 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem 1rem;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.2rem 0.45rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1rem;
}

.brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 0.12rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

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

.brand-title {
  font-size: 1.16rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  white-space: normal;
}

.nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #c5d4ea;
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-btn.active { background: var(--navy-3); color: #fff; }

.sidebar-foot {
  margin-top: auto;
  padding: 0.85rem 0.45rem 0.2rem;
  color: #7f93b3;
  font-size: 0.72rem;
  line-height: 1.45;
}

.foot-logo {
  display: block;
  width: 100%;
  max-width: 128px;
  height: auto;
  aspect-ratio: 112 / 22;
  object-fit: contain;
  object-position: left center;
  /* mlai-logo.svg is dark (#1c1c1c); render light on navy */
  filter: brightness(0) invert(1);
  opacity: 0.92;
  margin-bottom: 0.55rem;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
}
.subtitle { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }

.topbar-end {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-shrink: 0;
}

.topbar-logo {
  display: block;
  height: 22px;
  width: auto;
  max-width: 140px;
  aspect-ratio: 112 / 22;
  object-fit: contain;
  object-position: right center;
}

.main {
  padding: 1.25rem 1.5rem 2rem;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}
.seg button.active { background: #fff; color: var(--navy); box-shadow: 0 1px 2px rgba(11, 27, 58, 0.08); }

.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 0.5rem 0.95rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
th, td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #f8fafd;
  font-weight: 700;
}
tbody tr:hover { background: #f7f9fc; }

.empty, .error-banner, .status-line {
  padding: 1.4rem 1rem;
  color: var(--muted);
  text-align: center;
}
.error-banner { color: var(--err); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-err { background: var(--err-bg); color: var(--err); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: #eef1f6; color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.85rem 1rem 0;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
  padding: 1rem 1.1rem 1.2rem;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field.span-2 { grid-column: 1 / -1; }
label { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
input, textarea, select {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
.hint { font-size: 0.75rem; color: var(--muted); }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.panel h2 {
  margin: 0;
  font-size: 0.92rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow: auto;
  max-height: 320px;
  font-size: 0.76rem;
  line-height: 1.45;
  background: #0b1b3a;
  color: #d7e4f7;
  border-radius: 0 0 var(--radius) var(--radius);
}

.poll-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem 0;
  flex-wrap: wrap;
}
.poll-row input { flex: 1; min-width: 10rem; }
.poll-row-secondary {
  padding-top: 0.45rem;
  padding-bottom: 0.35rem;
}
.copy-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  vertical-align: middle;
}
.copy-cell .copy-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-copy {
  flex-shrink: 0;
  padding: 0.12rem 0.45rem;
  font-size: 0.7rem;
}
td.trigger-td {
  white-space: normal;
  max-width: 340px;
  overflow: visible;
  text-overflow: unset;
  vertical-align: top;
}
.trigger-input {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  min-width: 12rem;
}
.trigger-summary {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text);
  white-space: normal;
}
.trigger-missing { color: var(--muted); }
.trigger-details {
  width: 100%;
}
.trigger-details summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 650;
  user-select: none;
}
.trigger-json {
  margin-top: 0.4rem;
  max-height: 220px;
  max-width: 420px;
  white-space: pre;
  border-radius: 8px;
  font-size: 0.7rem;
  padding: 0.7rem 0.8rem;
}
td.copy-td {
  max-width: 340px;
}
td.copy-td .copy-cell {
  width: 100%;
}

.hidden { display: none !important; }

@media (max-width: 960px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; gap: 1rem; }
  .brand {
    flex-direction: row;
    align-items: center;
    border: 0;
    margin: 0;
    padding: 0 0.4rem;
    gap: 0.65rem;
  }
  .brand-mark { width: 28px; height: 28px; margin-top: 0; }
  .brand-title { font-size: 1rem; }
  .nav { flex-direction: row; }
  .sidebar-foot { display: none; }
  .form, .panels { grid-template-columns: 1fr; }
}

/* Branding without Flow product marks */
.brand-title {
  color: #fff;
}
.brand-sub {
  margin-top: 0.22rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.52);
}
.team-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}
.toolbar-search input {
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.88rem;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e8eef8 0%, var(--bg) 100%);
  padding: 1.5rem;
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}
.login-brand {
  background: var(--navy);
  padding: 1.15rem 1.45rem 1.05rem;
}
.login-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.login-logo-fallback {
  height: 40px;
  width: 40px;
  max-width: 40px;
  border-radius: 8px;
}
.login-panel {
  padding: 1.55rem 1.7rem 1.75rem;
}
.login-card h1 {
  margin: 0;
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.login-card .subtitle {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1.35rem;
}
.login-form label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  margin-top: 0.4rem;
}
.login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}
.login-form .btn { margin-top: 1rem; }
.login-error {
  margin: 0.65rem 0 0;
  color: var(--err);
  font-size: 0.85rem;
}
.user-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.user-bar .username {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
}

.toolbar { flex-wrap: wrap; }
#mine-seg { margin-left: 0.35rem; }


/* Make Trigger input column hard to miss */
th.trigger-col, td.trigger-td {
  min-width: 180px;
  background: rgba(37, 99, 235, 0.06);
}
.trigger-summary {
  font-weight: 600;
}
