:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #15171B;
  --muted: #5B6270;
  --border: #E1E4EA;
  --border-strong: #C9CED8;
  --accent: #1F5AE0;
  --accent-hover: #1747B8;
  --accent-soft: #E7EEFC;
  --danger: #C62828;
  --danger-soft: #FBE1E1;
  --ok: #1E7B45;
  --ok-soft: #DDF3E4;
  --warn-ink: #8A5A00;
  --warn-soft: #FBEFD5;
  --slate-ink: #3B4550;
  --slate-soft: #E5E9EF;
  --radius: 10px;
  --radius-sm: 7px;
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 500; font-size: 0.85em; margin-left: 0.4em; }
code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; min-width: 0; padding: 32px 40px 64px; max-width: 1240px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: #fff;
  display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 600;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.nav a.active .nav-badge { background: var(--accent); }
.app-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 16px; }
.app-card + .app-card { margin-top: 10px; }
.app-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.app-meta dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 6px 0 0; font-size: 0.9rem; }
.app-meta dt { color: var(--muted); font-weight: 600; }
.app-meta dd { margin: 0; overflow-wrap: anywhere; }
.app-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.app-actions textarea { width: 260px; min-height: 60px; font: inherit; font-weight: 500; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); resize: vertical; }
@media (max-width: 860px) { .app-card { grid-template-columns: 1fr; } .app-actions { align-items: stretch; } .app-actions textarea { width: 100%; } }
.nav-group { margin: 14px 11px 4px; font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar-user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; font-size: 0.85rem; }
.sidebar-user-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.menu-toggle { display: none; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 0.85rem; margin-bottom: 8px; color: var(--muted); }
.crumbs a { color: var(--muted); font-weight: 600; }
.crumb-sep { margin: 0 6px; color: var(--border-strong); }
.section { margin-top: 28px; }
.section-title { font-size: 0.85rem; color: var(--muted); font-weight: 700; margin-bottom: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 0.85rem; }
.btn-lg { padding: 13px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; cursor: pointer; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input:not([type]), select, textarea {
  font: inherit; font-weight: 500; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); width: 100%;
}
input:disabled { background: var(--surface-2); color: var(--muted); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { flex-direction: row; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { padding: 8px 18px; font-weight: 700; }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Flash */
.flash {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  border: 1px solid; font-weight: 600;
}
.flash button { margin-left: auto; background: none; border: 0; font-size: 1.2rem; cursor: pointer; line-height: 1; color: inherit; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #B7E1C4; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #F1B8B8; }

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 26px 20px; text-align: center;
  background: var(--surface); transition: border-color 0.12s, background 0.12s; cursor: pointer;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-idle { display: flex; flex-direction: column; gap: 4px; }
.dropzone-progress { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.bar { width: 100%; max-width: 420px; height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

/* Quota */
.quota { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 0.85rem; }
.quota .bar { width: 160px; height: 6px; }
.quota.is-full .bar span { background: var(--danger); }

/* Bulk bar */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; position: sticky; top: 12px; z-index: 5;
}
.bulk-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.35); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,0.12); }
.bulk-bar .btn-danger-text { color: #FFB4B4; }

/* Folders */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.folder-tile {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--ink); font-weight: 700;
}
.folder-tile svg { color: var(--accent); }
.folder-tile:hover { border-color: var(--border-strong); text-decoration: none; }
.folder-tile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* File tiles */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.file-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.file-tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thumb { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ext-mark { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; padding: 6px 14px; border-radius: 9px; }
.type-archive .ext-mark, .type-archive.ext-hero { background: var(--warn-soft); color: var(--warn-ink); }
.type-exec .ext-mark, .type-exec.ext-hero { background: var(--danger-soft); color: var(--danger); }
.type-schem .ext-mark, .type-schem.ext-hero { background: var(--ok-soft); color: var(--ok); }
.type-other .ext-mark, .type-other.ext-hero { background: var(--slate-soft); color: var(--slate-ink); }
.tile-meta { padding: 10px 12px 4px; display: flex; flex-direction: column; min-width: 0; }
.tile-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { display: flex; gap: 10px; font-size: 0.8rem; color: var(--muted); }
.tile-actions { display: flex; padding: 4px 8px 8px; gap: 2px; }
.select-box { position: absolute; top: 8px; left: 8px; z-index: 2; cursor: pointer; }
.select-box input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.select-box span {
  display: block; width: 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,0.92); border: 1.5px solid var(--border-strong);
  opacity: 0; transition: opacity 0.12s;
}
.file-tile:hover .select-box span, .select-box input:checked + span, .select-box input:focus-visible + span { opacity: 1; }
.select-box input:checked + span { background: var(--accent); border-color: var(--accent); }
.select-box input:checked + span::after {
  content: ''; display: block; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translate(6px, 3px) rotate(45deg);
}

.empty { padding: 44px 20px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-name { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.row-icon { color: var(--accent); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline-block; margin-left: 6px; }
.inline-actions { display: inline-flex; gap: 6px; align-items: center; }
.inline-actions select { width: auto; padding: 6px 10px; font-size: 0.85rem; }
.ext-pill, .pill {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 800;
  background: var(--slate-soft); color: var(--slate-ink);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

/* Panels */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.panel-wide { grid-column: 1 / -1; }
.key-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.key-row code { padding: 8px 12px; word-break: break-all; }
.details summary { cursor: pointer; font-weight: 700; }
.plain-list { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(21,23,27,0.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 14px; padding: 24px; width: 100%; max-width: 420px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(10px); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 9px; font-weight: 700; opacity: 0; transition: opacity 0.15s, transform 0.15s; z-index: 60; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Honeypot, kept off screen so real people never see it */
.hp { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand { margin-bottom: 8px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9rem; font-weight: 600; flex-wrap: wrap; }
.inline-note { display: flex; gap: 8px; font-size: 0.9rem; color: var(--muted); align-items: center; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.check-list li::before { content: '✓'; color: var(--ok); font-weight: 800; margin-right: 8px; }
.check-list li.bad::before { content: '✕'; color: var(--danger); }
.check-list li.bad { color: var(--danger); }

/* Public share pages */
.public-body { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 28px; }
.share-image { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 28px 48px; gap: 18px; }
.share-image-frame { max-width: 100%; }
.share-image-frame img { max-width: 100%; max-height: 74vh; border-radius: 10px; display: block; background: var(--surface); }
.share-bar {
  width: 100%; max-width: 900px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
.share-bar-meta { display: flex; flex-direction: column; min-width: 0; }
.share-bar-meta strong { overflow-wrap: anywhere; }
.share-file { flex: 1; display: grid; place-items: center; padding: 20px 28px 60px; }
.share-card { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 40px 36px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ext-hero { font-size: 3.4rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; padding: 18px 28px; border-radius: 16px; margin-bottom: 14px; }
.share-kind { color: var(--muted); font-weight: 700; }
.share-name { font-size: 1.35rem; overflow-wrap: anywhere; }
.share-buttons { margin-top: 20px; justify-content: center; }
.share-warning { margin-top: 14px; font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.error-page { max-width: 480px; margin: 60px auto; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Responsive */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform 0.18s; width: 260px; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(21,23,27,0.4); }
  .main { padding: 20px 16px 60px; }
  .menu-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); margin-bottom: 16px; cursor: pointer; }
  .panels, .grid-2 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .row-actions { white-space: normal; }
  .public-header { padding: 14px 16px; }
  .share-image { padding: 8px 12px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
