:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #647086;
  --line: #dbe1ea;
  --line-strong: #c3ccda;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #f59e0b;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --warning-bg: #fff8e6;
  --warning-line: #f2c94c;
  --shadow: 0 12px 36px rgba(24, 39, 75, 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: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--brand-dark);
}

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

.login-panel {
  width: min(480px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-title {
  margin: 0 0 6px;
  font-size: 28px;
}

.login-copy {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 16px;
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav button,
.ghost-button,
.secondary-button,
.primary-button,
.danger-button,
.icon-button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.nav button.active,
.primary-button {
  background: var(--brand);
  color: #fff;
}

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

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

.ghost-button:hover,
.nav button:hover,
.secondary-button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.danger-button {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #ffcdc7;
}

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

.user-pill,
.badge,
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.user-pill {
  background: #edf7f6;
  color: var(--brand-dark);
}

.badge {
  background: #fff4db;
  color: #8a4b00;
  font-weight: 700;
}

.state-pill {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
}

.state-pill.good {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
}

.state-pill.warn {
  border-color: #fde68a;
  background: var(--warning-bg);
  color: #8a4b00;
}

.state-pill.danger {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title {
  margin: 0;
  font-size: 24px;
}

.section-copy {
  margin: 4px 0 0;
  color: var(--muted);
}

.toolbar,
.filters,
.form-row,
.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.panel-body {
  padding: 16px;
}

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

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f8fafc;
}

tr.winning {
  background: #fff9e8;
}

.article-title-button {
  padding: 0;
  background: transparent;
  color: var(--brand-dark);
  font-weight: 700;
  text-align: left;
}

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

.stack {
  display: grid;
  gap: 12px;
}

.article-expand {
  background: #fbfcfe;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.run-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 12px;
}

.alert.warning {
  border-color: var(--warning-line);
  background: var(--warning-bg);
}

.alert.error {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.alert.success {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
}

.notification-panel {
  position: absolute;
  top: 54px;
  right: 18px;
  width: min(420px, calc(100vw - 36px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 40;
}

.notification-item {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.notification-item:last-child {
  border-bottom: 0;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.card h3 {
  margin: 0 0 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .main {
    padding: 14px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .section-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
