:root {
  color-scheme: light;
  --app-bg: #f1f4f8;
  --app-bg-soft: #f8fafc;
  --app-panel: #ffffff;
  --app-panel-soft: #fafafc;
  --app-text: #1d1d1f;
  --app-muted: #6e6e73;
  --app-border: #d0d8e2;
  --app-border-soft: #e3e8ee;
  --app-brand: #0071e3;
  --app-brand-strong: #0066cc;
  --app-brand-soft: #e8f2ff;
  --app-danger: #d70015;
  --app-warning: #b46900;
  --app-success: #167b43;
  --app-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  --app-shadow-strong: 0 18px 36px rgba(0, 0, 0, 0.11);
  --app-radius-lg: 30px;
  --app-radius-md: 22px;
  --app-radius-sm: 12px;
  --app-accent: #1d1d1f;
  --app-accent-strong: #11131a;
  --app-on-accent: #ffffff;
  --app-input-bg: #ffffff;
  --app-focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.16);
  --app-focus-border: #7cb1f3;
  --app-hover-border: rgba(0, 113, 227, 0.34);
  --app-success-bg: #eef5ff;
  --app-success-border: #c9ddf7;
  --app-success-text: #0f4f9f;
  --app-error-bg: #fff3f2;
  --app-error-border: #f3cccc;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

@keyframes app-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background:
    radial-gradient(980px 420px at 12% -18%, rgba(56, 189, 248, 0.24), transparent 70%),
    radial-gradient(820px 360px at 90% -18%, rgba(16, 185, 129, 0.16), transparent 72%),
    linear-gradient(180deg, var(--app-bg-soft) 0%, var(--app-bg) 100%);
  color: var(--app-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before,
body::after {
  border-radius: 999px;
  content: "";
  filter: blur(24px);
  opacity: .44;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

body::before {
  background: rgba(56, 189, 248, 0.18);
  height: 250px;
  left: -94px;
  top: 128px;
  width: 250px;
}

body::after {
  background: rgba(16, 185, 129, 0.14);
  height: 280px;
  right: -102px;
  top: 300px;
  width: 280px;
}

body.theme-dark {
  color-scheme: dark;
  --app-bg: #06080c;
  --app-bg-soft: #0c0f14;
  --app-panel: #171b22;
  --app-panel-soft: #2c2c2e;
  --app-text: #f5f5f7;
  --app-muted: #a1a1a6;
  --app-border: #3a3a3c;
  --app-border-soft: #2c2c2e;
  --app-brand: #0a84ff;
  --app-brand-strong: #409cff;
  --app-brand-soft: rgba(10, 132, 255, 0.22);
  --app-danger: #ff453a;
  --app-warning: #ffc86c;
  --app-success: #30d158;
  --app-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
  --app-shadow-strong: 0 22px 46px rgba(0, 0, 0, 0.55);
  --app-accent: #f5f5f7;
  --app-accent-strong: #ffffff;
  --app-on-accent: #1d1d1f;
  --app-input-bg: #1f242c;
  --app-focus-ring: 0 0 0 4px rgba(10, 132, 255, 0.28);
  --app-focus-border: #4ea3ff;
  --app-hover-border: rgba(64, 156, 255, 0.45);
  --app-success-bg: rgba(10, 132, 255, 0.14);
  --app-success-border: rgba(64, 156, 255, 0.34);
  --app-success-text: #cfe5ff;
  --app-error-bg: rgba(255, 69, 58, 0.14);
  --app-error-border: rgba(255, 69, 58, 0.34);
}

.app-nav {
  backdrop-filter: saturate(180%) blur(18px);
  background: rgba(250, 252, 254, 0.84);
  border-bottom: 1px solid var(--app-border-soft);
  color: var(--app-text);
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

body.theme-dark .app-nav {
  background: rgba(17, 19, 24, 0.78);
  border-bottom-color: var(--app-border);
}

.app-brand {
  color: var(--app-text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  justify-self: start;
}

.app-brand span {
  font-size: 19px;
  line-height: 1;
}

.app-brand-logo {
  display: block;
  width: auto;
  height: 52px;
}

.app-nav-center {
  justify-self: center;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.app-nav-actions {
  display: flex;
  justify-self: end;
  align-items: center;
}

.app-nav-link {
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.01em;
  padding: 7px 13px;
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.app-nav-link:hover {
  background: var(--app-brand-soft);
  border-color: #cbdff9;
  color: var(--app-brand);
}

.app-nav-link.active {
  background: var(--app-brand-soft);
  border-color: #bed8fb;
  color: var(--app-brand-strong);
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.12);
}

.theme-toggle {
  appearance: none;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--app-text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  letter-spacing: -0.01em;
  min-height: 34px;
  padding: 0 12px;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.theme-toggle:hover {
  background: var(--app-panel-soft);
  border-color: var(--app-muted);
}

body.theme-dark .theme-toggle {
  background: #2c2c2e;
  border-color: #4a4a4f;
  color: #f5f5f7;
}

.button,
.btn {
  align-items: center;
  appearance: none;
  background: var(--app-brand);
  border: 1px solid transparent;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  text-decoration: none;
  transition: background-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.button:hover,
.btn:hover {
  background: var(--app-brand-strong);
  box-shadow: 0 6px 18px rgba(0, 113, 227, 0.22);
}

.button:disabled,
.btn:disabled,
.btn[disabled] {
  cursor: not-allowed;
  opacity: .55;
}

.button.secondary,
.btn.secondary {
  background: var(--app-panel);
  border-color: var(--app-border);
  color: var(--app-muted);
}

.button.secondary:hover,
.btn.secondary:hover {
  background: var(--app-panel-soft);
  color: var(--app-text);
  box-shadow: none;
}

.button:focus-visible,
.btn:focus-visible,
.theme-toggle:focus-visible,
.app-nav-link:focus-visible {
  outline: none;
  box-shadow: var(--app-focus-ring);
}

.tool-wrap,
.wrap {
  width: min(1180px, calc(100% - 36px));
  margin: 24px auto 56px;
  animation: app-fade-in-up .42s ease;
}

.tool-hero {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  overflow: hidden;
  padding: 28px;
  position: relative;
}

.tool-hero::before {
  content: "";
  position: absolute;
  inset: -20% -8% auto auto;
  width: 320px;
  height: 220px;
  background:
    radial-gradient(circle at 35% 38%, rgba(0, 113, 227, 0.2), transparent 62%),
    radial-gradient(circle at 66% 66%, rgba(16, 185, 129, 0.14), transparent 64%);
  pointer-events: none;
}

.tool-title {
  color: var(--app-text);
  font-size: clamp(31px, 4.2vw, 48px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin: 0;
  position: relative;
  z-index: 1;
}

.tool-subtitle {
  color: var(--app-muted);
  font-size: 15px;
  letter-spacing: -0.015em;
  line-height: 1.35;
  margin: 10px 0 0;
  max-width: 78ch;
  position: relative;
  z-index: 1;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(0,113,227,0.14), rgba(45,212,191,0.14));
  border: 1px solid rgba(0, 113, 227, 0.28);
  color: #0f4f9f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  user-select: none;
  white-space: nowrap;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.card,
form,
.notice {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  box-shadow: var(--app-shadow);
}

body.theme-dark .hero,
body.theme-dark .tool,
body.theme-dark .card,
body.theme-dark .tool-hero,
body.theme-dark header,
body.theme-dark form,
body.theme-dark .notice,
body.theme-dark .kpi,
body.theme-dark .grid,
body.theme-dark .tableWrap {
  background: var(--app-panel) !important;
  border-color: var(--app-border) !important;
}

body.theme-dark .cardHead,
body.theme-dark .grid thead th,
body.theme-dark th {
  background: var(--app-panel-soft) !important;
  border-color: var(--app-border) !important;
  color: var(--app-muted) !important;
}

body.theme-dark .drop,
body.theme-dark .file-drop {
  background: #232326 !important;
  border-color: var(--app-border) !important;
}

body.theme-dark .drop.drag,
body.theme-dark .drop.dragover,
body.theme-dark .file-drop.dragging {
  background: #202b39 !important;
  border-color: #0a84ff !important;
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.2) !important;
}

body.theme-dark .status {
  background: #232326 !important;
  border-color: var(--app-border) !important;
  color: var(--app-muted) !important;
}

body.theme-dark .status.ok {
  background: #10243d !important;
  border-color: #264d7a !important;
  color: #8ec5ff !important;
}

body.theme-dark .status.warn {
  background: #2d2416 !important;
  border-color: #5f4a2b !important;
  color: #ffc86c !important;
}

body.theme-dark .status.bad,
body.theme-dark .status.err {
  background: #2d1f22 !important;
  border-color: #5c3439 !important;
  color: #ff8c84 !important;
}

body.theme-dark .search,
body.theme-dark .toast {
  background: var(--app-panel-soft) !important;
  border-color: var(--app-border) !important;
  color: var(--app-text) !important;
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select {
  background: #232326 !important;
  border-color: var(--app-border) !important;
  color: var(--app-text) !important;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
  color: #8e8e93 !important;
}

body.theme-dark .grid tbody tr:nth-child(odd),
body.theme-dark .grid tbody tr:nth-child(even) {
  background: #1f1f22 !important;
}

body.theme-dark .grid tbody tr:hover {
  background: #2a2a2e !important;
}

body.theme-dark td {
  border-color: var(--app-border) !important;
}

body.theme-dark tr:hover td {
  background: #2a2a2e !important;
}

@media (max-width: 760px) {
  .app-nav {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 12px 14px;
    position: relative;
  }

  .app-brand,
  .app-nav-center,
  .app-nav-actions {
    justify-self: center;
  }

  .app-nav-links {
    flex-wrap: wrap;
  }

  .tool-wrap,
  .wrap {
    width: min(100% - 24px, 1180px);
    margin: 20px auto 36px;
  }

  .tool-hero {
    flex-direction: column;
    padding: 22px;
  }
}
