:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #4d9fff;
  --accent-dim: #2a5f9e;
  --danger: #f07178;
  --ok: #7fd962;
  --radius: 10px;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.topbar .muted {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 88px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 1rem;
  background: #121922;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1rem;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-list li {
  margin-bottom: 0.35rem;
}

.project-list button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.project-list button:hover {
  background: var(--surface);
}

.project-list button.active {
  border-color: var(--accent-dim);
  background: var(--surface);
  color: var(--accent);
}

.main {
  padding: 1.25rem 1.5rem 2rem;
  overflow-x: auto;
}

.empty-state {
  color: var(--muted);
  padding: 3rem 1rem;
  text-align: center;
}

.panel.hidden,
.empty-state.hidden,
.tab-panel.hidden {
  display: none !important;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.hint code {
  font-family: var(--mono);
  font-size: 0.8em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.row.spread {
  justify-content: space-between;
}

.btn {
  font: inherit;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
}

textarea,
input[type="text"],
input[type="number"],
select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  width: 100%;
  max-width: 100%;
}

textarea.mono,
input.mono {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.checkbox-row {
  grid-column: 1 / -1;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tab {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--surface);
}

.tab-panel {
  margin-top: 0.5rem;
}

.meta-block {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  max-width: min(420px, 90vw);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.toast.error {
  border-color: var(--danger);
  color: #ffc8cb;
}

.toast.hidden {
  display: none;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--surface);
  color: var(--text);
  min-width: min(360px, 90vw);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog h3 {
  margin: 0 0 1rem;
}

.dialog label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.report-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.report-h1 {
  margin: 0;
  font-size: 1.2rem;
}

.report-sub {
  margin: 0.35rem 0 0;
}

.report-main {
  max-width: 1400px;
  margin: 0 auto;
}

.report-error {
  color: var(--danger);
  margin: 0 0 1rem;
}

.report-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.report-host-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.report-host-label {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
