:root{
  --bg: #f6f8fb;
  --panel:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --line:#e5e7eb;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --radius: 12px;
  --btn:#2563eb;
  --btnText:#fff;
  --btnSecondary:#f3f4f6;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:var(--bg);
  color:var(--text);
}

.topbar{
  position:sticky;
  top:0;
  z-index:20;
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  background:var(--panel);
  border-bottom:1px solid var(--line);
}

.brand{ display:flex; align-items:center; gap:10px; font-weight:700; }
.brandMark{
  width:26px; height:26px; border-radius:8px;
  background:linear-gradient(135deg, #60a5fa, #2563eb);
  box-shadow: 0 6px 16px rgba(37,99,235,.25);
}
.brandText{ letter-spacing:.2px; }

.auth{ display:flex; gap:8px; align-items:center; }
.auth input{
  height:34px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:10px;
  padding:0 10px;
  outline:none;
}
.auth input:focus{ border-color:#93c5fd; box-shadow:0 0 0 4px rgba(147,197,253,.35); }

button{
  height:34px;
  border-radius:10px;
  border:1px solid transparent;
  background:var(--btn);
  color:var(--btnText);
  padding:0 12px;
  cursor:pointer;
}
button.secondary{
  background:var(--btnSecondary);
  color:var(--text);
  border-color:var(--line);
}
button:disabled{ opacity:.5; cursor:not-allowed; }

.iconbtn{
  width:34px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:var(--btnSecondary);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:10px;
}

.layout{
  display:grid;
  grid-template-columns: 260px 1fr;
  gap:16px;
  padding:16px;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:12px;
  min-height: calc(100vh - 90px);
}

.sideHeader{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.sidebar h3{ margin:6px 6px 10px; font-size:14px; color:var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:.06em; }

.clientList .client{
  padding:10px 10px;
  border-radius:10px;
  cursor:pointer;
  border:1px solid transparent;
}
.clientList .client:hover{ background:#f9fafb; border-color:var(--line); }
.clientList .client.active{ background:#eff6ff; border-color:#bfdbfe; }

.content{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:12px;
  min-height: calc(100vh - 90px);
}

.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  padding:10px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfdff;
}

.navGroup, .uploadGroup{ display:flex; gap:8px; align-items:center; }
.searchGroup{ flex:1; min-width:220px; display:flex; justify-content:center; }
.search{
  width:min(560px, 100%);
  height:34px;
  border-radius:999px;
  border:1px solid var(--line);
  padding:0 14px;
  outline:none;
  background:#fff;
}
.search:focus{ border-color:#93c5fd; box-shadow:0 0 0 4px rgba(147,197,253,.35); }

.uploadGroup input[type="file"]{
  height:34px;
}
.chk{ display:flex; align-items:center; gap:6px; color:var(--muted); font-size:13px; user-select:none; }

.contextRow{ padding:10px 6px 6px; }
.context{
  font-size:13px;
  color:var(--muted);
}

.breadcrumb{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center;
  padding:8px 6px 10px;
  color:var(--muted);
  font-size:13px;
}
.breadcrumb a{
  color:var(--text);
  text-decoration:none;
  padding:4px 8px;
  border-radius:10px;
}
.breadcrumb a:hover{ background:#f3f4f6; }
.breadcrumb .sep{ color:#9ca3af; }

.tableWrap{ border:1px solid var(--line); border-radius:12px; overflow:hidden; }
.filetable{ width:100%; border-collapse:separate; border-spacing:0; }
.filetable thead th{
  position:sticky;
  top:0;
  background:#fff;
  z-index:5;
  text-align:left;
  font-size:12px;
  letter-spacing:.04em;
  color:var(--muted);
  text-transform:uppercase;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
}
.filetable tbody td{
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.filetable tbody tr:hover{ background:#f9fafb; }
.rowname{ font-weight:600; cursor:pointer; }
.actions{ white-space:nowrap; }
.actions button{ height:30px; padding:0 10px; border-radius:10px; }

.status{
  margin-top:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px dashed var(--line);
  color:var(--muted);
  min-height: 42px;
  display:flex;
  align-items:center;
}

/* Modal */
.modal-backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.35);
  display:block;
  z-index:100;
}
.modal{
  position:fixed;
  left:50%; top:50%;
  transform:translate(-50%,-50%);
  width:min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow: 0 18px 48px rgba(0,0,0,.2);
  display:block;
  z-index:101;
  overflow:hidden;
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
}
.modal-title{ font-weight:700; }
.modal-body{
  padding:12px 14px;
  overflow:auto;
  max-height: calc(100vh - 160px);
}
.modal-footer{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:12px 14px;
  border-top:1px solid var(--line);
  background:#fafafa;
}
.btnlink{
  display:inline-flex;
  align-items:center;
  padding:0 12px;
  height:34px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  text-decoration:none;
}

@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ min-height:auto; }
  .searchGroup{ justify-content:stretch; }
}

.hidden{display:none !important;}


/* --- UI refinements (Drive-like) --- */
.client { padding: 10px 12px; border-radius: 12px; }
.client + .client { margin-top: 10px; }
.client .titleRow{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.client .nameRow{ display:flex; align-items:baseline; gap:8px; min-width:0; }
.client .pcname{ font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.client .lastseen{ font-size:12px; color:#6b7280; white-space:nowrap; }
.client .statusDot{ width:8px; height:8px; border-radius:999px; flex:0 0 8px; }
.client.online .pcname{ color:#15803d; } /* green */
.client.offline .pcname{ color:#b91c1c; } /* red */
.client.online .statusDot{ background:#16a34a; }
.client.offline .statusDot{ background:#ef4444; }

.shares{ margin-top:8px; display:flex; flex-direction:column; gap:6px; }
.shareBtn{ display:flex; justify-content:space-between; align-items:center; padding:8px 10px; border-radius:10px; border:1px solid #e5e7eb; background:#fff; cursor:pointer; }
.shareBtn:hover{ background:#f8fafc; }
.shareBtn .shareName{ font-weight:600; }
.shareBtn .shareKey{ font-size:12px; color:#6b7280; }

/* Auth: hide input boxes after login */
.userLabel{ font-size:13px; color:#374151; padding:6px 10px; border:1px solid #e5e7eb; border-radius:999px; background:#fff; }

/* Sorting */
th.sortable{ cursor:pointer; user-select:none; white-space:nowrap; }
th.sortable:hover{ background:#f8fafc; }
.sortind{ font-size:11px; color:#6b7280; margin-left:4px; }


/* =========================
   Bulk actions + selection
   ========================= */
.colsel{ width:44px; text-align:center; }
.filetable td.colselcell{ text-align:center; }

.bulkbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin:10px 0 6px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#f9fafb;
}
.bulkcount{ color:var(--muted); font-size:13px; }
.bulkright{ display:flex; gap:8px; flex-wrap:wrap; }

button.danger{
  background:#dc2626;
  color:#fff;
  border:1px solid #b91c1c;
}
button.danger:hover{ filter:brightness(.98); }

/* =========================
   View toggle + grid view
   ========================= */
.viewGroup{ display:flex; gap:8px; }

.gridWrap{ margin-top:10px; }
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap:12px;
}
.card{
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px;
  background:var(--panel);
  box-shadow: var(--shadow);
  cursor:pointer;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.card:hover{ border-color:#cbd5e1; }
.cardTop{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:8px;
}
.cardChk{ margin-top:2px; }
.thumb{
  width:100%;
  aspect-ratio: 4 / 3;
  border-radius:12px;
  background:#f3f4f6;
  border:1px solid var(--line);
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
}
.thumb img, .thumb video{
  width:100%;
  height:100%;
  object-fit:contain;
}
.cardName{
  font-weight:600;
  font-size:13px;
  line-height:1.2;
  word-break:break-word;
}
.cardMeta{
  color:var(--muted);
  font-size:12px;
  display:flex;
  justify-content:space-between;
  gap:10px;
}

/* =========================
   Drag & drop upload overlay
   ========================= */
.tableWrap{ position:relative; }
.dropOverlay{
  position:absolute;
  inset:8px;
  border-radius:14px;
  border:2px dashed #93c5fd;
  background:rgba(239,246,255,.8);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
  color:#1d4ed8;
  z-index:20;
  pointer-events:none;
}

/* =========================
   Upload queue / progress
   ========================= */
.uploadQueue{
  margin:10px 0 6px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  background:#ffffff;
}
.upItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 0;
  border-bottom:1px solid var(--line);
}
.upItem:last-child{ border-bottom:none; }
.upLeft{ min-width:0; flex:1; }
.upName{ font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.upSub{ font-size:12px; color:var(--muted); margin-top:2px; }
.upRight{ width:220px; }
.progress{
  height:10px;
  border-radius:999px;
  background:#f3f4f6;
  border:1px solid var(--line);
  overflow:hidden;
}
.progress > div{
  height:100%;
  width:0%;
  background:#2563eb;
}

/* =========================
   Preview sizing (no crop)
   ========================= */
.preview-img{
  display:block;
  max-width:100%;
  max-height: calc(100vh - 180px);
  width:auto;
  height:auto;
  object-fit:contain;
  margin:0 auto;
}
.preview-video{
  display:block;
  max-width:100%;
  max-height: calc(100vh - 180px);
  width:100%;
  height:auto;
  margin:0 auto;
}
.preview-text{
  max-height: calc(100vh - 180px);
}

/* =========================
   Client folder buttons – restore contrast
   ========================= */

.clientFolders button,
.clientFolders .secondary{
  color: #1f2937;           /* dark gray text */
  background: #f3f4f6;      /* light background */
  border: 1px solid #d1d5db;
}

.clientFolders button:hover,
.clientFolders .secondary:hover{
  background: #e5e7eb;
}


/* =========================
   Client online / offline indicator – restore
   ========================= */

.clientStatus{
  display:inline-block;
  width:10px;
  height:10px;
  border-radius:50%;
  margin-right:6px;
  vertical-align:middle;
}

.clientStatus.online{
  background:#22c55e; /* green */
}

.clientStatus.offline{
  background:#ef4444; /* red */
}



/* =========================
   Share / folder buttons under PC name
   ========================= */

.shareBtn{
  color:#000000 !important;      /* force black text */
  background:#f3f4f6;
  border:1px solid #d1d5db;
}

.shareBtn:hover{
  background:#e5e7eb;
}


/* =========================
   Client card + reset button
   ========================= */
.clientCard{
  padding:10px 10px;
  border-radius:10px;
  cursor:pointer;
  border:1px solid transparent;
}
.clientCard:hover{ background:#f9fafb; border-color:var(--line); }
.clientCard.active{ background:#eff6ff; border-color:#bfdbfe; }

.clientTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
.clientName{ font-weight:700; }

button.danger{
  background:#dc2626;
  color:#fff;
}
button.danger:hover{ filter:brightness(0.95); }
button.clientReset{
  height:26px;
  padding:0 10px;
  border-radius:10px;
  font-size:12px;
}

