*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050816;
  --bg-soft: #050816;
  --bg-card: #020617;
  --bg-elevated: #020617;
  --border-subtle: #1f2937;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.18);
  --danger: #f97373;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.8);
}

body.theme-light {
  --bg: #f3f4f6;
  --bg-soft: #e5e7eb;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.16);
  --danger: #ef4444;
  --shadow-soft: 0 18px 35px rgba(15, 23, 42, 0.15);
}

body.theme-hacker {
  --bg: #020617;
  --bg-soft: #020617;
  --bg-card: #020617;
  --bg-elevated: #020617;
  --border-subtle: #16a34a33;
  --text-main: #ecfdf5;
  --text-muted: #6ee7b7;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.25);
  --danger: #f97373;
  --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.9);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #22c55e11, transparent 55%), var(--bg);
  color: var(--text-main);
  min-height: 100vh;
}

/* Utils */

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.8rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.18s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.4);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(34, 197, 94, 0.55);
}

.btn.outline {
  background: transparent;
  color: var(--text-main);
}

.btn.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn.tiny {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

.btn.full {
  width: 100%;
}

.icon-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  padding: 0.32rem 0.6rem;
  font-size: 1rem;
  cursor: pointer;
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  top: 1.1rem;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 90%;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 0.85rem;
  text-align: center;
  z-index: 999;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.8);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.9);
}

/* Login */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.auth-card {
  background: radial-gradient(circle at top left, var(--accent-soft), transparent),
    var(--bg-card);
  border-radius: 1.75rem;
  padding: 2.5rem 2.2rem;
  box-shadow: var(--shadow-soft);
  max-width: 420px;
  width: 100%;
  border: 1px solid var(--border-subtle);
}

.app-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.45rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.topbar-center input,
.mobile-search input,
select {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid var(--border-subtle);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.topbar-center input:focus,
.mobile-search input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background: rgba(15, 23, 42, 0.09);
}

.error-text {
  color: var(--danger);
  min-height: 1.1rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.hint {
  margin-top: 1.2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Dashboard */

#dashboard {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.98));
  color: #f9fafb;
}

body.theme-light .topbar {
  background: linear-gradient(to right, #0f172a, #111827);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: radial-gradient(circle, #22c55e, #16a34a);
  box-shadow: 0 0 18px #22c55e;
}

.brand-name {
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-sub {
  font-size: 0.72rem;
  color: rgba(209, 213, 219, 0.8);
}

.topbar-center {
  flex: 1;
  max-width: 420px;
  margin: 0 1rem;
}

.topbar-center input {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
  border-color: rgba(148, 163, 184, 0.6);
  color: #e5e7eb;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stats {
  display: flex;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #e5e7eb;
}

.stats span {
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.55);
}

.theme-select {
  border-radius: 999px;
  padding-inline: 0.6rem;
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.6);
  color: #e5e7eb;
  font-size: 0.8rem;
}

/* Layout */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

/* Sidebar */

.sidebar {
  border-right: 1px solid var(--border-subtle);
  padding: 1.1rem 0.9rem 1.5rem;
  background: radial-gradient(circle at top, rgba(34, 197, 94, 0.06), transparent),
    var(--bg-card);
}

.sidebar-section + .sidebar-section {
  margin-top: 1.4rem;
}

.sidebar-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.folder-list,
.filter-list {
  list-style: none;
  margin-bottom: 0.6rem;
}

.folder-list li,
.filter-list li {
  padding: 0.4rem 0.55rem;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: all 0.15s ease;
}

.folder-list li:hover,
.filter-list li:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-main);
}

.folder-list li.active,
.filter-list li.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Main */

.main {
  padding: 1.1rem 1.4rem 2rem;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.06), transparent),
    var(--bg-soft);
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.1rem;
  margin-bottom: 1.3rem;
}

.upload-left,
.upload-right {
  background: var(--bg-card);
  padding: 1.15rem;
  border-radius: 1.1rem;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.7);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.upload-left h2,
.upload-right h2 {
  font-size: 1rem;
  margin-bottom: 0.1rem;
}

.upload-controls {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.drop-zone {
  margin-top: 0.1rem;
  padding: 1rem;
  border-radius: 0.9rem;
  border: 1px dashed rgba(148, 163, 184, 0.9);
  background: rgba(15, 23, 42, 0.12);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.08);
}

.folder-select-row {
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0.3rem 0 0.7rem;
}

.section-header h2 {
  font-size: 0.98rem;
}

/* File grid */

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.9rem;
}

.file-card {
  background: var(--bg-card);
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.8);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
  cursor: pointer;
}

.file-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-soft);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.95);
}

.file-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
}

.file-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-icon {
  width: 34px;
  height: 34px;
  border-radius: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  word-break: break-word;
}

.file-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.file-folder {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.badge.link {
  border-color: rgba(59, 130, 246, 0.9);
  color: #60a5fa;
}

.badge.image {
  border-color: rgba(34, 197, 94, 0.9);
  color: #4ade80;
}

.badge.pdf {
  border-color: rgba(248, 113, 113, 0.9);
  color: #fca5a5;
}

.badge.text {
  border-color: rgba(129, 140, 248, 0.9);
  color: #a5b4fc;
}

.file-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.file-actions button {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.3rem 0.4rem;
}

.empty-state {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Contacts */

.contacts-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 1.2rem;
}

.contacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.contacts-header input {
  max-width: 220px;
}

.contacts-table-wrapper {
  border-radius: 0.9rem;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.75);
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.contacts-table th,
.contacts-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.contacts-table th {
  text-align: left;
  background: rgba(148, 163, 184, 0.12);
  font-weight: 500;
  color: var(--text-muted);
}

.contacts-table tbody tr:last-child td {
  border-bottom: none;
}

.contact-actions {
  display: flex;
  gap: 0.3rem;
}

.contact-actions button {
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 1rem;
  padding: 1rem;
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
}

.modal-content.wide {
  max-width: 720px;
}

.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}

#preview-body img,
#preview-body iframe {
  max-width: 100%;
  border-radius: 0.8rem;
}

#preview-body iframe {
  min-height: 60vh;
}

#camera-video {
  width: 100%;
  border-radius: 0.9rem;
  background: #000;
  margin-bottom: 0.7rem;
}

.camera-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Mobile */

.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

.mobile-search {
  margin-bottom: 0.8rem;
}

.fab {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 45px rgba(34, 197, 94, 0.7);
  font-size: 1.4rem;
  cursor: pointer;
}

/* Responsive */

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .upload-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .contacts-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    width: 230px;
    transform: translateX(-110%);
    transition: transform 0.18s ease;
    z-index: 30;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding-inline: 1rem;
  }

  .topbar-center.desktop-only {
    display: none;
  }

  .stats.desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }

  .desktop-only {
    display: none;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 2rem 1.5rem;
  }
}
