:root {
  color-scheme: dark;
  --bg: #20272d;
  --surface: #273039;
  --panel: #2c3640;
  --panel-2: #34414c;
  --line: #46535f;
  --text: #f4f7f9;
  --muted: #c2cbd2;
  --muted-2: #9faeb8;
  --green: #20b26b;
  --green-2: #159257;
  --red: #e05252;
  --yellow: #d7a63e;
  --blue: #4aa3df;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(32, 178, 107, 0.05), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 238px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--line);
}

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

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.nav-item.active {
  background: rgba(32, 178, 107, 0.14);
  border-left: 3px solid var(--green);
  color: var(--text);
  padding-left: 9px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px 26px;
  background: rgba(39, 48, 57, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

#page-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

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

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

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

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

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

.login-brand {
  padding: 18px;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.cards {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

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

.card {
  min-height: 104px;
  padding: 16px;
}

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

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

.card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.btn {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 13px;
  background: var(--green);
  color: #06120b;
  font-weight: 700;
}

.btn:hover {
  background: var(--green-2);
  color: #eefbf4;
}

.btn.secondary {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.btn.danger {
  background: transparent;
  border-color: rgba(224, 82, 82, 0.55);
  color: #ffb0b0;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.small {
  min-height: 29px;
  padding: 0 10px;
  font-size: 12px;
}

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

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

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

th {
  background: var(--panel-2);
  color: #d5dde2;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: #edf2f5;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.success {
  background: rgba(32, 178, 107, 0.16);
  color: #79e2ad;
}

.pill.error {
  background: rgba(224, 82, 82, 0.16);
  color: #ff9f9f;
}

.pill.warning {
  background: rgba(215, 166, 62, 0.16);
  color: #ffd27a;
}

.pill.neutral {
  background: rgba(151, 165, 173, 0.14);
  color: #c4ced3;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #222b33;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 41px;
}

.check-row input {
  width: 17px;
  height: 17px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.toast {
  position: fixed;
  top: 90px;
  right: 24px;
  z-index: 30;
  max-width: 420px;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.toast.ok {
  border-color: rgba(32, 178, 107, 0.55);
}

.toast.fail {
  border-color: rgba(224, 82, 82, 0.65);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(10, 15, 18, 0.52);
}

.modal {
  width: min(880px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  padding: 16px;
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.template-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.template-vars code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 7px;
  background: #222b33;
  color: #d9f7e7;
  font-size: 12px;
}

.template-textarea {
  min-height: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.template-preview {
  margin: 0;
  min-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #20272d;
  color: var(--text);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

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

  .shell {
    margin-left: 0;
  }

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

  .cards,
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

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