:root {
  --primary-color: #6d55ff;
  --primary-hover: #8b73ff;
  --background: #fbf8ff;
  --surface: rgba(255,255,255,.78);
  --surface-2: rgba(245,239,255,.62);
  --border: rgba(109,85,255,.14);
  --text-primary: #20164a;
  --text-secondary: #6f6490;
  --text-muted: #9a8cb9;
  --success: #38c98b;
  --warning: #ffb45c;
  --error: #ff5c82;
  --shadow: 0 18px 58px rgba(88,64,236,.10);
  --shadow-lg: 0 28px 90px rgba(88,64,236,.16);
  --radius: 30px;
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dark-theme {
  --background: #120e24;
  --surface: rgba(30,24,56,.78);
  --surface-2: rgba(24,19,45,.72);
  --border: rgba(169,145,255,.20);
  --text-primary: #f4f0ff;
  --text-secondary: #bdb3de;
  --text-muted: #8f84b3;
  --shadow: 0 18px 58px rgba(0,0,0,.26);
  --shadow-lg: 0 28px 90px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font);
  letter-spacing: 0;
  background:
    radial-gradient(circle at 8% 12%, rgba(109,85,255,.18), transparent 24rem),
    radial-gradient(circle at 88% 8%, rgba(255,120,184,.18), transparent 26rem),
    radial-gradient(circle at 70% 92%, rgba(65,214,195,.16), transparent 30rem),
    linear-gradient(180deg, #fbf8ff 0%, #f6f0ff 56%, #fbf8ff 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.dark-theme body {
  background:
    radial-gradient(circle at 8% 12%, rgba(139,115,255,.20), transparent 24rem),
    radial-gradient(circle at 88% 8%, rgba(255,120,184,.12), transparent 26rem),
    radial-gradient(circle at 70% 92%, rgba(65,214,195,.08), transparent 30rem),
    linear-gradient(180deg, #120e24 0%, #1a1433 56%, #120e24 100%);
}

body::before, body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  inset: 0;
  background:
    linear-gradient(125deg, transparent 0 28%, rgba(255,255,255,.54) 42%, transparent 58%),
    radial-gradient(circle at 38% 22%, rgba(109,85,255,.09), transparent 16rem);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), transparent 78%);
}

.dark-theme body::before {
  background:
    linear-gradient(125deg, transparent 0 28%, rgba(255,255,255,.06) 42%, transparent 58%),
    radial-gradient(circle at 38% 22%, rgba(139,115,255,.12), transparent 16rem);
}

body::after {
  width: 320px;
  height: 320px;
  right: -110px;
  top: 24%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(109,85,255,.16), rgba(255,120,184,.10) 42%, transparent 70%);
  filter: blur(4px);
}

.dark-theme body::after {
  background: radial-gradient(circle, rgba(139,115,255,.18), rgba(255,120,184,.06) 42%, transparent 70%);
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
svg {
  width: 24px;
  height: 24px;
  fill: none;
}
svg, svg * { stroke: currentColor; }

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  width: 100%;
  margin: 0 auto;
  padding: 18px 28px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: rgba(255,255,255,.62);
  box-shadow: 0 18px 70px rgba(88,64,236,.10), inset 0 1px 0 rgba(255,255,255,.82);
  backdrop-filter: blur(24px);
}

.dark-theme .topbar {
  background: rgba(30,24,56,.68);
  border-color: rgba(169,145,255,.18);
  box-shadow: 0 18px 70px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.08);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 800;
}

.fly-logo-mark {
  width: 54px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.fly-logo-mark img {
  width: 82px;
  height: 64px;
  object-fit: contain;
  transform: translate(-6px, -7px);
}

.nav, .top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a, button, .solid, .ghost, .upload-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(109,85,255,.16);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.82);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.dark-theme .nav a,
.dark-theme button,
.dark-theme .ghost {
  background: rgba(31,25,58,.72);
  border-color: rgba(169,145,255,.18);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.nav a:hover, .nav a.active, .ghost:hover {
  background: rgba(109,85,255,.08);
  border-color: rgba(109,85,255,.28);
}

.solid, .upload-button {
  background: linear-gradient(135deg, #6d55ff, #8b73ff) !important;
  border-color: rgba(109,85,255,.34) !important;
  color: #fff !important;
  box-shadow: 0 16px 32px rgba(109,85,255,.22);
}

.theme-toggle {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: #6d55ff;
}

.dark-theme .theme-toggle {
  color: #b8a8ff;
}

.theme-icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-sun,
.dark-theme .theme-icon-moon {
  display: none;
}

.dark-theme .theme-icon-sun {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.panel, .page-card, .table-wrap, .dropzone, .access-box, .status-tile, .help-list article, .modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.86);
  backdrop-filter: blur(24px);
}

.dark-theme .panel,
.dark-theme .page-card,
.dark-theme .table-wrap,
.dark-theme .dropzone,
.dark-theme .access-box,
.dark-theme .status-tile,
.dark-theme .help-list article,
.dark-theme .modal {
  background: linear-gradient(145deg, rgba(34,27,62,.82), rgba(24,19,45,.72));
  border-color: rgba(169,145,255,.18);
  box-shadow: 0 18px 58px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.07);
}

.side-panel, .access-panel { padding: 22px; }

.panel-title, .section-label {
  display: block;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 800;
}

.node-card {
  position: relative;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(109,85,255,.14);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 18%, rgba(109,85,255,.18), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,.86), rgba(243,237,255,.68));
}

.dark-theme .node-card,
.dark-theme .hero-line {
  background:
    radial-gradient(circle at 88% 18%, rgba(139,115,255,.20), transparent 34%),
    linear-gradient(145deg, rgba(34,27,62,.86), rgba(24,19,45,.74));
  border-color: rgba(169,145,255,.18);
  box-shadow: 0 18px 58px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.07);
}

.node-card span, .muted, .lead, .status-tile span, .dropzone p { color: var(--text-secondary); }

.node-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
}

.node-svg {
  position: absolute;
  right: 18px;
  top: 22px;
  color: var(--primary-color);
}

.kv { margin: 20px 0; }
.kv div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(109,85,255,.12);
}
.kv dt { color: var(--text-secondary); font-weight: 800; }
.kv dd { margin: 0; font-weight: 800; }

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 999px;
  vertical-align: -1px;
}
.dot.ok { background: var(--success); }
.dot.warn { background: var(--warning); }
.dot.bad { background: var(--error); }

.meter-head, .progress-head, .mini-log, .statusbar, .file-list, .drop-meta, .form-error, .notice {
  font-family: var(--mono);
}

.meter-head, .progress-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.meter {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 4px;
  margin-bottom: 18px;
}
.meter-seg {
  height: 10px;
  border-radius: 999px;
  background: rgba(109,85,255,.10);
}
.meter-seg.filled {
  background: linear-gradient(90deg, #6d55ff, #8b73ff);
}

.mini-log {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}
.mini-log p { margin: 0 0 8px; }
.mini-log span { color: var(--text-muted); }

.content,
.panel,
.page-card,
.table-wrap,
.dropzone,
.access-box {
  min-width: 0;
}

.hero-line {
  min-height: 230px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 88% 18%, rgba(109,85,255,.18), transparent 34%),
    radial-gradient(circle at 72% 82%, rgba(89,203,255,.10), transparent 28%),
    linear-gradient(145deg, rgba(255,255,255,.86), rgba(243,237,255,.68));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.86);
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin: 18px 0 12px;
  max-width: 680px;
  color: var(--text-primary);
  font-size: clamp(38px, 5vw, 64px);
  line-height: .92;
  font-weight: 800;
}
.lead {
  max-width: 700px;
  font-size: 17px;
  line-height: 1.55;
}

.search {
  width: min(300px, 100%);
  position: relative;
  align-self: end;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(109,85,255,.16);
  border-radius: 18px;
  outline: 0;
  background: rgba(255,255,255,.72);
  color: var(--text-primary);
}

.dark-theme input,
.dark-theme .drop-inner,
.dark-theme .drop-meta span,
.dark-theme .file-row,
.dark-theme .badge {
  background: rgba(31,25,58,.72);
}
.search input { padding-left: 46px; }
input:focus {
  border-color: rgba(109,85,255,.34);
  box-shadow: 0 0 0 4px rgba(109,85,255,.10);
}

.dropzone {
  min-height: 292px;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: pointer;
}
.drop-inner {
  width: 100%;
  min-height: 234px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1px dashed rgba(109,85,255,.26);
  border-radius: 24px;
  text-align: center;
  background: rgba(255,255,255,.32);
}
.dropzone.is-drag { border-color: rgba(109,85,255,.42); }
.upload-icon {
  width: 52px;
  height: 52px;
  color: var(--primary-color);
}
.dropzone h2 {
  margin: 10px 0 8px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
  font-weight: 900;
}
.drop-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 16px;
  color: var(--text-secondary);
  font-size: 12px;
}
.drop-code {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 800;
}
.drop-meta span {
  padding: 7px 10px;
  border: 1px solid rgba(109,85,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.52);
}
.upload-progress { display: none; width: min(560px, 100%); margin-top: 18px; }
.upload-progress.active { display: block; }
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(109,85,255,.10);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #6d55ff, #8b73ff);
  transition: width .25s ease;
}
.stages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 11px;
}
.stages span {
  padding: 6px 9px;
  border: 1px solid rgba(109,85,255,.14);
  border-radius: 999px;
}
.stages .done { color: var(--primary-color); }
.notice { margin: 12px 0 0; color: var(--warning); font-size: 12px; }

.table-wrap, .page-card { margin-top: 18px; overflow: hidden; }
.table-head, .page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  min-height: 62px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(109,85,255,.12);
}
.file-list { display: grid; gap: 8px; padding: 14px; }
.file-list [data-file-rows] { display: grid; gap: 8px; }
.file-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) minmax(70px, .55fr) minmax(60px, .5fr) minmax(92px, .7fr) minmax(92px, .7fr) minmax(86px, .65fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid rgba(109,85,255,.12);
  border-radius: 18px;
  background: rgba(255,255,255,.45);
}
.file-row.header {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
}
.file-row span {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary) !important;
  font-weight: 900;
}
.file-icon {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #6d55ff, #b08cff);
  font-size: 8px;
  font-weight: 900;
}
.type-pdf { background: linear-gradient(135deg, #ff5c82, #ff78b8); }
.type-archive { background: linear-gradient(135deg, #ffb45c, #ffd166); }
.type-sheet, .type-csv { background: linear-gradient(135deg, #38c98b, #41d6c3); }
.type-text, .type-json, .type-yaml { background: linear-gradient(135deg, #bdb3de, #8f84b3); }

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(109,85,255,.14);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255,255,255,.48);
}
.badge.ok { color: #168b60; border-color: rgba(56,201,139,.28); }
.badge.warn { color: #b36b00; border-color: rgba(255,180,92,.36); }

.access-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: 24px;
}
.access-box h2 {
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 900;
}
.access-box.compact p {
  margin-bottom: 14px;
  line-height: 1.45;
}
label {
  display: block;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
}
label input { margin-top: 7px; }
.wide { width: 100%; }
.form-error { margin: 12px 0 0; color: var(--error); font-size: 12px; }
.lock-orb {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(109,85,255,.10);
  color: var(--primary-color);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px;
}
.status-tile { padding: 18px; border-radius: 24px; }
.status-tile strong { display: block; margin-bottom: 8px; }

.help-list { display: grid; gap: 12px; margin: 18px; }
.help-list article { padding: 18px; border-radius: 24px; }
.help-list h3 { margin-bottom: 8px; }

.modal-layer[hidden] { display: none; }
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 17, 52, .34);
  backdrop-filter: blur(10px);
}
.modal {
  position: relative;
  width: min(430px, 100%);
  padding: 24px;
}
.icon-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.statusbar {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  overflow: auto;
}
.statusbar span { white-space: nowrap; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .access-panel { display: none; }
  .file-row { grid-template-columns: minmax(170px, 1.5fr) 70px 60px 90px 90px 80px; }
}

@media (max-width: 820px) {
  .shell { padding: 12px; }
  .layout { grid-template-columns: 1fr; }
  .side-panel { display: none; }
  .hero-line { flex-direction: column; min-height: auto; }
  .search { align-self: stretch; }
  .file-row, .file-row.header { grid-template-columns: 1fr; gap: 8px; }
  .file-row.header { display: none; }
  .file-row span::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
  }
  .file-name::before { display: none !important; }
  .status-grid { grid-template-columns: 1fr; }
}
