:root {
  color-scheme: dark;
  --bg: #030303;
  --bg-soft: #080808;
  --surface: #0d0d0f;
  --surface-2: #141417;
  --surface-3: #1b1b20;
  --text: #f4f4f5;
  --muted: #9b9ba4;
  --muted-2: #6f7078;
  --line: #26262d;
  --line-strong: #373742;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, .1);
  --danger: #ff5c5c;
  --danger-bg: #2a1111;
  --ok: #41d987;
  --shadow: 0 24px 80px rgba(0, 0, 0, .55);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 16% -10%, rgba(255, 255, 255, .11), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(120, 120, 140, .14), transparent 26%),
    linear-gradient(180deg, #070707 0%, #030303 45%, #000 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.72), transparent 74%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
.hidden { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.04em; }
p { color: var(--muted); line-height: 1.55; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-shell {
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 520px;
  gap: 22px;
  align-items: stretch;
}

.auth-copy,
.auth-card,
.panel {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18,18,21,.98), rgba(10,10,12,.98));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.auth-copy {
  min-height: 560px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: 34px;
}

.auth-copy::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,.19), transparent 9%),
    radial-gradient(circle at 64% 44%, rgba(255,255,255,.10), transparent 11%),
    radial-gradient(circle at 48% 70%, rgba(255,255,255,.14), transparent 10%);
  opacity: .7;
}

.auth-copy::after {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  right: -160px;
  top: -140px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 62%);
}

.auth-copy > * { position: relative; z-index: 1; }
.eyebrow {
  width: fit-content;
  margin-bottom: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.auth-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(48px, 7vw, 86px);
  line-height: .9;
}

.auth-copy p {
  max-width: 560px;
  margin-bottom: 24px;
  font-size: 18px;
}

.feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-strip span,
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #111114;
  border-radius: 999px;
  padding: 6px 10px;
  color: #cfcfd6;
  font-size: 13px;
  font-weight: 800;
}

.auth-card {
  padding: 28px;
  align-self: center;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand.compact { margin-bottom: 22px; }
.brand h1, .brand h2, .topbar h1 { margin-bottom: 2px; }
.brand p, .topbar p { margin-bottom: 0; }

.brand-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #050505;
  background: #fff;
  font-weight: 950;
  letter-spacing: -.08em;
  box-shadow: 0 0 0 6px rgba(255,255,255,.06);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  background: #08080a;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
  border-radius: 11px;
  font-weight: 900;
}

.tabs button.active {
  color: #050505;
  background: #fff;
}

.auth-form,
#uploadForm,
.admin-card form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #d8d8de;
  font-weight: 800;
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #08080a;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

input::placeholder { color: var(--muted-2); }
input:focus,
select:focus {
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,.1);
}

.primary,
.secondary,
.danger {
  border-radius: var(--radius-md);
  padding: 12px 15px;
  font-weight: 950;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.primary {
  border: 1px solid #fff;
  background: #fff;
  color: #050505;
}
.primary:hover { transform: translateY(-1px); background: #e7e7ec; border-color: #e7e7ec; }
.secondary {
  border: 1px solid var(--line);
  background: #101014;
  color: var(--text);
}
.secondary:hover { transform: translateY(-1px); border-color: var(--line-strong); background: #17171c; }
.danger {
  border: 1px solid rgba(255,92,92,.34);
  background: var(--danger-bg);
  color: #ff8585;
}
.danger:hover { transform: translateY(-1px); background: #361515; }

.message {
  min-height: 20px;
  margin: 14px 0 0;
  color: #ff8585;
  font-weight: 800;
}

.app-view {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px 0;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

.panel {
  padding: 20px;
}

.upload-panel {
  position: sticky;
  top: 18px;
}

.panel-title,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title { justify-content: flex-start; }
.section-head h2,
.panel h2 { margin-bottom: 4px; }

.dot {
  width: 12px;
  height: 12px;
  margin-top: 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 24px rgba(255,255,255,.7);
}

.file-drop {
  min-height: 168px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  text-align: center;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.05), transparent 45%),
    #08080a;
  color: var(--muted);
}

.file-drop strong {
  max-width: 100%;
  color: var(--text);
  overflow-wrap: anywhere;
}

.file-drop small {
  color: var(--muted-2);
  font-weight: 700;
}

.file-drop.dragging {
  border-color: #fff;
  background: rgba(255,255,255,.08);
  color: #fff;
}
.file-drop input { display: none; }


.upload-progress {
  margin-top: 2px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #070709;
}

#uploadProgressText {
  max-width: 260px;
  text-align: right;
  overflow-wrap: anywhere;
}

.usage-box {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #09090b;
}

.usage-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.usage-head b { color: var(--text); }
.bar {
  height: 12px;
  margin-top: 10px;
  border-radius: 999px;
  background: #1c1c22;
  overflow: hidden;
}
.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fff, #9b9ba4);
  transition: width .2s ease;
}
#maxUploadText { margin: 10px 0 0; font-size: 13px; }

.files-list { display: grid; gap: 12px; }
.file-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #09090b;
}
.file-card:hover { border-color: var(--line-strong); background: #0d0d10; }
.file-title {
  font-weight: 950;
  overflow-wrap: anywhere;
}
.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 520px;
}
.file-actions select {
  width: auto;
  min-width: 142px;
  padding: 9px 10px;
}
.file-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-weight: 950;
  background: #101014;
  color: var(--text);
}
.file-actions a:hover { background: #17171c; border-color: var(--line-strong); }
.file-actions button { padding: 10px 12px; }

.empty {
  padding: 34px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  color: var(--muted);
  background: #09090b;
}

.admin-panel { margin-top: 18px; }
.admin-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}
.admin-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #09090b;
  padding: 16px;
}
.admin-card.wide { grid-column: 1 / -1; }
.token-output,
.users-list,
.tokens-list { display: grid; gap: 10px; }
.token-pill,
.user-row,
.token-row {
  display: grid;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0f0f12;
  padding: 12px;
}
.token-pill {
  grid-template-columns: minmax(0, 1fr) auto;
}
.user-row,
.token-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
code {
  color: #f4f4f5;
  background: #050505;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px 6px;
  overflow-wrap: anywhere;
}
.user-row form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.user-row input {
  width: 120px;
  padding: 9px 10px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #fff;
  color: #050505;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 11px 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  z-index: 50;
  font-weight: 900;
}

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-copy { min-height: 360px; }
  .grid,
  .admin-grid { grid-template-columns: 1fr; }
  .upload-panel { position: static; }
}

@media (max-width: 760px) {
  .auth-view { padding: 16px; }
  .app-view { width: min(100% - 20px, 1440px); padding-top: 10px; }
  .topbar,
  .section-head,
  .file-card,
  .user-row,
  .token-row,
  .token-pill {
    grid-template-columns: 1fr;
    display: grid;
  }
  .top-actions,
  .file-actions { justify-content: flex-start; max-width: none; }
  .file-actions select { width: 100%; }
  .auth-copy,
  .auth-card,
  .panel { border-radius: 22px; }
}
