:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #17211d;
  --muted: #5f6c66;
  --border: #dfe6df;
  --accent: #116b4f;
  --accent-strong: #0b4f3a;
  --accent-soft: #e7f4ee;
  --blue: #245a8d;
  --danger: #9f2d2d;
  --shadow: 0 18px 50px rgba(26, 38, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 10;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
}

.skip-link:focus {
  left: 8px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #13231c;
  color: #f7fbf7;
  overflow-y: auto;
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-block span {
  display: block;
  color: #b8c8c0;
  font-size: 14px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #45c878, #f2d06b);
  flex: 0 0 auto;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #cbd9d2;
  font-size: 13px;
  font-weight: 700;
}

.select-control,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.select-control {
  margin-bottom: 24px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav a {
  display: block;
  border-radius: 8px;
  padding: 11px 12px;
  color: #dce7e1;
}

.side-nav a:hover,
.side-nav a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
}

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

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

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
}

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

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

.stat-grid-wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

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

.section-tile,
.company-row {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.section-tile span,
.company-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.rule-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.rule-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}

.rule-list dt {
  color: var(--muted);
  font-weight: 700;
}

.rule-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.button:hover {
  text-decoration: none;
}

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

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.button-danger {
  border-color: #f1c9c9;
  background: #faeaea;
  color: var(--danger);
}

.button-danger:hover {
  border-color: var(--danger);
  background: #f6dcdc;
}

.button-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-pill {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
}

.filter-pill.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.form-stack,
.form-inline {
  display: grid;
  gap: 14px;
}

.form-inline {
  grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

code {
  border-radius: 6px;
  background: #eef2ed;
  padding: 2px 5px;
  color: #26342e;
  font-size: 0.9em;
}

.table-action {
  font-weight: 800;
}

.compact-actions {
  gap: 8px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
}

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

.table-input {
  min-width: 130px;
  padding: 8px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 20px;
}

.editor-actions {
  display: block;
}

.markdown-editor {
  min-height: 64vh;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  line-height: 1.55;
}

.markdown-preview {
  max-width: 760px;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  line-height: 1.2;
}

.markdown-preview p,
.markdown-preview li {
  color: #26342e;
}

.markdown-preview pre {
  overflow-x: auto;
  border-radius: 8px;
  background: #101b16;
  color: #eef8f1;
  padding: 14px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.asset-card {
  overflow: hidden;
}

.asset-card img,
.asset-placeholder {
  width: 100%;
  height: 170px;
  object-fit: contain;
  background: #eef2ed;
}

.asset-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.asset-card div {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.asset-card span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.asset-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

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

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

.channel-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 16px;
}

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

.status-pill {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

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

.metric-definition-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.metric-definition-list span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.check-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
  margin-bottom: 0;
}

.flash-list {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash-success {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.flash-error {
  background: #faeaea;
  color: var(--danger);
}

.warning-panel {
  margin-bottom: 20px;
  border-color: #d7b84d;
  background: #fff9df;
}

.ai-grid {
  align-items: start;
}

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

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.toggle-row input {
  width: auto;
  min-width: 18px;
  min-height: 18px;
}

.prompt-block,
.log-box,
.output-box {
  overflow: auto;
  border-radius: 8px;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-block {
  background: #eef2ed;
  color: #26342e;
  min-height: 120px;
}

.memory-editor {
  min-height: 560px;
}

.inline-json {
  max-width: 360px;
  max-height: 180px;
  overflow: auto;
  border-radius: 6px;
  margin: 0;
  background: #eef2ed;
  color: #26342e;
  padding: 8px;
  white-space: pre-wrap;
  font-size: 12px;
}

.change-list {
  display: grid;
  gap: 8px;
}

.change-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfa;
}

.change-row span {
  border-radius: 999px;
  padding: 4px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.change-added span {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.change-modified span {
  background: #e8f0fb;
  color: var(--blue);
}

.change-deleted span {
  background: #faeaea;
  color: var(--danger);
}

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

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

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

  .stat-grid,
  .stat-grid-wide,
  .grid-two,
  .channel-grid,
  .editor-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .main-panel,
  .sidebar {
    padding: 18px;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
