:root {
  --ink: #07131c;
  --ink-2: #0d2130;
  --panel: rgba(12, 32, 46, 0.82);
  --sidebar: rgba(8, 24, 36, 0.95);
  --line: rgba(140, 210, 200, 0.18);
  --text: #e7f3f1;
  --muted: #8aa8a6;
  --accent: #3ddeb5;
  --accent-2: #f0b429;
  --danger: #ff6b6b;
  --warn: #f0b429;
  --radius: 14px;
  --font-brand: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  line-height: 1.45;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(61, 222, 181, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 222, 181, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  pointer-events: none;
  animation: gridDrift 28s linear infinite;
}
.bg-glow {
  position: fixed;
  inset: -20% auto auto 40%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(61, 222, 181, 0.18), transparent 60%);
  filter: blur(20px);
  pointer-events: none;
  animation: glowPulse 8s ease-in-out infinite;
}

@keyframes gridDrift {
  from { transform: translateY(0); }
  to { transform: translateY(48px); }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.08); }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.boot-error {
  display: block;
  max-width: 420px;
  margin: 1rem auto;
  text-align: center;
  position: relative;
  z-index: 2;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand .brand-mark {
  font-size: 1.65rem;
  margin: 0;
}

.sidebar-brand .brand-sub {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
}

.context-box {
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.field-compact span { font-size: 0.72rem; }
.field-compact select {
  border: 1px solid var(--line);
  background: rgba(7, 19, 28, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  width: 100%;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.side-link {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.side-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.side-link.is-active {
  background: rgba(61, 222, 181, 0.15);
  color: var(--accent);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.page-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.pad { padding: 1rem; }

.block-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-brand);
  font-size: 1rem;
}

.tiny { font-size: 0.82rem; margin-top: 0.5rem; }

.stat-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-value-sm { font-size: 1.1rem; }

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-ACCEPTED, .status-OBSERVED { background: rgba(61,222,181,0.2); color: var(--accent); }
.status-REJECTED, .status-ERROR { background: rgba(255,107,107,0.18); color: var(--danger); }
.status-REGISTERED, .status-DRAFT { background: rgba(138,168,166,0.15); color: var(--muted); }
.status-PENDING_SUBMISSION, .status-SENT { background: rgba(240,180,41,0.15); color: var(--warn); }

.toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.field-inline span { white-space: nowrap; }
.field-inline select {
  border: 1px solid var(--line);
  background: rgba(7, 19, 28, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  font: inherit;
}

.table-wrap.compact table { font-size: 0.82rem; }
.table-wrap.compact th, .table-wrap.compact td { padding: 0.5rem 0.6rem; }

.modal-wide { max-width: min(720px, calc(100vw - 2rem)); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.detail-item label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-item p { margin: 0.2rem 0 0; font-size: 0.9rem; }

.link-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.full { grid-column: 1 / -1; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.75rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  animation: riseIn 0.6s ease both;
}
.brand-mark {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.brand-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.top-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.link-quiet {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.link-quiet:hover { text-decoration: underline; }

.shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  padding-top: 1rem;
  animation: riseIn 0.7s ease 0.08s both;
}

.auth-panel,
.tab-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(10px);
  margin-bottom: 1rem;
}

.section-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.section-copy {
  margin: 0.4rem 0 1rem;
  color: var(--muted);
  max-width: 48rem;
}

.auth-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.field.full { grid-column: 1 / -1; }
.field input,
.field select {
  border: 1px solid var(--line);
  background: rgba(7, 19, 28, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
.field input:focus,
.field select:focus {
  outline: 2px solid rgba(61, 222, 181, 0.45);
  border-color: transparent;
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(120deg, var(--accent), #2bb896);
  color: #042018;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-tiny {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.hint { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }

.tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.tab {
  background: rgba(12, 32, 46, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active {
  color: var(--ink);
  background: var(--accent);
  border-color: transparent;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: riseIn 0.35s ease; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: rgba(7, 19, 28, 0.55);
}
.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  margin: 0.35rem 0 0;
  font-family: var(--font-brand);
  font-size: 1.6rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th, td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody tr:hover { background: rgba(61, 222, 181, 0.05); }
code {
  font-size: 0.78rem;
  color: var(--accent-2);
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
}
.pill-ok { background: rgba(61, 222, 181, 0.2); color: var(--accent); }
.pill-bad { background: rgba(255, 107, 107, 0.18); color: var(--danger); }
.pill-muted { background: rgba(138, 168, 166, 0.15); color: var(--muted); }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #123447;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  max-width: min(420px, calc(100vw - 2rem));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: riseIn 0.25s ease;
  z-index: 20;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
  animation: riseIn 0.55s ease both;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}
.login-card .brand-mark {
  font-size: 2.4rem;
}
.btn-block { width: 100%; margin-top: 0.85rem; }
.hint-error { color: var(--danger); }

.login-card .field { margin-bottom: 0.75rem; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
}

.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
}
.wizard-step {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.wizard-step.is-active {
  color: var(--ink);
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.wizard-step.is-done {
  color: var(--accent);
  border-color: rgba(61, 222, 181, 0.35);
}
.wizard-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-brand);
  font-size: 1.15rem;
}
.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.panel-soft {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.checklist {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
}
.check-item.is-ok {
  color: var(--text);
  border-color: rgba(61, 222, 181, 0.35);
}
.check-icon {
  width: 1.25rem;
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}
.code-block {
  display: block;
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  word-break: break-all;
}
.cred-box {
  padding: 1rem;
  border: 1px solid rgba(61, 222, 181, 0.25);
  border-radius: var(--radius);
  background: rgba(7, 19, 28, 0.65);
}
.cred-key {
  color: var(--accent-2);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}
.modal-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
  color: var(--text);
  padding: 0;
  max-width: min(520px, calc(100vw - 2rem));
}
.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  padding: 1.25rem;
  margin: 0;
}
.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .sidebar-foot { flex-direction: row; width: 100%; }
}

@media (max-width: 760px) {
  .auth-grid, .form-grid, .stat-row, .stat-row-4, .grid-2, .detail-grid { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}
