:root {
  --dh-bg: #0b2f3a;
  --dh-surface: #0f3e4d;
  --dh-primary: #2cb6d8;
  --dh-primary-600: #1ea0c0;
  --dh-accent: #f0a22e;
  --dh-muted: #6ea4cc;
  --dh-text: #e6f2f7;
  --dh-ink: #0e1a1f;
  --dh-border: color-mix(in oklch, var(--dh-text) 16%, transparent);
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

html,
body {
  height: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  font:
    14px/1.45 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Inter,
    "Noto Sans",
    Arial,
    sans-serif;
  color: var(--dh-text);
  background:
    radial-gradient(1200px 800px at 15% -10%, #11495b 0%, transparent 60%),
    radial-gradient(1000px 600px at 120% 20%, #123746 0%, transparent 60%),
    var(--dh-bg);
}

.app {
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  box-sizing: border-box;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--dh-border);
  background: linear-gradient(
    180deg,
    color-mix(in oklch, #112e38 85%, transparent),
    #0e2a33
  );
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.logo {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--dh-primary);
  box-shadow: inset 0 0 0 2px #fff2;
}

.logo::after {
  content: "";
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 3px;
  opacity: 0.9;
}

h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.3px;
  font-weight: 650;
}

.btn {
  border: 1px solid var(--dh-border);
  background: #0f3340;
  color: var(--dh-text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.pwa-install {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10000;
  display: none;
  width: min(760px, calc(100% - 24px));
  box-sizing: border-box;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--dh-border);
  border-radius: 14px;
  background: linear-gradient(
    180deg,
    color-mix(in oklch, #112e38 86%, transparent),
    #0e2a33
  );
  box-shadow: var(--shadow);
}

.pwa-install.is-visible {
  display: flex;
}

.pwa-install-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.pwa-install-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.pwa-install-text {
  display: block;
  font-size: 12px;
  color: #cfe7f2;
  opacity: 0.9;
  line-height: 1.4;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .pwa-install {
    align-items: stretch;
    gap: 10px;
  }

  .pwa-install-actions {
    justify-content: flex-end;
  }
}

select {
  background: #0f3340;
  color: var(--dh-text);
  border: 1px solid var(--dh-border);
  border-radius: 10px;
  padding: 8px;
}

/* Nav */
.app-body {
  display: contents;
}

.nav {
  display: none;
}

.app.has-nav {
  max-width: 1200px;
}

.app.has-nav .app-body {
  flex: 1;
}

.app.has-nav .nav {
  display: flex;
  gap: 4px;
  padding: 10px;
  margin: 10px 0 0 0;
  border: 1px solid var(--dh-border);
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    color-mix(in oklch, #112e38 85%, transparent),
    #0e2a33
  );
  box-shadow: var(--shadow);
  height: fit-content;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--dh-text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s ease;
}

.nav-link:hover {
  background: color-mix(in oklch, var(--dh-primary) 12%, transparent);
}

.nav-link.active {
  background: color-mix(in oklch, var(--dh-primary) 20%, transparent);
  color: var(--dh-primary);
  font-weight: 600;
}

/* Page transition */
body {
  animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.fade-out {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Page loader */
.app {
  visibility: hidden;
}

.page-loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dh-bg);
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--dh-border);
  border-top-color: var(--dh-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.upload-btn.btn-loading {
  pointer-events: none;
}

.upload-btn.btn-loading::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid rgba(6, 34, 42, 0.35);
  border-top-color: #06222a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.data-table {
  transition: opacity 0.2s ease;
}

.data-table.is-loading {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 720px) {
  .app.has-nav .app-body {
    grid-template-columns: 1fr;
  }

  .app.has-nav .nav {
    flex-direction: row;
  }
}
