:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --border: #2a2a32;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #dc2626;
  --radius: 8px;
  --font: system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 1rem; width: 100%; }

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.admin-link, .header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.admin-link:hover, .header-nav a:hover { color: var(--accent); }
.logout-form { margin: 0; }
.logout-form button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
}
.logout-form button:hover { color: var(--accent); }

.main { flex: 1; padding: 1.5rem 0; }
.page-title { margin: 0 0 0.5rem; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.2px; }
.section-title { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; font-weight: 600; color: var(--text-muted); }
.section:first-of-type .page-title { margin-top: 0; }

.link-list, .file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.link-item, .file-item { margin: 0; }
.link-card, .file-card {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.link-card:hover, .file-card:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}
.link-title, .file-name { font-weight: 500; display: block; }
.link-desc, .file-meta { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; display: block; }

.empty { color: var(--text-muted); margin: 0.5rem 0; }

.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.auth-section {
  max-width: 420px;
  margin: 6vh auto;
  padding: 1rem;
}
.auth-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(99,102,241,0.08);
  box-shadow: 0 8px 24px rgba(2,6,23,0.6);
  padding: 1.25rem;
  border-radius: calc(var(--radius) + 4px);
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.5rem; }
.label { display: block; font-size: 0.875rem; margin-bottom: 0.25rem; color: var(--text-muted); }
.input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
}
.input-num { width: 5rem; }
.input-file { font-size: 0.9rem; }
.error-msg { color: var(--danger); margin: 0 0 0.5rem; }

.btn {
  display: inline-block;
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 14px rgba(99,102,241,0.12); transition: transform 0.12s ease, background 0.12s ease; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.form-inline, .form-upload { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.form-inline .input, .form-upload .input { flex: 1; min-width: 120px; }
.form-upload .input-file { min-width: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; flex: 1; min-width: 0; }
.form-row .input { flex: 1; min-width: 80px; }
.form-delete { margin-left: auto; }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.admin-item .form-row { flex: 1; min-width: 200px; }
.files-admin .admin-item { flex-wrap: wrap; }
.file-name-link { color: var(--accent); text-decoration: none; flex: 1; min-width: 120px; }
.file-name-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .form-inline .input, .form-row .input { min-width: 100%; }
  .form-inline, .form-upload { flex-direction: column; align-items: stretch; }
  .admin-item { flex-direction: column; align-items: stretch; }
  .form-delete { margin-left: 0; }
  .input-num { width: 100%; }
}
