*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0c0c0e;
  --surface:     #141416;
  --surface-2:   #1c1c1f;
  --surface-3:   #232326;
  --border:      #28282c;
  --border-2:    #323236;
  --text:        #e2e2e5;
  --text-muted:  #6b6b74;
  --text-dim:    #9898a3;
  --accent:      #6366f1;
  --accent-h:    #5254cc;
  --danger:      #e5534b;
  --danger-h:    #c0392b;
  --green:       #3fb950;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0 20px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
}

.sidebar-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
  padding: 0 20px 28px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
  flex: 1;
}

.nav-item {
  padding: 9px 12px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 500; }

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.storage-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.storage-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.storage-pct {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Main ── */
.main { margin-left: 230px; flex: 1; padding: 36px 44px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}

.page-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

/* ── Table ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 11px 18px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 13px 18px;
  color: var(--text);
  font-size: 13.5px;
  vertical-align: middle;
}

.file-name { font-weight: 500; }
.empty { text-align: center; color: var(--text-muted); padding: 40px !important; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.2px;
}

.id-chip {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12.5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  color: var(--text-dim);
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  border: none;
  outline: none;
  font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-download {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  margin-right: 6px;
}
.btn-download:hover { background: var(--surface-3); }

.btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 7px 10px;
}
.btn-delete:hover { background: rgba(229,83,75,0.08); border-color: var(--danger); }

/* ── Upload page ── */
.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 660px;
}

.drop-zone {
  border: 1.5px dashed var(--border-2);
  border-radius: 10px;
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 20px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,0.04);
}

.drop-icon { color: var(--text-muted); margin-bottom: 14px; }
.drop-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.drop-sub { font-size: 13px; color: var(--text-muted); }

.folder-name-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.folder-name-row label { font-size: 12.5px; color: var(--text-muted); }
.folder-name-row input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.folder-name-row input:focus { border-color: var(--accent); }

.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 14px;
}
.file-row-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80%;
}
.file-row-size { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.btn-upload { width: 100%; padding: 10px; font-size: 14px; }

.progress-wrap { margin-top: 16px; }
.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.2s ease;
}
.progress-label { font-size: 12.5px; color: var(--text-muted); }

.result-card {
  margin-top: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.result-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--green); }
.result-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.result-label { font-size: 12px; color: var(--text-muted); min-width: 90px; }
.result-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.result-link:hover { text-decoration: underline; }
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.result-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}

.auth-brand {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 28px;
  letter-spacing: -0.3px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.auth-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-group input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus { border-color: var(--accent); }

.form-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

.btn-full { width: 100%; padding: 10px; font-size: 14px; }

.auth-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Sidebar user ── */
.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.btn-link:hover { color: var(--danger); }

/* ── Owner controls on file page ── */
.owner-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 14px;
}

.owner-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}