:root {
  --bg: #070b14;
  --bg-elevated: #0d1320;
  --surface: rgba(18, 24, 38, 0.82);
  --surface-solid: #121826;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --accent-hover: #a5b4fc;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.22);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 24%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.35rem 1rem 1.5rem;
  border-right: 1px solid var(--border);
  background: rgba(8, 12, 22, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.35rem 0.5rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #22d3ee 100%);
  box-shadow: 0 10px 24px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-text strong {
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.78rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.78rem 0.9rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav-icon {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-footer-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.sidebar-footer-link {
  font-size: 0.85rem;
  word-break: break-all;
}

.main-wrap {
  min-width: 0;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.75rem 3.5rem;
}

.container-wide {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 2rem 1.5rem 3.5rem;
}

.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-top h1,
h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-intro {
  margin: 0.45rem 0 0;
  color: var(--muted);
  max-width: 42rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  margin: 0;
}

.lead {
  color: var(--muted);
  margin: -0.75rem 0 1.5rem;
  max-width: 42rem;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.card h2,
.card-label h2 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-stat {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.35rem 0;
}

.mono {
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 0.86rem;
  word-break: break-all;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.hint {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 0.4rem;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.18);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.18);
}

.badge.muted {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  border-color: var(--border);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.panel,
.form-card,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.panel h2,
.form-card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.activity {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.activity li:last-child {
  border-bottom: none;
}

.activity li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.12);
  flex-shrink: 0;
}

.activity time {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  padding-top: 0.1rem;
  flex-shrink: 0;
  min-width: 4.5rem;
}

.activity-error::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.12);
}

.activity-warn::before {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.12);
}

.activity-error span {
  color: #fecaca;
}

.activity-warn span {
  color: #fde68a;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

button.btn {
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-strong), #7c3aed);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 28px var(--accent-glow);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #7c83ff, #8b5cf6);
  color: #fff;
}

.btn.danger {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
  background: var(--danger-bg);
}

.btn.small {
  padding: 0.42rem 0.72rem;
  font-size: 0.8rem;
  border-radius: 10px;
}

.table-wrap {
  padding: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 1rem 1.15rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table .mono {
  white-space: nowrap;
}

.table th:last-child,
.table td.row-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface-solid);
  box-shadow: -8px 0 12px rgba(0, 0, 0, 0.18);
}

.table th:last-child {
  background: rgba(18, 24, 38, 0.98);
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: rgba(255, 255, 255, 0.02);
}

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

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.row-actions form {
  margin: 0;
  display: flex;
  flex: 0 0 auto;
}

.row-actions .btn {
  flex: 0 0 auto;
}

.password-field,
.password-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.password-input-wrap {
  width: 100%;
}

.password-input-wrap input {
  flex: 1;
  min-width: 0;
}

.password-toggle {
  flex-shrink: 0;
}

.password-value {
  min-width: 4.5rem;
}

.destination-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.destination-log-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.destination-log-detail {
  font-size: 0.82rem;
}

.empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty p {
  margin-top: 0;
}

.form,
.form-card .form {
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-card {
  max-width: 720px;
}

.form-wide {
  max-width: 860px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form select {
  padding: 0.72rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(7, 11, 20, 0.72);
  color: var(--text);
  font-size: 0.98rem;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.form input:focus,
.form select:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
}

.form-row .narrow {
  width: 110px;
}

.checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.65rem !important;
  font-weight: 500 !important;
}

.checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-strong);
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}

.fieldset legend {
  padding: 0 0.4rem;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.destination-list {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.destination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.destination-prefix {
  flex-shrink: 0;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
}

.config-path {
  margin-top: 1.5rem;
}

.upload-form .dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 220px;
  border: 1px dashed rgba(129, 140, 248, 0.35);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.02)),
    rgba(255, 255, 255, 0.02);
  cursor: pointer;
  text-align: center;
  padding: 1.75rem;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.upload-form .dropzone::before {
  content: "↑";
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(99, 102, 241, 0.16);
  color: var(--accent-hover);
  font-size: 1.4rem;
}

.upload-form .dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-form .dropzone span {
  color: var(--muted);
  pointer-events: none;
  max-width: 24rem;
}

.upload-form .dropzone:has(input:focus),
.upload-form .dropzone:hover {
  border-color: rgba(129, 140, 248, 0.65);
  box-shadow: 0 16px 40px rgba(99, 102, 241, 0.12);
  transform: translateY(-1px);
}

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

.login-shell {
  width: min(100%, 420px);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.75rem;
}

.login-brand strong {
  display: block;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.login-brand p {
  margin: 0.15rem 0 0;
}

.login-form {
  max-width: none;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
}

.login-error {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fecaca;
  font-size: 0.92rem;
}

.sidebar-logout {
  margin: 0;
  padding-top: 0.5rem;
}

.sidebar-logout .btn {
  width: 100%;
}

.stack-top {
  margin-top: 1.5rem;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .nav-link {
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .container {
    padding: 1.35rem 1rem 2.5rem;
  }

  .page-top,
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .destination-row {
    flex-direction: column;
    align-items: stretch;
  }
}
