:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e2e6ee;
  --text: #1a2233;
  --text-soft: #667085;
  --primary: #3b6cf6;
  --primary-hover: #2f59d4;
  --danger: #e5484d;
  --danger-hover: #c93b40;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #171d2b;
    --surface-2: #1e2534;
    --border: #2a3242;
    --text: #e6eaf2;
    --text-soft: #94a0b8;
    --primary: #4b7bff;
    --primary-hover: #6a92ff;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 6px; }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 30px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 42px; }
.login-card h1 { margin: 8px 0 2px; font-size: 22px; }
.login-sub { color: var(--text-soft); margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.login-error { color: var(--danger); margin-top: 12px; font-size: 13px; min-height: 18px; }

/* ---------- Layout ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.whoami { color: var(--text-soft); font-size: 13px; }

.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; }
.breadcrumb a { color: var(--primary); cursor: pointer; text-decoration: none; padding: 3px 6px; border-radius: 6px; }
.breadcrumb a:hover { background: var(--surface-2); }
.breadcrumb span.sep { color: var(--text-soft); }
.breadcrumb .current { font-weight: 600; padding: 3px 6px; }

/* ---------- Bulk bar ---------- */
.bulkbar {
  display: flex; align-items: center; gap: 12px;
  margin: 0 18px 8px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
}
.bulkbar .btn { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,.28); }
.bulkbar .btn-danger { background: var(--danger); }
.bulk-count { font-weight: 600; }
.bulk-actions { display: flex; gap: 6px; }
.bulkbar .btn-ghost { margin-left: auto; }

/* ---------- Table ---------- */
.content {
  flex: 1;
  overflow: auto;
  margin: 0 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}
.filetable { width: 100%; border-collapse: collapse; }
.filetable thead th {
  position: sticky; top: 0;
  background: var(--surface);
  text-align: left;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.filetable tbody td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.filetable tbody tr:hover { background: var(--surface-2); }
.col-check { width: 36px; text-align: center; }
.col-size { width: 110px; color: var(--text-soft); }
.col-date { width: 170px; color: var(--text-soft); }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.name-cell { display: flex; align-items: center; gap: 9px; cursor: default; }
.name-cell .icon { font-size: 18px; flex-shrink: 0; }
.name-cell.folder { cursor: pointer; }
.name-cell.folder .fname { font-weight: 600; }
.name-cell .fname { word-break: break-all; }
.name-cell a.fname { color: var(--text); text-decoration: none; }
.name-cell a.fname:hover { color: var(--primary); text-decoration: underline; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: 6px; color: var(--text-soft);
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.sub { color: var(--text-soft); font-size: 12px; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-soft); }

/* ---------- Dropzone ---------- */
.content.dragging { outline: 2px dashed var(--primary); outline-offset: -8px; }
.drop-hint {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(59,108,246,.08);
  font-size: 18px; font-weight: 600; color: var(--primary);
  pointer-events: none;
}
.content.dragging .drop-hint { display: flex; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,15,25,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 22px;
  width: 100%; max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal h3 { margin: 0 0 12px; }
.modal-text { color: var(--text-soft); margin: 0 0 14px; word-break: break-word; }
.modal-input {
  width: 100%; padding: 10px 12px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 14px;
}
.modal-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 16px; border-radius: 8px; box-shadow: var(--shadow);
  min-width: 220px; max-width: 340px; animation: slidein .2s;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: #12b76a; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Progress ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: transparent; z-index: 70; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

@media (max-width: 640px) {
  .col-date { display: none; }
  .toolbar-actions .btn { padding: 8px 10px; }
}
