:root {
  color-scheme: dark;
  --bg: #07101e;
  --panel: rgba(16, 29, 49, .76);
  --panel-strong: #101d31;
  --line: rgba(151, 175, 209, .16);
  --text: #f4f7fb;
  --muted: #92a5bf;
  --primary: #53d5bd;
  --primary-strong: #22bda3;
  --blue: #6fa8ff;
  --danger: #ff7185;
  --warning: #ffc968;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--text); background: radial-gradient(circle at 70% -10%, #17325a 0, transparent 42%), linear-gradient(145deg, #07101e 0%, #0a1424 60%, #07101e 100%); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.ambient { position: fixed; border-radius: 999px; filter: blur(100px); opacity: .15; pointer-events: none; }
.ambient-one { width: 360px; height: 360px; background: #42dab9; left: -180px; top: 35%; }
.ambient-two { width: 420px; height: 420px; background: #3878ff; right: -220px; bottom: -80px; }
.glass { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 430px); padding: 34px; border-radius: 28px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { filter: drop-shadow(0 8px 16px rgba(67, 220, 189, .22)); }
.brand div { display: grid; min-width: 0; }
.brand strong { letter-spacing: -.02em; }
.brand span { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-auth { padding-bottom: 34px; }
.brand-auth strong { font-size: 1.08rem; }
.auth-card h1 { margin: 4px 0 10px; font-size: 2rem; letter-spacing: -.05em; }
.muted { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.stack-form { display: grid; gap: 17px; margin-top: 26px; }
label { display: grid; gap: 8px; color: #c7d3e3; font-size: .84rem; font-weight: 650; }
input, textarea { width: 100%; color: var(--text); background: rgba(4, 12, 23, .65); border: 1px solid rgba(147, 173, 209, .23); border-radius: 13px; outline: none; transition: border-color .2s, box-shadow .2s; }
.stack-form input { padding: 13px 14px; }
input:focus, textarea:focus { border-color: rgba(83, 213, 189, .8); box-shadow: 0 0 0 4px rgba(83, 213, 189, .1); }
input[readonly] { color: var(--muted); }
.primary { min-height: 48px; padding: 0 22px; border: 0; border-radius: 13px; color: #041714; font-weight: 800; background: linear-gradient(135deg, #6ce5cf, #35c7ad); box-shadow: 0 10px 28px rgba(50, 198, 172, .2); transition: transform .18s, filter .18s; }
.primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary:disabled { cursor: not-allowed; opacity: .52; transform: none; }
.full { width: 100%; margin-top: 4px; }
.form-error { min-height: 1.3em; margin: 17px 0 0; color: #ff9baa; font-size: .84rem; }
.form-error.compact { margin: 9px 3px -3px; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px max(22px, calc((100vw - 1240px)/2)); border-bottom: 1px solid var(--line); background: rgba(7, 16, 30, .82); backdrop-filter: blur(22px); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-pill { padding: 8px 12px; color: #c9d5e4; background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; }
.icon-button, .ghost { color: #c9d5e4; background: rgba(255,255,255,.045); border: 1px solid var(--line); }
.icon-button { width: 36px; height: 36px; border-radius: 11px; font-size: 1.05rem; }
.ghost { padding: 8px 12px; border-radius: 10px; }
.small { font-size: .78rem; }

.dashboard { width: min(1240px, calc(100% - 44px)); margin: 0 auto; padding: 54px 0 80px; }
.hero-grid { display: grid; grid-template-columns: 1.25fr .75fr; align-items: end; gap: 28px; }
.hero-copy h1 { max-width: 700px; margin: 9px 0 12px; font-size: clamp(2.35rem, 5vw, 4.7rem); line-height: .98; letter-spacing: -.065em; }
.hero-copy > p:last-child { max-width: 650px; margin: 0; color: var(--muted); font-size: 1.02rem; line-height: 1.6; }
.vpn-card { padding: 22px; border-radius: 19px; }
.vpn-heading { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 5px rgba(255, 201, 104, .1); }
.vpn-card.connected .status-dot { background: var(--primary); box-shadow: 0 0 0 5px rgba(83, 213, 189, .1); }
.vpn-card.disconnected .status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 113, 133, .1); }
.vpn-card p { min-height: 2.6em; margin: 12px 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.vpn-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.vpn-meta span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 6px 9px; border-radius: 8px; color: #b8c7d9; background: rgba(255,255,255,.04); font-size: .72rem; }

.add-card { margin-top: 38px; padding: 22px; border-radius: 22px; }
.add-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.add-heading h2 { margin: 5px 0 0; font-size: 1.25rem; letter-spacing: -.03em; }
.domain-badge { padding: 7px 10px; color: #9eb1ca; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 999px; font-size: .69rem; }
.add-form { display: grid; gap: 13px; }
.url-field { display: grid; grid-template-columns: auto 1fr; gap: 13px; min-width: 0; padding: 14px 15px; color: var(--primary); background: rgba(3, 10, 20, .62); border: 1px solid rgba(147, 173, 209, .18); border-radius: 15px; transition: border-color .2s, box-shadow .2s; }
.url-field:focus-within { border-color: rgba(83, 213, 189, .55); box-shadow: 0 0 0 4px rgba(83, 213, 189, .07); }
.composer-icon { display: grid; place-items: center; width: 34px; height: 34px; margin-top: 1px; color: var(--primary); background: rgba(83,213,189,.09); border-radius: 10px; font-size: 1rem; }
.url-field textarea { min-width: 0; min-height: 94px; max-height: 280px; padding: 7px 4px; resize: vertical; border: 0; border-radius: 0; background: transparent; box-shadow: none; line-height: 1.55; }
.url-field textarea:focus { border: 0; box-shadow: none; }
.url-field textarea::placeholder { color: #687d99; }
.add-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.link-counter { color: var(--muted); font-size: .76rem; }
.link-counter.detected { color: var(--primary); }
.add-actions .primary { min-width: 180px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 20px; }
.stat-card { display: grid; padding: 19px 20px; border-radius: 17px; box-shadow: none; }
.stat-card span { color: var(--muted); font-size: .76rem; }
.stat-card strong { margin: 4px 0 2px; font-size: 1.65rem; letter-spacing: -.04em; }
.stat-card small { color: #6f839e; font-size: .7rem; }

.downloads-section { margin-top: 52px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 5px 0 0; font-size: 1.55rem; letter-spacing: -.035em; }
.filter-group { display: flex; padding: 4px; background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 12px; }
.filter { padding: 7px 11px; color: var(--muted); border: 0; border-radius: 8px; background: transparent; font-size: .76rem; }
.filter.active { color: var(--text); background: rgba(255,255,255,.09); }
.downloads-list { display: grid; gap: 10px; }
.download-row { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(160px, .55fr) auto; align-items: center; gap: 22px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(13, 25, 43, .66); transition: border-color .2s, transform .2s; }
.download-row:hover { border-color: rgba(151, 175, 209, .28); transform: translateY(-1px); }
.file-main { display: flex; min-width: 0; gap: 13px; align-items: center; }
.file-icon { flex: 0 0 auto; display: grid; place-items: center; width: 42px; height: 42px; color: var(--blue); background: rgba(111, 168, 255, .09); border-radius: 12px; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.file-copy { min-width: 0; }
.file-name { display: block; overflow: hidden; color: var(--text); font-size: .9rem; font-weight: 700; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: var(--primary); }
.file-sub { display: flex; gap: 8px; margin-top: 5px; color: var(--muted); font-size: .71rem; }
.state-label.error { color: var(--danger); }
.state-label.completed, .state-label.extracted { color: var(--primary); }
.progress-column { min-width: 0; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.07); }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #5c9eff, #53d5bd); transition: width .35s ease; }
.progress-bar.indeterminate { width: 35%; animation: indeterminate 1.4s ease-in-out infinite; }
@keyframes indeterminate { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
.progress-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--muted); font-size: .69rem; }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }
.action { min-width: 34px; height: 34px; padding: 0 9px; color: #bdcad9; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; }
.action:hover { color: var(--text); background: rgba(255,255,255,.08); }
.action.danger:hover { color: #ff9baa; border-color: rgba(255,113,133,.32); }
.error-detail { grid-column: 1 / -1; margin: -7px 0 0 55px; color: #ff9baa; font-size: .74rem; }
.empty-state { display: grid; place-items: center; padding: 54px 20px; border-radius: 19px; text-align: center; box-shadow: none; }
.empty-state h3 { margin: 12px 0 4px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: var(--primary); background: rgba(83,213,189,.09); font-size: 1.4rem; }

.log-card { margin-top: 26px; padding: 0 18px; border-radius: 16px; box-shadow: none; }
.log-card summary { cursor: pointer; padding: 16px 0; font-size: .84rem; font-weight: 700; }
.log-card summary span { margin-left: 8px; color: var(--muted); font-size: .7rem; font-weight: 400; }
.events-list { display: grid; gap: 7px; padding: 0 0 16px; }
.event { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: .72rem; }
.event.error { color: #ff9baa; }
.event.warning { color: var(--warning); }
.toast-region { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(360px, calc(100% - 40px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: #14233a; box-shadow: var(--shadow); font-size: .82rem; animation: toast-in .2s ease-out; }
.toast.error { border-color: rgba(255,113,133,.35); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 850px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .download-row { grid-template-columns: 1fr auto; }
  .progress-column { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 600px) {
  .topbar { padding: 12px 14px; }
  .topbar .brand span, .user-pill { display: none; }
  .dashboard { width: min(100% - 28px, 1240px); padding-top: 36px; }
  .hero-copy h1 { font-size: 2.55rem; }
  .add-heading { align-items: flex-start; }
  .domain-badge { display: none; }
  .add-actions { align-items: stretch; flex-direction: column; }
  .add-actions .primary { width: 100%; }
  .stats-grid { gap: 9px; }
  .stat-card { padding: 16px; }
  .section-heading { align-items: start; flex-direction: column; }
  .filter-group { width: 100%; overflow-x: auto; }
  .filter { flex: 1; }
  .download-row { grid-template-columns: 1fr; gap: 13px; }
  .progress-column { grid-column: 1; grid-row: auto; }
  .row-actions { justify-content: flex-start; }
  .error-detail { margin: -3px 0 0; }
  .auth-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
