:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-raised: #fbfcfe;
  --line: #dbe3ee;
  --line-soft: #edf1f6;
  --text: #172033;
  --text-soft: #40516a;
  --muted: #748197;
  --primary: #0b8f70;
  --primary-dark: #08795f;
  --primary-soft: #e8f6f1;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --warn: #a16207;
  --warn-soft: #fff6dc;
  --danger: #d92d46;
  --danger-soft: #fff1f3;
  --shadow: 0 16px 34px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .auth-screen {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card__head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.product-mark,
.brand__name {
  font-weight: 900;
}

.product-mark {
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 13px;
}

.auth-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

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

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.brand__name {
  font-size: 18px;
}

.brand__meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.environment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.nav-group {
  display: grid;
  gap: 5px;
  padding-top: 18px;
}

.nav-label {
  margin: 0 8px 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  padding: 0 10px;
  text-align: left;
  font-size: 14px;
  font-weight: 800;
}

.nav-item:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.nav-item.is-active {
  border-color: rgba(11, 143, 112, 0.24);
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  border-radius: 6px;
  background: #eef3f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.nav-item.is-active .nav-key {
  background: var(--primary);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 22px 24px 32px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  margin-bottom: 16px;
}

.crumb {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.2;
  font-weight: 900;
}

.topbar p,
.panel__head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
}

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

.session-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  background: var(--surface-raised);
  border-color: #c9d3df;
}

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

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

.button--wide {
  width: 100%;
}

.button:disabled,
.control:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}

.status-item__label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.status-item strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.summary-card,
.panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.summary-card {
  min-width: 0;
  padding: 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.summary-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 14px;
  align-items: start;
}

.content-grid--wide {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
  padding: 12px 14px;
}

.panel__head h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 900;
}

.panel__body {
  padding: 14px;
}

.model-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  gap: 14px;
  align-items: start;
}

.settings-column {
  display: grid;
  gap: 14px;
}

.section-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  padding: 12px;
}

.key-box p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.control {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  outline: none;
  font-size: 13px;
  font-weight: 750;
}

.control:focus {
  border-color: rgba(11, 143, 112, 0.7);
  box-shadow: 0 0 0 3px rgba(11, 143, 112, 0.12);
}

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

.side-panel {
  padding: 14px;
}

.side-panel__title {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.config-readout {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}

.config-readout div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

.config-readout div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.config-readout dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.config-readout dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
  overflow-wrap: anywhere;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
  padding: 12px 14px;
}

.save-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.tag--ok {
  background: var(--primary-soft);
  color: var(--primary);
}

.tag--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.tag--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag--muted {
  background: #eef3f7;
  color: var(--muted);
}

.priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 24px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.priority--p0 {
  background: var(--danger-soft);
  color: var(--danger);
}

.priority--p1 {
  background: var(--warn-soft);
  color: var(--warn);
}

.task-list {
  display: grid;
  gap: 0;
}

.task-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.task-row:last-child {
  border-bottom: 0;
}

.task-row strong {
  display: block;
  font-size: 13px;
}

.task-row p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}

th {
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  color: var(--text-soft);
  font-weight: 650;
}

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

.module-empty {
  display: grid;
  gap: 14px;
}

.module-empty__intro {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.module-empty__intro h2 {
  font-size: 18px;
}

.module-empty__intro p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.definition-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.definition-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.definition-card strong {
  display: block;
  margin-top: 7px;
  font-size: 14px;
  line-height: 1.35;
}

.inline-alert {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text-soft);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.inline-alert:not(:empty) {
  display: block;
}

.inline-alert--danger {
  border-color: rgba(217, 45, 70, 0.25);
  background: var(--danger-soft);
  color: var(--danger);
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(440px, calc(100vw - 40px));
  border: 1px solid rgba(11, 143, 112, 0.22);
  border-radius: 8px;
  background: #f7fffb;
  color: var(--primary);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

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

  .content-grid,
  .content-grid--wide,
  .model-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    padding: 16px;
  }

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

  .topbar__actions,
  .form-footer,
  .key-box {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .summary-grid,
  .definition-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}
