:root {
  --bg: #f5f7fb;
  --bg-strong: #eef2f8;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --ink: #111827;
  --ink-muted: #6b7280;
  --accent: #1f4fd6;
  --accent-soft: #e3ebff;
  --good: #0a7f54;
  --warn: #b86800;
  --bad: #b5213a;
  --ring: rgba(31, 79, 214, 0.22);
  --border: rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 8px 18px rgba(15, 23, 42, 0.06);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg), var(--bg-strong));
}

body {
  position: relative;
  overflow-x: hidden;
}

.background-orb {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.2;
  pointer-events: none;
}

.orb-a {
  width: 28rem;
  height: 28rem;
  background: radial-gradient(circle at 30% 30%, #c7d6ff 0%, transparent 70%);
  top: -10rem;
  left: -8rem;
}

.orb-b {
  width: 34rem;
  height: 34rem;
  background: radial-gradient(circle at 30% 30%, #ffe2c5 0%, transparent 70%);
  bottom: -16rem;
  right: -12rem;
}

#app {
  position: relative;
  z-index: 1;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.2rem;
  padding: 1.2rem;
}

.sidebar {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.logo-row img {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.8rem;
  object-fit: cover;
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.brand-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.nav-stack {
  display: grid;
  gap: 0.5rem;
}

.nav-button,
.mobile-nav-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 0.7rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
}

.nav-button:hover,
.mobile-nav-button:hover {
  background: rgba(31, 79, 214, 0.08);
}

.nav-button.active,
.mobile-nav-button.active {
  background: rgba(31, 79, 214, 0.12);
  color: #1f4fd6;
  border-color: rgba(31, 79, 214, 0.25);
}

.nav-group {
  display: grid;
  gap: 0.35rem;
}

.nav-group-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 0.7rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-group-toggle:hover {
  background: rgba(31, 79, 214, 0.08);
}

.nav-group.open .nav-group-toggle {
  background: rgba(31, 79, 214, 0.12);
  border-color: rgba(31, 79, 214, 0.25);
  color: #1f4fd6;
}

.nav-caret {
  font-size: 0.85rem;
  opacity: 0.6;
}

.nav-group-items {
  display: grid;
  gap: 0.3rem;
  padding-left: 0.3rem;
}

.nav-group:not(.open) .nav-group-items {
  display: none;
}

.nav-subtab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 0.6rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.nav-subtab:hover {
  background: rgba(31, 79, 214, 0.08);
}

.nav-subtab.active {
  background: rgba(31, 79, 214, 0.12);
  border-color: rgba(31, 79, 214, 0.25);
  color: #1f4fd6;
}

.sidebar-foot {
  margin-top: auto;
  background: #f6f8ff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.main-area {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.2vw + 0.8rem, 1.75rem);
  font-weight: 600;
}

.topbar p {
  margin: 0.18rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  border: 1px solid var(--border);
  background: #f7f8fc;
  color: #1f2937;
}

.chip-ok {
  color: var(--good);
  border-color: rgba(10, 127, 84, 0.2);
  background: rgba(10, 127, 84, 0.1);
}

.chip-warn {
  color: var(--warn);
  border-color: rgba(184, 104, 0, 0.2);
  background: rgba(184, 104, 0, 0.12);
}

.chip-bad {
  color: var(--bad);
  border-color: rgba(181, 33, 58, 0.2);
  background: rgba(181, 33, 58, 0.12);
}

.content {
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.tab-button:hover {
  background: rgba(31, 79, 214, 0.08);
}

.tab-button.active {
  background: rgba(31, 79, 214, 0.12);
  border-color: rgba(31, 79, 214, 0.25);
  color: #1f4fd6;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.table-toolbar .input {
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}

.detail-card {
  margin-top: 1rem;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.detail-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.detail-grid {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.detail-item p {
  margin: 0;
}

.detail-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.detail-value {
  margin-top: 0.3rem;
  font-weight: 500;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-block {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.detail-body {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  white-space: pre-wrap;
  color: var(--ink);
}

.detail-hint {
  margin: 0.9rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

.card h2,
.card h3,
.card h4 {
  margin: 0;
}

.stat-value {
  margin-top: 0.4rem;
  font-size: 1.7rem;
  font-weight: 800;
}

.stat-label {
  margin-top: 0.25rem;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.8rem;
}

.input,
.textarea,
.select,
button.primary,
button.secondary,
button.ghost {
  font: inherit;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  border-radius: 0.75rem;
  padding: 0.65rem 0.78rem;
  transition: box-shadow 120ms ease, border-color 120ms ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: rgba(31, 79, 214, 0.45);
  box-shadow: 0 0 0 4px var(--ring);
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button.primary,
button.secondary,
button.ghost {
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.6rem 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 110ms ease;
}

button.primary {
  color: #fff;
  background: #1f4fd6;
}

button.primary:hover {
  background: #1b46c1;
}

button.secondary {
  background: #eef3ff;
  color: #1f4fd6;
  border-color: #dbe5ff;
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

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

.table-wrap {
  overflow: auto;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
  background: #fff;
}

thead th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  padding: 0.66rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

tbody td {
  padding: 0.7rem;
  border-bottom: 1px solid #eef2fb;
  font-size: 0.92rem;
}

tbody tr[data-action="open-detail"] {
  cursor: pointer;
}

tbody tr[data-action="open-detail"]:hover {
  background: rgba(31, 79, 214, 0.05);
}

tbody tr.is-selected {
  background: rgba(31, 79, 214, 0.1);
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

.error-banner {
  padding: 0.7rem 0.9rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(181, 33, 58, 0.3);
  background: rgba(181, 33, 58, 0.11);
  color: #7e1728;
}

.success-banner {
  padding: 0.7rem 0.9rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(10, 127, 84, 0.3);
  background: rgba(10, 127, 84, 0.11);
  color: #0d6244;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(100%, 900px);
  background: var(--surface);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.login-panel {
  padding: 1.4rem;
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  font-weight: 600;
}

.login-panel p {
  margin: 0.7rem 0 0;
  color: var(--ink-muted);
}

.info-panel {
  background: linear-gradient(165deg, #1740a4 0%, #1b50cc 58%, #0f2f80 100%);
  color: #f6f9ff;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.info-note {
  padding: 0.8rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
  margin-top: 1rem;
}

.status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.loading-state {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.loading-card {
  width: min(96vw, 520px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  padding: 1.3rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 4px solid #c9d6f6;
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mobile-nav {
  display: none;
}

.fade-in {
  animation: fadeIn 280ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 0.7rem 0.7rem 5rem;
    gap: 0.7rem;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: grid;
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.75rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border-radius: 1rem;
    padding: 0.3rem;
    box-shadow: var(--shadow-soft);
    z-index: 9;
  }

  .mobile-nav-button {
    font-size: 0.72rem;
    text-align: center;
    padding: 0.45rem 0.25rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.7rem;
  }

  .profile-row {
    width: 100%;
    justify-content: space-between;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .info-panel {
    order: -1;
  }
}
