:root {
  --bg: #eef1f8;
  --bg2: #e3e9f5;
  --panel: #ffffff;
  --panel2: #f7f9fc;
  --line: #dbe3f0;
  --cyan: #0891b2;
  --blue: #2f6fed;
  --green: #16a34a;
  --orange: #d97706;
  --red: #dc2626;
  --purple: #9333ea;
  --text: #152238;
  --muted: #59677e;
  --soft: rgba(47, 111, 237, 0.08);
  --sidebar-bg: rgba(6, 15, 30, 0.97);
  --sidebar-text: #f4f8ff;
  --sidebar-muted: #a8bedb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(47, 111, 237, 0.06), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg2));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--text);
  background: #0b4dd8;
  cursor: pointer;
  font-weight: 700;
}

/* Action links (e.g. document downloads) use <a class="..."> instead of
   <button> since they need a real href for the browser's native download
   behaviour - these mirror every button rule so they look and behave
   identically rather than falling back to a plain, unstyled hyperlink. */
a.mini, a.green, a.orange, a.danger, a.outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--text);
  background: #0b4dd8;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

a.mini:hover, a.green:hover, a.orange:hover, a.danger:hover, a.outline:hover {
  filter: brightness(1.12);
}

button:hover {
  filter: brightness(1.12);
}

button.outline, a.outline {
  background: transparent;
}

button.green, a.green {
  border-color: #18d56a;
  background: #12843d;
}

button.orange, a.orange {
  border-color: #ff8a22;
  background: #c94307;
}

button.danger, a.danger {
  border-color: #ff355d;
  background: #8e1730;
}

button.mini, a.mini {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  padding: 0 14px;
  outline: none;
}

textarea {
  min-height: 96px;
  padding-top: 12px;
  resize: vertical;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 276px;
  padding: 26px 18px;
  border-right: 1px solid rgba(47, 128, 255, 0.45);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  --text: var(--sidebar-text);
  --muted: var(--sidebar-muted);
}

.brand img {
  width: 220px;
  height: auto;
  display: block;
  margin-bottom: 36px;
}

.brand {
  flex-shrink: 0;
}

.module-nav {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.nav-btn.active {
  border-color: var(--blue);
  background: rgba(47, 128, 255, 0.24);
}

.nav-status {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  margin-top: 3px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.main {
  margin-left: 276px;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 560px) auto;
  gap: 18px;
  align-items: center;
  min-height: 86px;
  padding: 16px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

.title-block p,
.muted,
.small {
  color: var(--muted);
}

.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.content {
  padding: 28px 34px 42px;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 4px 20px rgba(15, 30, 60, 0.06);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 118px;
  padding: 18px;
  position: relative;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent, var(--blue));
  opacity: 0.55;
}

.metric-title {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
}

.metric-value {
  font-size: 30px;
  font-weight: 900;
  margin-bottom: 10px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 17px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

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

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

th {
  color: #334155;
  background: var(--panel2);
  font-weight: 900;
}

td {
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(47, 128, 255, 0.28);
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  background: rgba(34, 211, 107, 0.25);
}

.badge.orange {
  background: rgba(255, 122, 24, 0.25);
}

.badge.red {
  background: rgba(255, 53, 93, 0.25);
}

.badge.purple {
  background: rgba(168, 85, 247, 0.25);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(220px, 2fr);
  gap: 10px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 460px;
  padding: 14px 16px;
  border: 1px solid var(--cyan);
  border-radius: 8px;
  background: #142238;
  color: var(--sidebar-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

@media (max-width: 1100px) {
  .sidebar {
    width: 224px;
  }

  .main {
    margin-left: 224px;
  }

  .brand img {
    width: 180px;
  }

  .topbar,
  .metrics,
  .two,
  .three {
    grid-template-columns: 1fr;
  }
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #0d1c33, var(--sidebar-bg));
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: 380px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 30px 80px rgba(15, 30, 60, 0.18);
}

.auth-card img {
  width: 200px;
  display: block;
  margin: 0 auto 20px;
  padding: 16px 20px;
  background: var(--sidebar-bg);
  border-radius: 10px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.auth-card p.muted {
  margin: 0 0 22px;
}

.auth-card label {
  display: block;
  font-size: 12px;
  margin: 14px 0 6px;
}

.auth-card input {
  width: 100%;
  box-sizing: border-box;
}

.auth-card button {
  width: 100%;
  margin-top: 20px;
}

.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.4);
  font-size: 13px;
  display: none;
}

.auth-error.visible {
  display: block;
}

.role-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(37, 198, 255, 0.15);
  border: 1px solid rgba(37, 198, 255, 0.4);
  font-size: 11px;
  margin-top: 6px;
}

details summary {
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  transition: transform 0.15s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 8, 18, 0.72);
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(15, 30, 60, 0.25);
}

.modal-dialog h2 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
