:root {
  --bg: #0b0e14;
  --surface: #11161f;
  --surface-raised: #161d28;
  --surface-soft: #131a24;
  --surface-hover: #1a2330;
  --border: #263142;
  --border-strong: #35455d;
  --text: #e7edf7;
  --text-soft: #c3cddb;
  --muted: #8b98ab;
  --muted-strong: #6f7d92;
  --accent: #86a5ff;
  --accent-strong: #a7bcff;
  --accent-soft: rgba(134, 165, 255, 0.12);
  --accent-border: rgba(134, 165, 255, 0.32);
  --success: #59c99a;
  --success-soft: rgba(89, 201, 154, 0.12);
  --warning: #e3b767;
  --warning-soft: rgba(227, 183, 103, 0.12);
  --danger: #ef7b7b;
  --danger-soft: rgba(239, 123, 123, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

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

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

::selection {
  color: var(--text);
  background: rgba(134, 165, 255, 0.28);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2b374a;
  border: 3px solid var(--bg);
  border-radius: 999px;
}

.boot-screen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.brand-mark {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.brand-mark-large {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 22px;
}

.boot-copy {
  display: grid;
  gap: 2px;
}

.boot-copy strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.boot-copy span {
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.auth-page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.08fr) minmax(440px, 0.92fr);
  background: var(--surface);
}

.auth-story {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px clamp(32px, 6vw, 88px);
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.auth-story::after {
  position: absolute;
  right: -140px;
  bottom: -160px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(134, 165, 255, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 54px rgba(134, 165, 255, 0.025), 0 0 0 108px rgba(134, 165, 255, 0.018);
  content: "";
  pointer-events: none;
}

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

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-name {
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.035em;
}

.brand-meta {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.auth-story-content {
  position: relative;
  z-index: 1;
  max-width: 620px;
  padding: 64px 0;
}

.auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.auth-eyebrow::before {
  width: 18px;
  height: 1px;
  background: var(--accent);
  content: "";
}

.auth-title {
  max-width: 580px;
  margin: 0;
  font-size: clamp(34px, 4.1vw, 58px);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 1.12;
}

.auth-subtitle {
  max-width: 560px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 1.3vw, 18px);
  line-height: 1.8;
}

.feature-list {
  display: grid;
  gap: 14px;
  margin-top: 42px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  color: var(--text-soft);
}

.feature-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
}

.feature-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.feature-item span {
  color: var(--muted);
  font-size: 13px;
}

.boundary-card {
  position: relative;
  z-index: 1;
  max-width: 620px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17, 22, 31, 0.78);
}

.boundary-card-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.boundary-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.auth-panel {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 40px clamp(24px, 5vw, 72px);
}

.auth-card {
  width: min(100%, 430px);
  animation: fade-in 0.35s ease both;
}

.auth-card-heading {
  margin-bottom: 26px;
}

.auth-card-heading h2 {
  margin: 0 0 7px;
  font-size: 25px;
  font-weight: 640;
  letter-spacing: -0.035em;
}

.auth-card-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.auth-form {
  display: grid;
  gap: 17px;
}

.form-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.form-group label,
.field-label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 560;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.input,
.select {
  min-height: 42px;
  padding: 9px 12px;
}

.textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}

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

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b98ab' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--surface-raised);
  font-weight: 580;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.button:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-hover);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

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

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  color: #0b1020;
  background: var(--accent-strong);
}

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

.button-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-hover);
}

.button-danger {
  border-color: rgba(239, 123, 123, 0.3);
  color: var(--danger);
  background: var(--danger-soft);
}

.button-danger:hover:not(:disabled) {
  border-color: rgba(239, 123, 123, 0.5);
  color: #ff9c9c;
  background: rgba(239, 123, 123, 0.16);
}

.button-sm {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.button-block {
  width: 100%;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--muted-strong);
  font-size: 11px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--border);
  content: "";
}

.anonymous-box {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.anonymous-box-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  font-weight: 600;
}

.anonymous-box p {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 12px;
}

.auth-footnote {
  margin: 20px 0 0;
  color: var(--muted-strong);
  font-size: 11px;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 264px;
  flex-direction: column;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-header {
  padding: 0 8px 22px;
}

.workspace-switcher {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.sidebar-section-label {
  display: block;
  padding: 0 8px;
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workspace-select-wrap {
  position: relative;
}

.workspace-select-wrap .select {
  min-height: 44px;
  padding-left: 36px;
  border-color: var(--border);
  background-color: var(--surface-raised);
  font-weight: 580;
}

.workspace-select-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 11px;
  display: inline-flex;
  color: var(--accent);
  pointer-events: none;
  transform: translateY(-50%);
}

.workspace-create {
  width: 100%;
  justify-content: flex-start;
  color: var(--muted);
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  margin-top: 26px;
}

.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 520;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover {
  color: var(--text-soft);
  background: var(--surface-hover);
}

.nav-link.active {
  border-color: var(--accent-border);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.nav-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.42;
}

.nav-icon {
  display: inline-flex;
  flex: 0 0 auto;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 9px;
  background: var(--surface-soft);
}

.avatar {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
}

.user-meta {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 1px;
}

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

.user-meta strong {
  font-size: 12px;
  font-weight: 600;
}

.user-meta span {
  color: var(--muted);
  font-size: 10px;
}

.icon-button {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

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

.mobile-topbar {
  display: none;
}

.mobile-scrim {
  display: none;
}

.main-area {
  min-height: 100vh;
  margin-left: 264px;
}

.topbar {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(22px, 3.2vw, 46px);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.92);
}

.page-heading {
  display: grid;
  gap: 4px;
}

.page-heading h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.035em;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-badge,
.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-accent {
  border-color: var(--accent-border);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.badge-success {
  border-color: rgba(89, 201, 154, 0.25);
  color: var(--success);
  background: var(--success-soft);
}

.badge-warning {
  border-color: rgba(227, 183, 103, 0.25);
  color: var(--warning);
  background: var(--warning-soft);
}

.badge-danger {
  border-color: rgba(239, 123, 123, 0.25);
  color: var(--danger);
  background: var(--danger-soft);
}

.view {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 40px) clamp(22px, 3.2vw, 46px) 64px;
  animation: fade-in 0.24s ease both;
}

.view-stack {
  display: grid;
  gap: 22px;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-header h2,
.section-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.015em;
}

.section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 620;
}

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.panel-body {
  padding: 18px;
}

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

.metric-card {
  position: relative;
  display: grid;
  min-height: 142px;
  align-content: space-between;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 540;
}

.metric-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--accent);
  background: var(--surface-raised);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 1;
}

.metric-note {
  margin-top: 7px;
  color: var(--muted-strong);
  font-size: 10px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.data-table th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(38, 49, 66, 0.7);
  color: var(--text-soft);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.015);
}

.table-primary {
  color: var(--text);
  font-weight: 580;
}

.table-secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.mono {
  font-family: var(--font-mono);
}

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

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

.empty-state {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state-icon {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  margin-bottom: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--muted-strong);
  background: var(--surface-raised);
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.empty-state p {
  max-width: 380px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-state .button {
  margin-top: 16px;
}

.view-loading {
  display: grid;
  min-height: 420px;
  place-items: center;
  align-content: center;
  gap: 13px;
  color: var(--muted);
  font-size: 12px;
}

.view-loading .spinner {
  width: 24px;
  height: 24px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 18px;
}

.quick-grid {
  display: grid;
  gap: 10px;
}

.quick-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.quick-number {
  display: inline-flex;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-border);
  border-radius: 7px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 10px;
}

.quick-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 600;
}

.quick-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.boundary-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.boundary-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.boundary-list svg {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--success);
}

.workspace-empty {
  display: grid;
  min-height: calc(100vh - 180px);
  place-items: center;
}

.workspace-empty-card {
  width: min(100%, 560px);
  padding: clamp(28px, 5vw, 46px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.workspace-empty-card .empty-state-icon {
  width: 58px;
  height: 58px;
  margin-bottom: 20px;
  color: var(--accent);
}

.workspace-empty-card h2 {
  margin: 0 0 10px;
  font-size: 23px;
  font-weight: 640;
  letter-spacing: -0.035em;
}

.workspace-empty-card p {
  max-width: 430px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.workflow-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.workflow-list-panel {
  position: sticky;
  top: 18px;
}

.workflow-list {
  display: grid;
  max-height: calc(100vh - 190px);
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
}

.workflow-item {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.workflow-item:hover {
  background: var(--surface-hover);
}

.workflow-item.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.workflow-item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.workflow-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.workflow-detail {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-heading h2 {
  margin: 0 0 7px;
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -0.03em;
}

.detail-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: start;
}

.code-block,
.json-view {
  margin: 0;
  padding: 15px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #cbd8ee;
  background: #0c1119;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  tab-size: 2;
  white-space: pre;
}

.code-block {
  white-space: pre-wrap;
  word-break: break-word;
}

.state-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.state-meta-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.state-meta-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-strong);
  font-size: 9px;
}

.state-meta-item strong {
  display: block;
  overflow: hidden;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  display: grid;
  gap: 0;
  padding: 4px 0 4px 5px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 11px;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  position: absolute;
  top: 15px;
  bottom: -2px;
  left: 6px;
  width: 1px;
  background: var(--border);
  content: "";
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 13px;
  height: 13px;
  margin-top: 3px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.timeline-content {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.timeline-header strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.timeline-header time {
  color: var(--muted-strong);
  font-size: 9px;
  white-space: nowrap;
}

.timeline-actor {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
}

.timeline-summary {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.timeline-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.op-chip {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 9px;
}

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

.memory-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

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

.memory-card h4 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.memory-type {
  color: var(--muted-strong);
  font-size: 9px;
}

.memory-value {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.evidence-list {
  display: grid;
  gap: 6px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.evidence-item {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.evidence-item strong {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-weight: 500;
}

.form-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.form-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.form-panel-header h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 620;
}

.form-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

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

.form-grid .full-width {
  grid-column: 1 / -1;
}

.state-ops {
  display: grid;
  gap: 8px;
}

.state-op-row {
  display: grid;
  grid-template-columns: 104px minmax(130px, 0.7fr) minmax(180px, 1.3fr) 34px;
  gap: 8px;
  align-items: start;
}

.state-op-row .input,
.state-op-row .select {
  min-height: 38px;
  font-size: 11px;
}

.state-op-row .textarea {
  min-height: 38px;
  height: 38px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.state-op-row .icon-button {
  width: 34px;
  height: 38px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.optional-memory {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px dashed var(--border-strong);
}

.optional-memory summary {
  width: fit-content;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 580;
  cursor: pointer;
}

.optional-memory .form-grid {
  margin-top: 14px;
}

.search-result {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.search-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
  align-items: start;
}

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

.agent-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.agent-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.agent-avatar {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--accent-strong);
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 650;
}

.agent-identity strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-identity span {
  color: var(--muted);
  font-size: 10px;
}

.agent-properties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.agent-property {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.agent-property span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted-strong);
  font-size: 9px;
}

.agent-property strong {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 560;
}

.agent-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

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

.key-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.key-main {
  display: grid;
  gap: 7px;
}

.key-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.key-title-row strong {
  font-size: 13px;
  font-weight: 620;
}

.key-prefix {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-strong);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.scope-chip {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: 9px;
}

.audit-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.audit-filters .input {
  max-width: 340px;
}

.audit-details summary {
  color: var(--accent-strong);
  font-size: 11px;
  cursor: pointer;
}

.audit-details pre {
  max-width: 460px;
  margin: 9px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: pre-wrap;
}

.integration-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.code-toolbar span {
  color: var(--muted);
  font-size: 11px;
}

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

.tool-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.tool-item code {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
}

.tool-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.integration-notes {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.integration-notes li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.integration-notes svg {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 12, 0.76);
  backdrop-filter: blur(4px);
  animation: fade-in 0.16s ease both;
}

.modal {
  width: min(100%, 500px);
  max-height: min(88vh, 900px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: fade-in 0.2s ease both;
}

.modal-wide {
  width: min(100%, 720px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.025em;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.modal-body {
  max-height: calc(88vh - 150px);
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

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

.checkbox-grid {
  display: grid;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.checkbox-row input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

.checkbox-row strong {
  display: block;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 560;
}

.checkbox-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.secret-key {
  margin: 12px 0 0;
  padding: 14px;
  overflow-wrap: anywhere;
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  color: var(--accent-strong);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  user-select: all;
}

.secret-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(227, 183, 103, 0.25);
  border-radius: 9px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 11px;
  line-height: 1.7;
}

.secret-warning svg {
  flex: 0 0 auto;
  margin-top: 2px;
}

.confirm-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.toast-root {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: min(360px, calc(100vw - 44px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text-soft);
  background: var(--surface-raised);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  font-size: 12px;
  line-height: 1.6;
  pointer-events: auto;
  animation: fade-in 0.2s ease both;
}

.toast-success {
  border-color: rgba(89, 201, 154, 0.32);
}

.toast-success svg {
  color: var(--success);
}

.toast-error {
  border-color: rgba(239, 123, 123, 0.32);
}

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

.toast-info svg {
  color: var(--accent);
}

.toast svg {
  flex: 0 0 auto;
  margin-top: 1px;
}

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

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-story {
    min-height: auto;
    padding: 28px clamp(24px, 7vw, 64px) 38px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .auth-story-content {
    padding: 48px 0 34px;
  }

  .auth-title {
    max-width: 720px;
  }

  .auth-subtitle {
    max-width: 680px;
  }

  .feature-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .boundary-card {
    max-width: none;
  }

  .auth-panel {
    min-height: auto;
    padding: 42px clamp(24px, 7vw, 64px) 60px;
  }

  .sidebar {
    z-index: 70;
    width: 278px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

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

  .mobile-scrim {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(3, 6, 10, 0.68);
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }

  .mobile-scrim.open {
    visibility: visible;
    opacity: 1;
  }

  .mobile-topbar {
    position: sticky;
    z-index: 50;
    top: 0;
    display: flex;
    min-height: 62px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(17, 22, 31, 0.96);
    backdrop-filter: blur(8px);
  }

  .mobile-topbar .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 8px;
    font-size: 14px;
  }

  .mobile-topbar .brand-name {
    font-size: 15px;
  }

  .main-area {
    margin-left: 0;
  }

  .topbar {
    min-height: 74px;
  }

  .workflow-layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .state-op-row {
    grid-template-columns: 96px minmax(120px, 0.7fr) minmax(150px, 1.3fr) 34px;
  }
}

@media (max-width: 760px) {
  .feature-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    padding: 16px 18px;
  }

  .page-heading h1 {
    font-size: 19px;
  }

  .topbar-meta {
    padding-top: 2px;
  }

  .view {
    padding: 20px 16px 52px;
  }

  .workflow-layout {
    grid-template-columns: 1fr;
  }

  .workflow-list-panel {
    position: static;
  }

  .workflow-list {
    max-height: 280px;
  }

  .memory-grid,
  .agent-grid {
    grid-template-columns: 1fr;
  }

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

  .form-grid .full-width {
    grid-column: auto;
  }

  .state-op-row {
    grid-template-columns: 92px minmax(0, 1fr) 34px;
  }

  .state-op-row .state-op-value {
    grid-column: 1 / -1;
  }

  .state-op-row .state-op-remove {
    grid-column: 3;
    grid-row: 1;
  }

  .detail-heading {
    flex-direction: column;
  }

  .detail-badges {
    justify-content: flex-start;
  }

  .state-meta {
    grid-template-columns: 1fr;
  }

  .key-card {
    grid-template-columns: 1fr;
  }

  .key-card .button {
    justify-self: start;
  }

  .audit-filters .input {
    max-width: none;
  }

  .audit-filters {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .auth-story {
    padding: 22px 20px 30px;
  }

  .auth-story-content {
    padding: 38px 0 28px;
  }

  .auth-title {
    font-size: 32px;
  }

  .auth-subtitle {
    font-size: 14px;
  }

  .auth-panel {
    padding: 32px 20px 48px;
  }

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

  .metric-card {
    min-height: 124px;
  }

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

  .topbar-meta .badge {
    display: none;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .modal-wide {
    width: 100%;
    max-height: 92vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
  }

  .modal-body {
    max-height: calc(92vh - 150px);
  }

  .toast-root {
    right: 14px;
    bottom: 14px;
    width: calc(100vw - 28px);
  }
}
