:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #20242c;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #176b87;
  --primary-dark: #0f4f63;
  --accent: #5f7a38;
  --warn: #a15c00;
  --danger: #a33a3a;
  --soft: #eef6f8;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(16, 24, 40, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  background: #132833;
  color: #fff;
  padding: 18px 14px;
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
  margin-bottom: 12px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #b8c7cf;
  font-size: 13px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #e7f3f6;
  color: #12313d;
  border-radius: 8px;
  font-weight: 800;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: #d8e4e9;
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  cursor: pointer;
}

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

.shell {
  margin-left: 270px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 86px;
  background: rgba(246, 247, 249, .95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 27px;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  margin-bottom: 12px;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
}

.phase-pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #fff7e8;
  color: var(--warn);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.content {
  padding: 24px 26px 42px;
}

.login-panel {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.login-panel .panel {
  width: min(420px, 100%);
}

.logout-btn {
  min-height: 30px;
  padding: 4px 9px;
  margin-left: 8px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
}

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

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

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

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

.metric {
  min-height: 108px;
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 27px;
}

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

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  min-height: 38px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 650;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #fff;
  color: var(--primary);
  border-color: #aac3cb;
}

.btn.secondary:hover {
  background: var(--soft);
}

.btn.warning {
  background: var(--warn);
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  background: transparent;
  color: var(--primary);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.control-panel {
  margin-bottom: 16px;
}

.op-status.running {
  background: #edf8ed;
  color: var(--accent);
}

.op-status.stopped {
  background: #fff7e8;
  color: var(--warn);
}

.op-status.maintenance {
  background: #eef2ff;
  color: #344054;
}

.control-actions {
  margin-top: 14px;
}

.operation-result {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.operation-result.ok {
  border-color: #b8d6b8;
  background: #f3faf3;
}

.operation-result.warning {
  border-color: #e1c28f;
  background: #fffaf0;
}

.readiness-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.readiness-item {
  display: grid;
  gap: 2px;
  border-left: 4px solid var(--line);
  padding: 7px 8px;
  background: #fff;
}

.readiness-item.ready {
  border-left-color: var(--accent);
}

.readiness-item.blocked {
  border-left-color: var(--warn);
}

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

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  color: #344054;
  font-weight: 650;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd3df;
  border-radius: 7px;
  background: #fff;
  min-height: 38px;
  padding: 9px 10px;
  color: var(--ink);
}

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

.search {
  min-width: 260px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

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

th {
  background: #f1f4f7;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: #29313d;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.status.pending_review,
.status.approved_for_learning,
.status.rejected,
.status.deleted {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.tag {
  background: #edf2f7;
  color: #344054;
}

.status.pending_review {
  background: #fff7e8;
  color: var(--warn);
}

.status.approved_for_learning {
  background: #edf8ed;
  color: var(--accent);
}

.status.rejected,
.status.deleted {
  background: #fff0f0;
  color: var(--danger);
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 40, .42);
  padding: 20px;
}

.modal {
  width: min(850px, 100%);
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.modal-head h2 {
  margin: 0;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #b9d3db;
  background: var(--soft);
  color: #244b58;
  margin-bottom: 14px;
}

.edit-surface {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: 14px 0;
}

.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  margin: 4px 0 12px;
  background: #fbfcfd;
}

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

.proposal-panel {
  border-color: #9ec4cf;
  background: #fbfeff;
}

.recommendation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, .7fr) minmax(220px, .8fr);
  gap: 12px;
}

.success-note {
  border-color: #bad9bd;
  background: #f1faf1;
  color: #345f35;
}

.version-arrow {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  padding: 12px;
}

.version-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfd;
}

.version-item .muted {
  display: block;
  margin-top: 2px;
}

.knowledge-group {
  margin: 14px 0;
}

.knowledge-group h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.split-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
  min-height: 160px;
  white-space: pre-wrap;
}

.knowledge-preview {
  max-height: 420px;
  overflow-y: auto;
  line-height: 1.55;
}

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

.metadata-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 10px;
}

mark {
  background: #fff2a8;
  padding: 1px 2px;
  border-radius: 3px;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .shell {
    margin-left: 0;
  }

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

  .grid.two,
  .grid.three,
  .grid.four,
  .recommendation-grid,
  .split-preview,
  .metadata-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }
}
