:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --line: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --danger: #f87171;
  --success: #4ade80;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: #020617;
  color: var(--text);
}
button, input, select, textarea {
  font: inherit;
}
button {
  border: 0;
  background: var(--accent);
  color: #082f49;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
button.secondary {
  background: #334155;
  color: var(--text);
}
input, select, textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f172a;
  color: var(--text);
}
label {
  display: block;
  margin: 0.25rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.hidden { display: none !important; }
.centered-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-panel {
  width: min(440px, 100%);
}
.panel {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
.compact-panel { padding: 1rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.9);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1, .section-header h2, .panel h3, .panel h4 { margin: 0; }
.muted { color: var(--muted); }
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 88px);
}
.sidebar {
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #020617;
}
.nav-btn {
  background: #0f172a;
  color: var(--text);
  text-align: left;
}
.nav-btn.active { outline: 2px solid var(--accent); }
.content { padding: 1.5rem; }
.section { display: none; }
.section.active { display: block; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.minor-header { margin-bottom: 0.75rem; }
.filter-grid, .grid-2, .form-grid {
  display: grid;
  gap: 1rem;
}
.filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.filter-grid.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full-span { grid-column: 1 / -1; }
.table-panel { overflow: hidden; }
.table-wrap { overflow: auto; }
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  padding: 0.9rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #0f172a;
}
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.list-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.list-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  background: #020617;
}
.selected-item {
  outline: 1px solid var(--accent);
}
.list-item-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}
.inline-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.inline-actions button {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.8rem;
  background: #0f172a;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.error { color: var(--danger); min-height: 1.2rem; }
.success { color: var(--success); min-height: 1.2rem; }
.checkbox-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.checkbox-row input { width: auto; }
.checkbox-wrap { padding-top: 0.5rem; }
.max-520 { max-width: 520px; }
.actions-cell { white-space: nowrap; }
.actions-cell button { margin-right: 0.5rem; padding: 0.45rem 0.7rem; }
.top-gap { margin-top: 1rem; }
.info-banner, .hint-box {
  border: 1px dashed var(--line);
  background: rgba(15, 23, 42, 0.7);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  color: var(--muted);
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.profile-subpanel {
  padding: 1rem;
  background: rgba(2, 6, 23, 0.7);
}
.profile-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
}
.profile-row:last-child { border-bottom: 0; }
.profile-label {
  color: var(--muted);
  font-weight: 600;
}
.profile-value {
  word-break: break-word;
}
.profile-notes {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
}
.templates-layout { align-items: start; }
@media (max-width: 1080px) {
  .filter-grid.three-up,
  .grid-2,
  .form-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .filter-grid { grid-template-columns: 1fr; }
  .profile-row { grid-template-columns: 1fr; gap: 0.4rem; }
}
