:root {
  color-scheme: dark;
  --bg: #1e1e2e;
  --chrome: #181825;
  --panel: #181825;
  --panel-soft: #1e1e2e;
  --panel-lift: #202033;
  --line: #313244;
  --line-strong: #45475a;
  --text: #cdd6f4;
  --muted: #6c7086;
  --subtle: #a6adc8;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --red: #f38ba8;
  --mauve: #cba6f7;
}

* {
  box-sizing: border-box;
}

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

.app-frame {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  grid-template-rows: 42px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.titlebar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome);
  padding: 0 14px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.red { background: var(--red); }
.yellow { background: var(--yellow); }
.green { background: var(--green); }

.titlebar-title {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--chrome);
  padding: 16px 10px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 8px 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #89b4fa, #cba6f7);
  color: #11111b;
  font-weight: 900;
}

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

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.side-section {
  padding: 16px 8px 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
}

.side-link {
  display: flex;
  align-items: center;
  min-height: 34px;
  border-radius: 8px;
  color: var(--subtle);
  font-size: 13px;
  text-decoration: none;
  padding: 0 10px;
}

.side-link:hover,
.side-link.active {
  background: #89b4fa22;
  color: var(--blue);
}

.shell {
  min-width: 0;
  overflow-y: auto;
  padding: 22px 28px 42px;
}

.workspace-head {
  position: sticky;
  top: -22px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  padding: 6px 0 16px;
  margin: -6px 0 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--text);
  font-size: 21px;
  line-height: 1.25;
}

h2 {
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.workspace-head p,
.hint,
.muted {
  color: var(--muted);
}

.workspace-head p {
  margin-top: 6px;
  font-size: 13.5px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #89b4fa55;
  border-radius: 8px;
  background: #89b4fa22;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  padding: 0 12px;
}

button,
.ghost-button {
  border: 1px solid #89b4fa55;
  border-radius: 8px;
  background: #89b4fa22;
  color: var(--blue);
  min-height: 36px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

button:hover,
.ghost-button:hover {
  background: #89b4fa33;
}

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

.mini-metrics {
  margin: 14px 0 0;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.metric {
  min-height: 74px;
  padding: 14px 16px;
  text-align: left;
}

.metric strong {
  display: block;
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.notice-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #f9e2af3d;
  border-radius: 8px;
  background: #f9e2af12;
  color: var(--subtle);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.notice-strip strong {
  color: var(--yellow);
  font-size: 13px;
  white-space: nowrap;
}

.notice-strip span {
  font-size: 12.5px;
}

.grid {
  display: grid;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

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

.grid.uneven {
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
}

.panel {
  min-width: 0;
  padding: 16px;
}

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

.panel-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.role-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.role {
  min-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 16px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.role:hover {
  border-color: #89b4fa55;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
  transform: translateY(-2px);
}

.role strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #313244;
  color: var(--subtle);
  font-size: 11px;
  padding: 4px 8px;
  margin: 8px 6px 0 0;
}

.tag.core {
  border-color: #89b4fa55;
  background: #89b4fa22;
  color: var(--blue);
}

.form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 12px;
}

.form.inline {
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  min-height: 36px;
  padding: 7px 10px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px #89b4fa22;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

.compact-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-lift);
  padding: 12px;
}

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

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
}

#eventForm .action-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

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

.timeline-list {
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px 12px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.item-head strong {
  color: var(--text);
  font-size: 13.5px;
}

.item p {
  margin-top: 6px;
  color: var(--subtle);
  font-size: 13px;
  line-height: 1.45;
}

.item .muted {
  font-size: 12px;
  line-height: 1.4;
}

.risk-高,
.risk-中,
.risk-低,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 0 8px;
  white-space: nowrap;
}

.risk-高 { border: 1px solid #f38ba866; background: #f38ba81a; color: var(--red); }
.risk-中 { border: 1px solid #f9e2af66; background: #f9e2af1a; color: var(--yellow); }
.risk-低 { border: 1px solid #a6e3a166; background: #a6e3a11a; color: var(--green); }

.status-pill {
  border: 1px solid #89b4fa55;
  background: #89b4fa1a;
  color: var(--blue);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 800;
}

code,
pre {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

code {
  padding: 2px 5px;
}

pre {
  overflow: auto;
  padding: 10px;
  min-height: 44px;
  max-height: 140px;
}

#evaluations {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.integration-panel {
  min-height: 320px;
}

.channel-panel {
  margin-top: 16px;
}

.channel-filter {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto auto auto;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  color: var(--subtle);
  font-size: 12px;
  white-space: nowrap;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.table-split {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 14px;
  margin-top: 14px;
}

.table-title {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.table-scroll {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-scroll table {
  margin-top: 0;
}

.table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-lift);
}

.table-scroll a {
  color: var(--blue);
  text-decoration: none;
}

.contact-cell {
  min-width: 180px;
  color: var(--subtle);
  font-size: 11.5px;
  line-height: 1.45;
}

@media (max-width: 1320px) {
  .action-row,
  #eventForm .action-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .app-frame {
    grid-template-columns: 1fr;
    grid-template-rows: 42px auto minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand,
  .side-section {
    display: none;
  }

  .side-link {
    white-space: nowrap;
  }

  .metrics,
  .grid.two,
  .grid.uneven,
  .role-list,
  .form.inline,
  .channel-filter,
  .table-split,
  .field-grid,
  .action-row,
  #eventForm .action-row {
    grid-template-columns: 1fr;
  }

  .workspace-head,
  .notice-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}
