@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --color-surface: #051424;
  --color-surface-dim: #051424;
  --color-surface-bright: #2c3a4c;
  --color-surface-container-lowest: #010f1f;
  --color-surface-container-low: #0d1c2d;
  --color-surface-container: #122131;
  --color-surface-container-high: #1c2b3c;
  --color-surface-container-highest: #273647;
  --color-on-surface: #d4e4fa;
  --color-on-surface-variant: #c2c6d8;
  --color-inverse-surface: #d4e4fa;
  --color-inverse-on-surface: #233143;
  --color-outline: #8c90a1;
  --color-outline-variant: #424656;
  --color-primary: #b3c5ff;
  --color-on-primary: #002b75;
  --color-primary-container: #0066ff;
  --color-on-primary-container: #f8f7ff;
  --color-inverse-primary: #0054d6;
  --color-secondary: #7bd0ff;
  --color-on-secondary: #00354a;
  --color-secondary-container: #00a6e0;
  --color-on-secondary-container: #00374d;
  --color-tertiary: #ffb59d;
  --color-on-tertiary: #5d1900;
  --color-error: #ffb4ab;
  --color-on-error: #690005;
  --color-error-container: #93000a;
  --color-on-error-container: #ffdad6;
  --color-background: #051424;
  --color-on-background: #d4e4fa;
  --color-surface-variant: #273647;

  --font-display: 800 2.75rem/1.1 'Inter', sans-serif;
  --font-headline-lg: 700 2rem/1.2 'Inter', sans-serif;
  --font-headline-md: 600 1.5rem/1.3 'Inter', sans-serif;
  --font-body-lg: 400 1.125rem/1.6 'Inter', sans-serif;
  --font-body-md: 400 1rem/1.5 'Inter', sans-serif;
  --font-body-sm: 400 0.875rem/1.5 'Inter', sans-serif;
  --font-label: 500 0.75rem/1.3 'Inter', sans-serif;
  --font-button: 600 0.875rem/1 'Inter', sans-serif;
  --font-caption: 400 0.75rem/1.4 'Inter', sans-serif;

  --radius-sm: 0.25rem;
  --radius-default: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 2.5rem;
  --space-6: 3rem;
  --space-8: 4rem;

  --nav-height: 64px;
  --header-height: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-on-surface);
  background: var(--color-background);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--color-primary-container);
  color: var(--color-on-primary-container);
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-outline-variant);
  border-radius: var(--radius-full);
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.4);
}

@media (min-width: 481px) {
  body {
    background: var(--color-surface-container-lowest);
  }
  .app-shell {
    border-radius: var(--radius-xl);
    margin: var(--space-4) auto;
    height: calc(100% - var(--space-8));
    max-height: 900px;
    border: 1px solid var(--color-outline-variant);
  }
}

@media (min-width: 1024px) {
  .app-shell {
    margin: var(--space-6) auto;
    height: calc(100% - var(--space-12, 6rem));
  }
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-3);
  padding-top: var(--safe-top);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-surface-container-high);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-primary-container), transparent);
  opacity: 0.3;
}

.app-header__title {
  font: var(--font-button);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--color-on-surface), var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header__badge {
  font: var(--font-caption);
  color: var(--color-on-surface-variant);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-surface-container-high);
  border: 1px solid var(--color-outline-variant);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-3);
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-3));
  scroll-behavior: smooth;
}

.app-content::-webkit-scrollbar {
  width: 3px;
}

.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(5, 20, 36, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-surface-container-high);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.bottom-nav::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-primary-container), transparent);
  opacity: 0.15;
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 12px;
  border: none;
  background: none;
  color: var(--color-on-surface-variant);
  font: var(--font-caption);
  cursor: pointer;
  transition: color 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  min-width: 44px;
}

.bottom-nav__item:hover {
  color: var(--color-on-surface);
}

.bottom-nav__item.active {
  color: var(--color-primary);
}

.bottom-nav__item.active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--color-primary-container);
  border-radius: 0 0 3px 3px;
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.bottom-nav__item.active .bottom-nav__icon svg {
  transform: scale(1.1);
}

.bottom-nav__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font: var(--font-button);
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: var(--radius-default);
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary-container);
  color: var(--color-on-primary-container);
  border-color: var(--color-primary-container);
}

.btn-primary:hover {
  background: #0052e0;
  border-color: #0052e0;
  box-shadow: 0 0 24px rgba(0, 102, 255, 0.3);
}

.btn-primary:active {
  background: #0047c4;
  box-shadow: 0 0 12px rgba(0, 102, 255, 0.2);
}

.btn-secondary {
  background: transparent;
  color: var(--color-on-surface);
  border-color: var(--color-outline-variant);
}

.btn-secondary:hover {
  background: var(--color-surface-container-high);
  border-color: var(--color-outline);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: rgba(179, 197, 255, 0.08);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group__label {
  font: var(--font-label);
  color: var(--color-on-surface-variant);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper__icon {
  position: absolute;
  left: 14px;
  color: var(--color-on-surface-variant);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.input-wrapper__icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.input-field {
  width: 100%;
  font: var(--font-body-md);
  color: var(--color-on-surface);
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-default);
  padding: 14px 16px;
  padding-left: 44px;
  transition: all 0.25s ease;
  outline: none;
  min-height: 48px;
}

.input-field::placeholder {
  color: var(--color-on-surface-variant);
  opacity: 0.5;
}

.input-field:focus {
  border-color: var(--color-primary-container);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15), 0 0 20px rgba(0, 102, 255, 0.05);
  background: var(--color-surface-container);
}

.card {
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  transition: all 0.2s ease;
}

.card-highlight {
  background: linear-gradient(135deg, var(--color-surface-container-low), var(--color-surface-container));
  border-color: var(--color-surface-container-highest);
}

.card-glass {
  background: rgba(18, 33, 49, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(66, 70, 86, 0.3);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--space-3));
  padding: 0 var(--space-3);
}

table {
  width: 100%;
  border-collapse: collapse;
  font: var(--font-body-sm);
}

th {
  text-align: left;
  font: var(--font-label);
  color: var(--color-on-surface-variant);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-surface-container-high);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--color-surface-container-high);
  color: var(--color-on-surface);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--color-surface-container);
}

.tag {
  display: inline-flex;
  align-items: center;
  font: var(--font-caption);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(0, 102, 255, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(179, 197, 255, 0.15);
}

.tag-error {
  background: rgba(255, 180, 171, 0.1);
  color: var(--color-error);
  border-color: rgba(255, 180, 171, 0.15);
}

.tag-aa {
  background: rgba(255, 200, 50, 0.12);
  color: #ffd54f;
  border-color: rgba(255, 200, 50, 0.25);
}

.tag-a {
  background: rgba(76, 217, 100, 0.1);
  color: #69db7c;
  border-color: rgba(76, 217, 100, 0.2);
}

.tag-d {
  background: rgba(150, 150, 150, 0.1);
  color: #a0a0a0;
  border-color: rgba(150, 150, 150, 0.2);
}

.tag-cm {
  background: rgba(255, 159, 10, 0.12);
  color: #ff9f0a;
  border-color: rgba(255, 159, 10, 0.25);
}

.tag-ca {
  background: rgba(255, 69, 58, 0.1);
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.2);
}

.tag-fa {
  background: rgba(255, 50, 50, 0.15);
  color: #ff4444;
  border-color: rgba(255, 50, 50, 0.3);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-8) var(--space-3);
  gap: var(--space-2);
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-surface-container-high);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-on-surface-variant);
  margin-bottom: var(--space-1);
}

.empty-state__title {
  font: var(--font-headline-md);
  color: var(--color-on-surface);
}

.empty-state__text {
  font: var(--font-body-md);
  color: var(--color-on-surface-variant);
  max-width: 280px;
}

.loading-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--space-6) 0;
}

.loading-dots__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary-container);
  animation: dotPulse 1.4s ease-in-out infinite both;
}

.loading-dots__dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dots__dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dots__dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease forwards;
}

.animate-slide-up {
  animation: slideUp 0.5s ease forwards;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

.result-link {
  color: var(--color-primary);
  font: var(--font-body-sm);
  word-break: break-all;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-surface-container);
  border-radius: var(--radius-default);
  border: 1px solid var(--color-outline-variant);
  transition: all 0.2s ease;
}

.result-link:hover {
  background: var(--color-surface-container-high);
  border-color: var(--color-primary-container);
  text-decoration: none;
}

.divider {
  height: 1px;
  background: var(--color-surface-container-high);
  margin: var(--space-3) 0;
}

.text-muted {
  color: var(--color-on-surface-variant);
}

.text-sm {
  font: var(--font-body-sm);
}

.text-xs {
  font: var(--font-caption);
}

.text-error {
  color: var(--color-error);
}

.glow-primary {
  box-shadow: 0 0 30px rgba(0, 102, 255, 0.15);
}

.gradient-text {
  background: linear-gradient(135deg, var(--color-on-surface), var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.w-full { width: 100%; }
