:root {
  --bg: #0f1115;
  --panel: #161a21;
  --panel-2: #1c212a;
  --line: #262c37;
  --text: #e6e9ef;
  --muted: #8a93a6;
  --accent: #6d8cff;
  --accent-2: #5674ee;
  --danger: #ef5a5a;
  --ok: #3ecf8e;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: #232935; border-color: #323a48; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; font-size: 18px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); stroke: none; }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); cursor: pointer; }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 0%, #1b2440 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; padding: 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-card .brand { justify-content: center; margin-bottom: 6px; font-size: 18px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card .btn { justify-content: center; padding: 10px; }
.error { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }

/* Barre du haut */
#app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 20px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; padding: 0 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; background: transparent; flex: 1; padding: 8px 0; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.user span { color: var(--text); font-weight: 550; text-transform: capitalize; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 15px; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 4px 7px; border-radius: 6px; cursor: pointer; }
.crumbs a:hover { color: var(--text); background: var(--panel-2); }
.crumbs a:last-child { color: var(--text); font-weight: 600; }
.crumbs a.drop-over { background: rgba(109,140,255,.2); color: var(--text); }
.crumbs .sep { color: #4a5263; }
.sel-count { color: var(--muted); margin-right: 4px; }

/* Liste */
.list-wrap { flex: 1; overflow: auto; padding: 0 22px 30px; }
.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: default; }
.list tbody tr:hover td { background: #1a1f28; }
.list tbody tr.selected td { background: rgba(109,140,255,.12); }
.list tbody tr.active td { background: rgba(109,140,255,.18); }
.list tbody tr.active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.list tbody tr.drop-over td { background: rgba(109,140,255,.22); }
.c-check { width: 40px; }
.c-size { width: 100px; }
.c-date { width: 150px; }
.c-by { width: 110px; }
.c-menu { width: 46px; text-align: right; }
.list td.c-size, .list td.c-date, .list td.c-by { color: var(--muted); font-size: 13px; }
.list td.c-by { text-transform: capitalize; }
.name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name a { color: var(--text); text-decoration: none; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name a:hover { color: var(--accent); }
.name .sub { color: var(--muted); font-size: 12px; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ficon { width: 20px; height: 20px; }
.ficon.folder { fill: #e8b54a; stroke: none; }
.ficon.zip { color: #c08cff; }
.ficon.text { color: #6dc7ff; }
.ficon.image { color: #3ecf8e; }
.ficon.other { color: var(--muted); }

.empty { text-align: center; padding: 60px 20px; color: var(--text); }
.empty svg { width: 40px; height: 40px; color: var(--muted); }
.empty p { margin: 8px 0 0; }

/* Menu contextuel */
.menu { position: fixed; z-index: 50; min-width: 190px; padding: 5px; background: var(--panel-2); border: 1px solid #323a48; border-radius: 9px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: 0; background: transparent; color: var(--text); border-radius: 6px; cursor: pointer; text-align: left; }
.menu button:hover { background: #2a3140; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* Glisser-déposer */
.dropzone { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(15,17,21,.75); pointer-events: none; }
.dropzone div { padding: 30px 46px; border: 2px dashed var(--accent); border-radius: 16px; background: var(--panel); font-size: 17px; }

/* Envois */
.uploads { position: fixed; right: 20px; bottom: 20px; z-index: 30; width: 360px; max-height: 50vh; display: flex; flex-direction: column; background: var(--panel-2); border: 1px solid #323a48; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.45); overflow: hidden; }
.uploads-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
#uploadsList { overflow: auto; }
.up-item { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.up-item:last-child { border-bottom: 0; }
.up-name { display: flex; justify-content: space-between; gap: 10px; }
.up-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 4px; margin-top: 6px; background: var(--line); border-radius: 4px; overflow: hidden; }
.up-bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.up-item.done .up-bar div { background: var(--ok); }
.up-item.failed .up-bar div { background: var(--danger); }
.up-item.failed .up-name span:last-child { color: var(--danger); }

/* Notifications */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 9px; background: var(--panel-2); border: 1px solid #323a48; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pop .18s ease-out; }
.toast.err { border-color: rgba(239,90,90,.5); color: #ffb1b1; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* Visionneuse */
.viewer { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.viewer-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.viewer-title span:first-child { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; overflow: auto; display: flex; }
.editor { flex: 1; display: flex; min-height: 0; }
.editor textarea { flex: 1; resize: none; border: 0; border-radius: 0; padding: 18px 22px; background: var(--bg); font: 13.5px/1.6 "JetBrains Mono", Consolas, "Cascadia Code", monospace; tab-size: 4; white-space: pre; }
.editor textarea.wrap { white-space: pre-wrap; }
.preview-img { margin: auto; max-width: 100%; max-height: 100%; padding: 20px; object-fit: contain; }
.zip-view { flex: 1; padding: 20px 22px; }
.zip-view table { max-width: 1000px; }
.info-view { margin: auto; text-align: center; color: var(--muted); }
.info-view p { margin: 6px 0; }

/* Dialogues */
.overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(5,7,10,.65); }
.dialog { width: 100%; max-width: 420px; display: grid; gap: 14px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.dialog h2 { margin: 0; font-size: 17px; }
.dialog p { margin: 0; color: var(--muted); white-space: pre-line; }
.dialog p:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .toolbar, .list-wrap { padding-left: 12px; padding-right: 12px; }
  .c-date, .c-by { display: none; }
  .actions .btn { padding: 7px 9px; }
}

.info-view .ficon { width: 48px; height: 48px; }
