:root {
  --bg: #f5f5f0;
  --fg: #1d1b16;
  --accent: #004e64;
  --warn: #b45309;
  --error: #b91c1c;
}
body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-width: 320px;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  flex-wrap: wrap;
  background:
    radial-gradient(circle at top left, rgba(199, 141, 66, 0.14), transparent 34%),
    linear-gradient(135deg, #f3eee3 0%, #ebe4d6 52%, #e4ddcf 100%);
  border-bottom: 1px solid #d7cebf;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.55);
}
header a { color: var(--fg); text-decoration: none; }
main {
  padding: 20px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}
.logo { font-weight: 700; letter-spacing: 1px; display: flex; align-items: center; gap: 10px; }
.mode-badge { font-size: 0.75rem; letter-spacing: 0.5px; padding: 6px 10px; border-radius: 999px; border: 1px solid #b9b1a7; background: #f4efe6; }
.mode-test { color: #7c2d12; border-color: #c7a48b; background: #f8e8da; }
.mode-hardened { color: #065f46; border-color: #8abf9f; background: #e7f6ed; }
.logo-img { width: 26px; height: 26px; }
.logo-img-lg { width: 72px; height: 72px; }
.logo-block { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 10px; }
.logo-title { font-weight: 700; letter-spacing: 0.5px; }
.center { max-width: 320px; margin: 10vh auto; }
input { padding: 6px; margin-bottom: 8px; width: 100%; box-sizing: border-box; }
select, textarea { padding: 6px; margin-bottom: 8px; width: 100%; box-sizing: border-box; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0 6px 0 0; vertical-align: middle; }
label input[type="checkbox"] { margin-right: 8px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid #ddd; padding: 6px; text-align: center; }
th { white-space: nowrap; }
td { vertical-align: top; }
.t-left { text-align: left; }
.t-right { text-align: right; }
.warn { background: #fff3cd; padding: 10px; }
.error { background: #fee2e2; padding: 10px; }
.flash { padding: 10px; margin-bottom: 10px; }
.flash.success { background: #dcfce7; border: 1px solid #86efac; }
.card { background: #fff; padding: 10px; margin-bottom: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-start; margin-top: 10px; }
.actions form { display: inline-block; margin: 0; width: auto; }
.actions .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
}
.actions .action-btn-download {
  background: #f4f8fa;
  border-color: #2d5664;
  color: #17343d;
}
.actions .action-btn-download:hover { background: #e7f0f4; }
.actions .action-btn-soft {
  background: #f6f8f9;
  border-color: #c8d5db;
  color: #17343d;
}
.actions .action-btn-soft:hover { background: #edf2f4; }
.btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  box-sizing: border-box;
  cursor: pointer;
}
.btn-dark {
  background: #f4f8fa;
  border-color: #2d5664;
  color: #17343d;
}
.btn-dark:hover { background: #e7f0f4; }
.btn-light {
  background: #f6f8f9;
  border-color: #c8d5db;
  color: #17343d;
}
.btn-light:hover { background: #edf2f4; }
.site-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 210px !important;
  height: 34px;
  padding: 0 12px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  box-sizing: border-box;
  cursor: pointer;
  text-decoration: none;
  appearance: none;
}
.site-btn-dark {
  background: #f4f8fa;
  border-color: #2d5664;
  color: #17343d;
}
.site-btn-dark:hover { background: #e7f0f4; }
.site-btn-light {
  background: #f6f8f9;
  border-color: #c8d5db;
  color: #17343d;
}
.site-btn-light:hover { background: #edf2f4; }
.form-grid { max-width: 520px; }
.form-grid label { font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: #6b6458; margin-bottom: 8px; }
.field-error { color: var(--error); font-size: 0.85rem; margin: 4px 0 8px; }
.field-error.hidden { display: none; }
.input-error { border: 1px solid var(--error); background: #fff5f5; }
.row { display: flex; gap: 12px; align-items: center; }
.row input, .row label { width: auto; margin: 0; }
.row form { margin: 0; width: auto; }
dialog { border: none; border-radius: 8px; padding: 16px; width: min(440px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
dialog form { padding-right: 6px; box-sizing: border-box; }
dialog::backdrop { background: rgba(0,0,0,0.3); }
button,
.btn,
.btn-secondary,
.btn-primary,
.btn-danger,
.site-btn,
.btn-inline,
.actions .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 0;
  height: 30px !important;
  padding: 0 10px;
  margin: 0 0 8px 0;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
button {
  background: #eef2f4;
  border-color: #b7c5cd;
  color: #17343d;
}
button:hover {
  background: #e2eaee;
}

.btn-primary,
button[type="submit"] {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}
.btn-primary:hover,
button[type="submit"]:hover {
  background: #0b5f58;
}

button.btn-secondary,
.btn-secondary,
button.btn,
.btn,
button.btn-link,
.btn-link,
button.site-btn-light,
.site-btn-light {
  background: #eef2f4;
  border-color: #b7c5cd;
  color: #17343d;
}
button.btn-secondary:hover,
.btn-secondary:hover,
button.btn:hover,
.btn:hover,
button.btn-link:hover,
.btn-link:hover,
button.site-btn-light:hover,
.site-btn-light:hover {
  background: #e2eaee;
}

button.btn-danger,
.btn-danger {
  background: #b91c1c;
  border-color: #991b1b;
  color: #fff;
}
button.btn-danger:hover,
.btn-danger:hover {
  background: #991b1b;
}

.site-btn-dark,
.actions .action-btn-download {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}
.site-btn-dark:hover,
.actions .action-btn-download:hover {
  background: #0b5f58;
}

/* Semantic action colors (set from global classifier in base.html) */
button.act-delete,
a.act-delete,
.act-delete {
  background: #b91c1c !important;
  border-color: #991b1b !important;
  color: #fff !important;
}
button.act-delete:hover,
a.act-delete:hover,
.act-delete:hover {
  background: #991b1b !important;
}

button.act-disable,
a.act-disable,
.act-disable {
  background: #8a5a24 !important;
  border-color: #6f4519 !important;
  color: #fff !important;
}
button.act-disable:hover,
a.act-disable:hover,
.act-disable:hover {
  background: #6f4519 !important;
}

button.act-enable,
a.act-enable,
.act-enable {
  background: #1f8f4e !important;
  border-color: #176f3c !important;
  color: #fff !important;
}
button.act-enable:hover,
a.act-enable:hover,
.act-enable:hover {
  background: #176f3c !important;
}

.copy-status {
  font-size: 12px;
  font-weight: 600;
}
.copy-status.ok { color: #1b6e37; }
.copy-status.bad { color: #9f1f1f; }

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: flex-end;
  padding: 2px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 30px;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #5d5548;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  position: relative;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.topbar-link:hover {
  background: transparent;
  color: #1d1b16;
}

.topbar-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e 0%, #1d7f8c 100%);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.topbar-link:hover::after,
.topbar-link.is-active::after {
  transform: scaleX(1);
  opacity: 1;
}

.topbar-link.is-active {
  background: transparent;
  color: #17343d;
  font-weight: 700;
}

.topbar-link:not(.is-active) {
  opacity: 0.82;
}

.topbar-link-exit {
  color: #7a2e1d;
}

.topbar-link-exit:hover {
  background: rgba(174, 61, 28, 0.1);
  color: #632012;
}

.table-shell {
  width: 100%;
  overflow: visible;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  background: #fff;
  position: relative;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.dropdown-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  min-width: 190px;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid rgba(180, 170, 154, 0.9);
  border-radius: 14px;
  box-shadow: 0 22px 46px rgba(48, 40, 29, 0.18);
  padding: 8px;
  backdrop-filter: blur(10px);
}

.dropdown-menu.open {
  display: block;
}

.dropdown-menu form,
.dropdown-menu a,
.dropdown-menu button {
  margin-bottom: 6px;
}

.dropdown-menu form:last-child,
.dropdown-menu a:last-child,
.dropdown-menu button:last-child {
  margin-bottom: 0;
}

.dropdown-menu button,
.dropdown-menu a {
  width: 100% !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}

.table-scroll table {
  margin: 0;
  min-width: 100%;
}

.table-scroll.table-scroll-compact table {
  width: max-content;
}

.card pre,
.card code,
.hint code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: #f7f4ee;
  padding: 10px;
  border-radius: 8px;
}

canvas {
  max-width: 100%;
}

@media (max-width: 900px) {
  header {
    padding: 14px 16px;
  }
  main {
    padding: 14px;
  }
  .topbar {
    align-items: flex-start;
  }
  .topbar-brand {
    width: 100%;
    justify-content: space-between;
  }
  .topbar-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 8px 14px;
  }
}

@media (max-width: 640px) {
  .logo {
    font-size: 0.95rem;
    letter-spacing: 0.4px;
  }
  .mode-badge {
    font-size: 0.68rem;
    padding: 5px 8px;
  }
  .topbar-link {
    min-height: 28px;
    padding: 4px 0;
    font-size: 0.82rem;
  }
  .topbar-link::after {
    bottom: -4px;
  }
  .row,
  .actions,
  .action-inline {
    align-items: stretch;
  }
  .row {
    flex-direction: column;
  }
  .row input,
  .row label,
  .row form,
  .row button,
  .row .btn,
  .row .btn-secondary,
  .row .btn-primary,
  .row .btn-danger,
  .row .site-btn {
    width: 100% !important;
  }
  .actions .action-btn,
  .site-btn,
  .btn-inline {
    width: 100% !important;
  }
  th,
  td {
    padding: 6px;
    font-size: 12px;
  }
}

.st-badge {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}
.st-ok { background: #e6f6ec; color: #1b6e37; border-color: #9ad2ad; }
.st-down { background: #fde8e8; color: #9f1f1f; border-color: #e6a0a0; }
