:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-alt: #1f2937;
  --border: #2f3a4c;
  --text: #e6edf3;
  --muted: #9aa7b2;
  --accent: #4f8cff;
  --success: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-weight: 600;
  z-index: 100;
}

.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 240px;
  min-width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar nav {
  display: grid;
  gap: 0.5rem;
}

.sidebar a {
  text-decoration: none;
  color: var(--text);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

.sidebar a:hover,
.sidebar a.active {
  border-color: var(--accent);
}

.view {
  margin-top: 56px;
  margin-left: 240px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 1rem;
}

.panel,
.card,
.table-wrap,
.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

input,
select,
textarea,
button {
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}

button {
  cursor: pointer;
  background: var(--accent);
  border: none;
}

button.secondary {
  background: #334155;
}

button.danger {
  background: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.9rem;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.chip.status-active {
  border-color: var(--success);
  color: var(--success);
}

.chip.status-revoked,
.chip.status-archived {
  border-color: var(--danger);
  color: var(--danger);
}

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

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem;
  font-size: 0.92rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

.modal.open {
  display: flex;
}

.modal-content {
  width: min(700px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

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

.feed {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.msg {
  background: var(--panel-alt);
  border-radius: 8px;
  padding: 0.6rem;
  border: 1px solid var(--border);
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    min-width: 0;
    margin-top: 56px;
  }

  .view {
    margin: 0;
    height: auto;
    padding-top: 1rem;
  }
}

.preview-area {
  margin-top: 0.75rem;
  min-height: 120px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

.preview-frame {
  width: 100%;
  min-height: 65vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b1020;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chip-secure {
  border-color: var(--success);
  color: var(--success);
}

.chip-metadata {
  border-color: var(--warn);
  color: var(--warn);
}

.text-success {
  color: var(--success);
}

.text-warn {
  color: var(--warn);
}

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

td button + button {
  margin-left: 0.5rem;
}
