:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f100e;
  color: #f2efe7;
  --bg: #0f100e;
  --panel: #191914;
  --panel-2: #222119;
  --line: #3c3829;
  --line-strong: #6d6240;
  --text: #f2efe7;
  --muted: #aaa28f;
  --gold: #d8bb72;
  --gold-strong: #f0cf7b;
  --green: #7fd1a2;
  --red: #ff8d8d;
  --ink: #11110d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(216, 187, 114, 0.08), transparent 320px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 18px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(15, 16, 14, 0.92);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--gold-strong);
  background: #15140f;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-strip,
.button-row,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-strip {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.shell {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 18px;
  width: min(1440px, calc(100vw - 36px));
  margin: 24px auto 48px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 25, 20, 0.96);
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 58px;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.access-panel,
.nfr-panel {
  grid-column: 1;
}

.search-panel,
.detail-panel {
  grid-column: 2;
}

.detail-panel {
  min-height: 520px;
}

.field {
  display: grid;
  gap: 7px;
  padding: 0 18px 16px;
}

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

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: #11110e;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 187, 114, 0.14);
}

.button-row {
  padding: 0 18px 18px;
  flex-wrap: wrap;
}

.button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 15px;
  color: var(--text);
  background: #181710;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: var(--gold);
}

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

.button.primary {
  border-color: var(--gold);
  color: var(--ink);
  background: var(--gold);
  font-weight: 800;
}

.button.secondary {
  color: var(--gold-strong);
}

.button.ghost {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.button.danger {
  border-color: rgba(255, 141, 141, 0.58);
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--gold-strong);
  background: #11110e;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  color: var(--green);
}

.badge.bad {
  color: var(--red);
}

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

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

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

.search-grid {
  grid-template-columns: minmax(0, 1fr) 180px 120px;
  align-items: end;
  padding-right: 18px;
}

.search-grid .field {
  padding-right: 10px;
}

.search-button {
  margin-bottom: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 210px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment {
  border: 0;
  color: var(--muted);
  background: #11110e;
  cursor: pointer;
}

.segment.active {
  color: var(--ink);
  background: var(--gold);
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

tr:hover td {
  background: rgba(216, 187, 114, 0.05);
}

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

.detail-body {
  display: grid;
  gap: 18px;
  padding-bottom: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.metric {
  min-height: 82px;
  padding: 14px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.section-title {
  padding: 0 18px;
  color: var(--gold-strong);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.action-bar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 18px;
}

.action-bar .field {
  width: 160px;
  padding: 0;
}

.result-box {
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #11110e;
}

.result-box code,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.result-box code {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--gold-strong);
  font-size: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(460px, calc(100vw - 40px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--text);
  background: #16150f;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

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

  .access-panel,
  .nfr-panel,
  .search-panel,
  .detail-panel {
    grid-column: 1;
  }
}

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

  .status-strip {
    justify-content: flex-start;
  }

  .form-grid,
  .search-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .search-grid {
    padding-right: 0;
  }

  .search-grid .field {
    padding-right: 18px;
  }

  .search-button {
    margin: 0 18px 18px;
  }

  .segmented {
    width: 100%;
  }
}
