:root {
  --bg-0:        #0c0e12;
  --bg-1:        #121419;
  --bg-2:        #181b22;
  --bg-3:        #1f232c;
  --bg-hover:    #232831;
  --line:        #262a35;
  --line-soft:   #1c2029;
  --fg:          #e7e9ee;
  --fg-soft:     #c8ccd6;
  --muted:       #8a91a0;
  --muted-2:     #5f6675;
  --accent:      #c9a86a;
  --accent-2:    #a98a4f;
  --accent-soft: rgba(201,168,106,.14);
  --ok:          #4ea877;
  --warn:        #d8a93c;
  --err:         #d35a4a;
  --radius:      4px;
  --radius-lg:   8px;
  --mono:        "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --serif:       Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg-0);
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv01", "tnum";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button { font: inherit; cursor: pointer; }

input, select, textarea {
  font: inherit;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  outline: none;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted-2); }

label { display: block; margin: 14px 0; }
label > span {
  display: block; margin-bottom: 5px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
label > input, label > select, label > textarea { width: 100%; }

.muted    { color: var(--muted); }
.small    { font-size: 12px; }
.error, .auth-error {
  color: var(--err);
  background: rgba(211,90,74,.08);
  border: 1px solid rgba(211,90,74,.25);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.linkbtn {
  background: transparent; border: 0; color: var(--accent); padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
  font-size: inherit;
}

.btn {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-weight: 500;
  letter-spacing: .01em;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: #2f3441; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--bg-0);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-2); }
.btn.danger {
  color: var(--err); border-color: rgba(211,90,74,.4); background: rgba(211,90,74,.08);
}
.btn.danger:hover:not(:disabled) { background: rgba(211,90,74,.18); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { display: block; width: 100%; padding: 11px; font-size: 14px; }

.iconbtn {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 28px; height: 28px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
}
.iconbtn:hover { background: var(--bg-3); color: var(--fg); }
.iconbtn.danger:hover { color: var(--err); }
.iconbtn svg { width: 16px; height: 16px; }

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(201,168,106,.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(201,168,106,.03) 0%, transparent 50%),
    var(--bg-0);
  padding: 24px;
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 440px;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-mark {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--bg-0);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(201,168,106,.2), 0 0 30px rgba(201,168,106,.08);
}
.auth-org {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: .03em;
  color: var(--fg);
}
.auth-sub {
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.auth-card h1 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 8px;
}
.auth-card > p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.auth-alt { margin-top: 18px; text-align: center; }
.auth-foot {
  text-align: center;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--muted);
}
.auth-foot a { color: var(--muted); }
.auth-foot a:hover { color: var(--accent); }
.code-input {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  padding: 14px;
}

.dropbox {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropbox.over { border-color: var(--accent); background: var(--accent-soft); }
.dropbox-icon {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  position: relative;
}
.dropbox-icon::before, .dropbox-icon::after {
  content: ''; position: absolute; background: var(--muted);
}
.dropbox-icon::before { left: 50%; top: 10px; width: 1.5px; height: 18px; transform: translateX(-50%); }
.dropbox-icon::after  { left: 50%; top: 14px; width: 12px; height: 1.5px; transform: translate(-50%, -50%) rotate(-45deg); transform-origin: left; }
.dropbox p { margin: 6px 0 0; color: var(--muted); }

.upqueue { margin-top: 22px; }

body.app {
  display: flex; flex-direction: column;
  height: 100vh;
  background: var(--bg-0);
}

.topbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex: 0 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: .02em;
  color: var(--fg);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-0);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--serif);
}
.brand-name { line-height: 1; }
.brand-sub  { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
}
.user-chip .role-badge {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 256px;
  flex: 0 0 256px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 18px 0;
}
.side-section { padding: 0 16px 14px; }
.side-section h3 {
  margin: 12px 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 600;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--fg-soft);
  font-size: 13px;
  transition: background .1s, color .1s;
}
.side-link:hover { background: var(--bg-2); color: var(--fg); }
.side-link.active { background: var(--accent-soft); color: var(--accent); }
.side-link svg { width: 15px; height: 15px; flex: 0 0 auto; }
.side-link .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-link .lock { color: var(--accent); }

.tree { padding: 0 8px; }
.tree-node { cursor: pointer; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--fg-soft);
  transition: background .08s;
}
.tree-row:hover { background: var(--bg-2); }
.tree-row.active { background: var(--accent-soft); color: var(--accent); }
.tree-row svg { width: 14px; height: 14px; flex: 0 0 auto; opacity: .8; }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .caret { width: 10px; height: 10px; transition: transform .15s; cursor: pointer; }
.tree-row .caret.open { transform: rotate(90deg); }
.tree-row .caret.hidden { visibility: hidden; }
.tree-children { padding-left: 14px; border-left: 1px solid var(--line-soft); margin-left: 11px; }

.content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-0);
  min-width: 0;
}

.crumbs {
  display: flex; align-items: center;
  padding: 14px 26px;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.crumbs a { color: var(--muted); cursor: pointer; }
.crumbs a:hover { color: var(--fg); text-decoration: none; }
.crumbs .sep { color: var(--muted-2); }
.crumbs .current { color: var(--fg); }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.search {
  flex: 0 1 360px;
  position: relative;
}
.search input {
  width: 100%;
  padding-left: 36px;
  background: var(--bg-1);
}
.search svg {
  position: absolute;
  left: 11px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.toolbar-spacer { flex: 1; }
.toolbar-actions { display: flex; gap: 8px; }

.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 26px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.bulk-bar .count { color: var(--accent); font-weight: 600; }
.bulk-bar .actions { margin-left: auto; display: flex; gap: 6px; }

.listing-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.list-head {
  display: grid;
  grid-template-columns: 36px 28px 1fr 120px 90px 170px 130px;
  gap: 10px;
  padding: 10px 26px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 5;
  cursor: default;
}
.list-head .col { cursor: pointer; user-select: none; }
.list-head .col:hover { color: var(--fg); }
.list-head .col.sorted { color: var(--accent); }
.list-head .col .arrow { font-size: 9px; margin-left: 2px; }

.row {
  display: grid;
  grid-template-columns: 36px 28px 1fr 120px 90px 170px 130px;
  gap: 10px;
  align-items: center;
  padding: 9px 26px;
  border-bottom: 1px solid var(--line-soft);
  cursor: default;
  transition: background .08s;
  user-select: none;
}
.row:hover { background: var(--bg-1); }
.row.selected { background: var(--accent-soft); }
.row.folder { cursor: pointer; }
.row .checkbox { display: flex; align-items: center; justify-content: center; }
.row .checkbox input { width: 14px; height: 14px; cursor: pointer; }
.row .ic {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.row.folder .ic { color: var(--accent); }
.row .ic svg { width: 18px; height: 18px; }
.row .name {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .name .meta-sub { font-size: 11px; color: var(--muted); margin-top: 1px; display: block; }
.row .type-col, .row .size-col, .row .date-col, .row .owner-col {
  color: var(--muted);
  font-size: 12px;
}
.row .actions {
  display: flex; gap: 2px; justify-content: flex-end;
  opacity: 0;
  transition: opacity .1s;
}
.row:hover .actions, .row.selected .actions { opacity: 1; }

.empty {
  padding: 80px 30px;
  text-align: center;
  color: var(--muted);
}
.empty h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--fg-soft);
  margin: 0 0 6px;
}
.locked {
  padding: 80px 30px;
  text-align: center;
}
.locked .lock-icon {
  width: 48px; height: 48px;
  margin: 0 auto 18px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.locked h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
}

[hidden] { display: none !important; }

.marquee {
  position: fixed;
  pointer-events: none;
  z-index: 90;
  background: rgba(201, 168, 106, 0.10);
  border: 1px solid var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 0 24px rgba(201,168,106,.18);
  will-change: transform, width, height;
}

.marquee-active * { cursor: crosshair !important; }
.marquee-active .row, .marquee-active .tile {
  transition: background .08s, border-color .08s, box-shadow .08s;
}

.listing-wrap { user-select: none; }
.row .name, .tile .tile-name { user-select: text; }

.row.drop-target, .tile.drop-target, .tree-row.drop-target, .crumbs .drop-target {
  background: rgba(78, 168, 119, .14) !important;
  box-shadow: inset 0 0 0 1px var(--ok);
  border-radius: 4px;
}
.row[draggable="true"], .tile[draggable="true"] { cursor: grab; }
.row[draggable="true"]:active, .tile[draggable="true"]:active { cursor: grabbing; }

.drag-ghost {
  position: fixed;
  top: -1000px; left: -1000px;
  pointer-events: none;
  background: var(--bg-1);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 14px 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--fg);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: 280px;
  white-space: nowrap;
  z-index: 9999;
}
.drag-ghost svg { width: 14px; height: 14px; color: var(--accent); flex: 0 0 auto; }
.drag-ghost .count {
  background: var(--accent);
  color: var(--bg-0);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.drag-ghost .lbl { overflow: hidden; text-overflow: ellipsis; }

.dragging { opacity: .45; }

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.view-toggle { display: flex; gap: 4px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.view-toggle button {
  background: transparent; border: 0; color: var(--muted);
  width: 28px; height: 26px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .12s, color .12s;
}
.view-toggle button:hover { color: var(--fg); }
.view-toggle button.active { background: var(--bg-3); color: var(--accent); }
.view-toggle svg { width: 14px; height: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  padding: 18px 26px;
}
.tile {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .04s;
  position: relative;
  user-select: none;
}
.tile:hover { border-color: var(--line); }
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .tile-thumb {
  aspect-ratio: 4/3;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
}
.tile .tile-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.tile .tile-thumb img.thumb-xls,
.row .ic img.thumb-xls {
  object-position: top left;
}
.tile .tile-thumb svg {
  width: 38%; height: 38%;
  color: var(--muted);
}
.tile.folder .tile-thumb svg { color: var(--accent); }
.tile .tile-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 18px; height: 18px;
  background: rgba(15,17,21,.85);
  border: 1px solid var(--line);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity .12s;
  cursor: pointer;
  z-index: 2;
}
.tile:hover .tile-check, .tile.selected .tile-check { opacity: 1; }
.tile .tile-check input { width: 12px; height: 12px; margin: 0; cursor: pointer; }
.tile .tile-actions {
  position: absolute;
  top: 6px; right: 6px;
  display: flex; gap: 2px;
  background: rgba(15,17,21,.8);
  border-radius: var(--radius);
  padding: 2px;
  opacity: 0;
  transition: opacity .1s;
  z-index: 2;
}
.tile:hover .tile-actions { opacity: 1; }
.tile .tile-actions .iconbtn { width: 24px; height: 24px; }
.tile .tile-actions .iconbtn svg { width: 13px; height: 13px; }
.tile .tile-body {
  padding: 9px 12px 11px;
}
.tile .tile-name {
  font-size: 12.5px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.tile .tile-meta {
  font-size: 10.5px;
  color: var(--muted);
}

.row .ic .thumb-img {
  width: 24px; height: 24px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
}

.drop-overlay {
  position: absolute;
  inset: 6px;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--accent);
  pointer-events: none;
  z-index: 4;
}

.uploads, .upqueue {
  width: 380px;
}
.uploads {
  position: fixed;
  bottom: 18px; right: 18px;
  max-height: 60vh; overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  z-index: 60;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.uploads:empty { display: none; }
.uphead {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
}
.upitem {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.upitem:last-child { border-bottom: none; }
.upname {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar, .upbar {
  height: 3px;
  background: var(--bg-3);
  border-radius: 2px;
  margin: 7px 0;
  overflow: hidden;
}
.bar-fill, .upbar-fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .12s linear;
}
.upitem.done .bar-fill, .upitem.done .upbar-fill { background: var(--ok); }
.upitem.err  .bar-fill, .upitem.err  .upbar-fill,
.upitem.error .upbar-fill { background: var(--err); }
.upmeta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.modal {
  position: fixed; inset: 0;
  background: rgba(8,9,12,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-body {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
}
.modal-body.wide { max-width: 880px; }
.modal-body h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}
table.data th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: var(--bg-2);
}
table.data tr:hover td { background: var(--bg-1); }

.tabs {
  display: flex;
  gap: 0;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: transparent; border: 0;
  padding: 10px 18px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color .1s, border-color .1s;
}
.tab:hover { color: var(--fg-soft); }
.tab.active { color: var(--accent); border-color: var(--accent); }
.tabpane { padding: 4px 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.kpi .value {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--fg);
}

.usage-bar {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.usage-bar .fill {
  height: 100%;
  background: var(--accent);
}
.usage-bar .fill.warn { background: var(--warn); }
.usage-bar .fill.err  { background: var(--err); }

#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { color: #ffd1cc; border-color: rgba(211,90,74,.4); }
#toast.ok  { color: #b6e9c8; border-color: rgba(78,168,119,.4); }

.context-menu {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 0;
  min-width: 180px;
  z-index: 150;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  font-size: 13px;
}
.context-menu .item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  color: var(--fg-soft);
}
.context-menu .item:hover { background: var(--bg-3); color: var(--fg); }
.context-menu .item.danger { color: var(--err); }
.context-menu .item.danger:hover { background: rgba(211,90,74,.15); }
.context-menu .item svg { width: 14px; height: 14px; opacity: .7; }
.context-menu .sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

.preview-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; flex-direction: column;
  z-index: 130;
}
.preview-head {
  display: flex; align-items: center;
  padding: 14px 22px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.preview-head .name { flex: 1; font-family: var(--serif); font-size: 15px; }
.preview-body {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  padding: 24px;
}
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: var(--fg);
  padding: 8px;
  margin-right: 4px;
  cursor: pointer;
  border-radius: var(--radius);
}
.menu-toggle:hover { background: var(--bg-2); }
.menu-toggle svg { width: 20px; height: 20px; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 48;
  opacity: 0;
  transition: opacity .2s;
}
.sidebar-backdrop.open { display: block; opacity: 1; }

@media (max-width: 820px) {
  body { font-size: 13.5px; }

  .topbar { height: 52px; padding: 0 12px; gap: 8px; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .brand-mark { width: 26px; height: 26px; font-size: 12px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }
  .topbar-actions { gap: 6px; margin-left: auto; }

  #newFolderBtn span, #uploadBtn span { display: none; }
  #newFolderBtn, #uploadBtn { padding: 7px 10px; font-size: 12px; }
  .user-chip { padding: 4px 10px; gap: 6px; }
  .user-chip .who, .user-chip .role-badge { display: none; }
  .user-chip::after {
    content: '';
    width: 24px; height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: inline-block;
  }

  .sidebar {
    position: fixed;
    top: 52px; left: 0; bottom: 0;
    width: 280px;
    z-index: 49;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.5);
    flex: none;
  }
  .sidebar.open { transform: translateX(0); }

  .crumbs {
    padding: 10px 14px;
    font-size: 12.5px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .crumbs::-webkit-scrollbar { display: none; }

  .toolbar { padding: 10px 12px; gap: 8px; }
  .search { flex: 1; max-width: none; }
  .search input { padding-left: 34px; padding-right: 10px; }
  .view-toggle { flex: 0 0 auto; }

  .list-head { display: none; }
  .row {
    padding: 12px 14px;
    grid-template-columns: 28px 36px 1fr 80px 36px;
    gap: 8px;
    min-height: 56px;
  }
  .row .checkbox input { width: 18px; height: 18px; }
  .row .ic { width: 32px; height: 32px; }
  .row .ic svg { width: 22px; height: 22px; }
  .row .ic .thumb-img { width: 32px; height: 32px; border-radius: 4px; }
  .row .name { font-size: 14px; }
  .row .type-col, .row .date-col, .row .owner-col { display: none; }
  .row .size-col { font-size: 11px; text-align: right; }
  .row .actions { gap: 0; opacity: 1; }
  .row .actions .iconbtn { display: none; }
  .row .actions .iconbtn:last-child { display: inline-flex; width: 36px; height: 36px; }
  .row .actions .iconbtn svg { width: 18px; height: 18px; }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }
  .tile .tile-thumb { aspect-ratio: 1; }
  .tile .tile-check { opacity: 1; }
  .tile .tile-actions { opacity: 1; padding: 3px; }
  .tile .tile-actions .iconbtn { width: 28px; height: 28px; }
  .tile .tile-name { font-size: 13px; }
  .tile .tile-meta { font-size: 11px; }

  .bulk-bar {
    position: sticky;
    bottom: 0;
    padding: 10px 12px;
    flex-wrap: wrap;
    z-index: 10;
    background: var(--bg-2);
    border-top: 1px solid var(--line);
  }
  .bulk-bar .actions { width: 100%; justify-content: flex-end; margin-left: 0; }

  .modal { padding: 0; align-items: stretch; }
  .modal-body {
    max-width: none;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    padding: 22px 18px;
    overflow-y: auto;
  }
  .modal-body.wide { max-width: none; }
  .modal-actions { position: sticky; bottom: 0; background: var(--bg-1); margin: 16px -18px -22px; padding: 14px 18px; }

  .uploads {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    max-height: 50vh;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  }

  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 8px 10px; }

  .preview-head { padding: 10px 12px; }
  .preview-body { padding: 10px; }

  .auth-card { padding: 28px 22px; max-width: none; }

  .dropbox { padding: 22px 14px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 18px; }
}

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding: 0 8px; }
  #newFolderBtn { display: none; }
  #uploadBtn { padding: 7px 12px; }
}

@media (hover: none) and (pointer: coarse) {
  .row .actions { opacity: 1; }
  .tile .tile-check, .tile .tile-actions { opacity: 1; }
  .row, .tile { -webkit-tap-highlight-color: rgba(201,168,106,.2); }
  .marquee-active { display: none; }
}
