:root {
  --bg: #eef3fb;
  --bg-accent: radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 28%), linear-gradient(180deg, #f7f9fd 0%, #edf3fb 100%);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --border: #e4eaf4;
  --border-strong: #d6deeb;
  --text: #172033;
  --muted: #667085;
  --primary: #2563eb;
  --primary-soft: #e8f0ff;
  --secondary-soft: #f8fafc;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg-accent);
  color: var(--text);
}

body.layer-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
}

input[readonly] {
  background: rgba(248, 250, 252, 0.95);
  color: #344054;
}

.layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111c34 100%);
  color: #f8fafc;
  padding: 30px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 28px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  color: rgba(248, 250, 252, 0.82);
  padding: 13px 14px;
  border-radius: 14px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  padding: 30px 34px 44px;
}

.topbar,
.section-head,
.card-head,
.actions,
.subject-option-main,
.subject-option-meta,
.subject-admin-header,
.subject-admin-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar {
  align-items: flex-start;
  margin-bottom: 30px;
}

.topbar h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.topbar p,
.subject-meta,
.muted,
.subject-option p,
.subject-admin-item p,
.link-field-row p,
.task-name-text,
.session-user {
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(214, 222, 235, 0.8);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.topbar-meta-rich {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: min(100%, 760px);
}

.subject-summary,
.subject-meta,
.stack,
.detail-list,
.subject-switch-list,
.subject-admin-list,
.subject-step-list,
.editor-links-list {
  display: grid;
  gap: 12px;
}

.subject-pill-label,
.stat-label,
.detail-list span,
.table-meta,
.editor-banner .muted {
  font-size: 12px;
  color: var(--muted);
}

.subject-meta {
  gap: 8px;
  min-width: 0;
}

.subject-meta-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text);
}

.subject-meta-title strong {
  font-size: 18px;
  color: var(--text);
}

.subject-meta-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
}

.section-head {
  align-items: flex-start;
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.btn,
.link-button,
.text-action,
.icon-btn,
.subject-option {
  border: 0;
  cursor: pointer;
}

.btn {
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.session-user {
  display: inline-flex;
  align-items: center;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.card,
.stat-card {
  background: var(--panel);
  border: 1px solid rgba(228, 234, 244, 0.9);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.card,
.stat-card {
  padding: 22px;
}

.stats-grid,
.three-panel-grid,
.subject-settings-grid,
.runtime-grid,
.runtime-log-grid,
.form-row.two,
.form-row.three,
.check-grid,
.two-col,
.link-field-row {
  display: grid;
  gap: 16px;
}

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

.stat-card strong {
  display: block;
  font-size: 36px;
  margin: 12px 0 8px;
}

.two-col {
  grid-template-columns: 1.6fr 1fr;
}

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

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

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

.form-row {
  display: grid;
  gap: 14px;
}

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

.form-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
}

.info-inline,
.upload-box,
.preview-card,
.editor-banner,
.table-meta {
  padding: 14px 16px;
  border-radius: 14px;
}

.info-inline,
.preview-card,
.editor-banner {
  background: var(--primary-soft);
}

.upload-box {
  border: 1px dashed var(--border-strong);
  background: rgba(248, 250, 252, 0.75);
  text-align: center;
}

.upload-hint {
  font-size: 12px;
}

.preview-card {
  display: grid;
  gap: 6px;
}

.page-section {
  display: grid;
  gap: 0;
}

.subject-banner,
.subject-banner-main,
.subject-banner-title,
.subject-inline-meta,
.button-grid,
.feature-list,
.mode-grid,
.auth-panel-stack,
.avatar-copy,
.subject-admin-tags,
.avatar-upload-panel,
.avatar-preview-card,
.avatar-preview-copy {
  display: grid;
  gap: 12px;
}

.subject-banner {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
}

.subject-banner-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.subject-banner-title strong {
  font-size: 24px;
}

.subject-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 13px;
  color: var(--muted);
}

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

.title-inline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.table-meta.inline {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.feature-list div {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.82);
  color: #344054;
}

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

.mode-card,
.reserve-card {
  width: 100%;
  text-align: left;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.84);
  box-shadow: var(--shadow-soft);
}

.mode-card {
  padding: 18px;
  cursor: pointer;
}

.mode-card.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(232, 240, 255, 0.98);
}

.mode-card.static {
  box-shadow: none;
  cursor: default;
}

.mode-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.auth-panel {
  display: grid;
  gap: 14px;
}

.reserve-card {
  padding: 18px;
}

.login-error {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(220, 38, 38, 0.22);
  background: rgba(254, 242, 242, 0.92);
  color: #b91c1c;
}

.subject-option,
.subject-admin-item,
.link-field-row,
.runtime-card,
.runtime-log-card {
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.84);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.subject-option.active,
.subject-admin-item.active {
  border-color: rgba(37, 99, 235, 0.32);
  background: rgba(232, 240, 255, 0.95);
}

.runtime-card strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.runtime-meta-list,
.runtime-log-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.runtime-meta-list span {
  font-size: 13px;
  color: var(--muted);
}

.runtime-log-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.85);
}

.runtime-log-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.runtime-log-item-head strong {
  font-size: 13px;
}

.runtime-log-item-head span,
.runtime-log-item p,
.runtime-log-empty {
  font-size: 12px;
  color: var(--muted);
}

.runtime-log-item.danger {
  border-color: rgba(220, 38, 38, 0.18);
  background: rgba(254, 242, 242, 0.82);
}

.runtime-log-empty {
  padding: 8px 0;
}

.subject-option-meta,
.subject-admin-meta {
  font-size: 13px;
  margin-top: 10px;
}

.subject-settings-grid {
  grid-template-columns: 1.25fr 0.95fr;
}

.detail-panel {
  display: grid;
  gap: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag.success {
  background: rgba(22, 163, 74, 0.12);
  color: var(--success);
}

.tag.warning {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warning);
}

.tag.danger {
  background: rgba(220, 38, 38, 0.14);
  color: var(--danger);
}

.link-button,
.text-action {
  background: transparent;
  color: var(--primary);
  padding: 0;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--secondary-soft);
}

.timeline {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

tbody td {
  padding: 18px 16px;
  border-bottom: 1px solid rgba(228, 234, 244, 0.9);
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.98);
}

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

tbody tr:hover td {
  background: #fbfdff;
}

.overview-table,
.task-table {
  min-width: 100%;
}

.overview-table {
  min-width: 720px;
}

.task-table {
  min-width: 1180px;
  table-layout: fixed;
}

.task-col-primary {
  width: 23%;
}

.task-col-subject {
  width: 14%;
}

.task-col-range {
  width: 14%;
}

.task-col-avatar {
  width: 17%;
}

.task-col-count {
  width: 10%;
}

.task-col-created,
.task-col-updated {
  width: 11%;
}

.task-col-actions {
  width: 16%;
}

.task-primary-cell {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.task-index {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  background: #eaf2ff;
}

.task-primary-cell strong {
  font-size: 15px;
}

.task-primary-cell.compact {
  gap: 6px;
}

.task-helper {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.enterprise-cell,
.range-cell,
.count-cell,
.time-cell {
  font-size: 14px;
  color: #344054;
}

.enterprise-cell strong,
.count-cell {
  font-weight: 600;
}

.avatar-cell {
  min-width: 160px;
}

.avatar-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(241, 245, 249, 0.98) 100%);
  border: 1px solid var(--border);
}

.avatar-image {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
  display: inline-flex;
  background: #e5e7eb;
}

.avatar-swatch {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.avatar-copy {
  gap: 4px;
}

.avatar-copy strong {
  font-size: 13px;
}

.avatar-copy span {
  font-size: 12px;
  color: #475467;
}

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

.compact-actions {
  justify-content: flex-start;
}

.mini-action {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
}

.action-analyze {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #dbeafe;
}

.action-edit {
  color: #15803d;
  background: #f0fdf4;
  border-color: #dcfce7;
}

.action-delete {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.editor-card {
  display: grid;
  gap: 0;
}

.link-field-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: flex-start;
}

.links-empty {
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.82);
}

.overview-empty-cell {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
}

.upload-avatar-box {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-preview-card {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.82);
}

.avatar-preview-media {
  width: 100%;
  min-height: 132px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-preview-media img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  display: block;
}

.avatar-preview-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  color: #1d4ed8;
  background: rgba(219, 234, 254, 0.88);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.modal-shell,
.drawer-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.modal-shell:not([hidden]),
.drawer-shell:not([hidden]) {
  display: grid;
}

.modal-shell {
  place-items: center;
  padding: 24px;
}

.modal {
  width: min(820px, 100%);
  background: var(--panel-strong);
}

.modal-medium {
  max-width: 720px;
}

.modal-large {
  max-width: 820px;
}

.modal-small {
  max-width: 560px;
}

.drawer-shell {
  justify-items: end;
}

.drawer-panel {
  width: min(560px, 100%);
  min-height: 100vh;
  border-radius: 0;
  border-left: 1px solid var(--border);
  padding: 24px;
  background: var(--panel-strong);
  overflow-y: auto;
}

.toast {
  position: fixed;
  right: 28px;
  top: 24px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(23, 32, 51, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 60;
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.top-gap {
  margin-top: 16px;
}

.empty-card {
  text-align: center;
  padding: 48px 20px;
}

.subject-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
}

.subject-step strong {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.auth-scope-grid label {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.75);
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .stats-grid,
  .two-col,
  .subject-settings-grid,
  .three-panel-grid,
  .runtime-grid,
  .runtime-log-grid,
  .mode-grid,
  .form-row.two,
  .form-row.three,
  .check-grid,
  .link-field-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .topbar-meta-rich,
  .subject-banner {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 20px 16px 32px;
  }

  .actions,
  .card-head,
  .topbar-meta,
  .topbar-meta-rich {
    width: 100%;
  }

  .btn,
  .subject-option {
    width: 100%;
  }

  .subject-banner {
    grid-template-columns: 1fr;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody td {
    padding: 10px 0;
    border-bottom: 0;
  }

  tbody tr {
    border-bottom: 1px solid rgba(228, 234, 244, 0.9);
    padding: 12px 0;
  }

  .overview-table thead,
  .task-table thead {
    display: table-header-group;
  }

  .overview-table tbody,
  .task-table tbody {
    display: table-row-group;
  }

  .overview-table tr,
  .task-table tr {
    display: table-row;
  }

  .overview-table td,
  .task-table td {
    display: table-cell;
    width: auto;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(228, 234, 244, 0.9);
  }

  .overview-table tbody tr,
  .task-table tbody tr {
    border-bottom: 0;
    padding: 0;
  }

  .toast {
    left: 16px;
    right: 16px;
    top: 16px;
  }
}
