:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --panel-2: #f0f0ec;
  --text: #1c1d1f;
  --muted: #6b6e73;
  --border: #e2e2dc;
  --accent: #115596;
  --accent-ink: #ffffff;
  --accent-soft: #e5eef8;
  --ok: #2f7a22;
  --ok-soft: #e7f4e2;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn-soft: #fff4d6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --panel: #1c1d20;
    --panel-2: #24262a;
    --text: #e8e8e6;
    --muted: #9a9ca1;
    --border: #2e3035;
    --accent: #6aa6e8;
    --accent-ink: #0b1522;
    --accent-soft: #1a2a3d;
    --ok: #86d06f;
    --ok-soft: #1f3320;
    --danger: #f2877e;
    --danger-soft: #3a2220;
    --warn-soft: #3a3220;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
input[type=text], input[type=password], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: 12.5px; }
.error { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 8px; margin-top: 12px; font-size: 13.5px; }

/* login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand .logo { width: 34px; height: 34px; display: grid; place-items: center; flex: none; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-card .brand { flex-direction: column; align-items: flex-start; gap: 12px; font-size: 20px; }
.login-card .brand .logo { width: 64px; height: 64px; }
.login-card h1 { font-size: 22px; margin: 24px 0 4px; letter-spacing: -.02em; }
.login-card .btn.primary { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }

/* app shell */
.topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 13px; margin-right: 4px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.badge.read { background: var(--panel-2); color: var(--muted); }
.badge.upload { background: var(--warn-soft); color: #8a6100; }
.badge.full { background: var(--ok-soft); color: var(--ok); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) { .badge.upload { color: #e6c06a; } }
.badge.off { background: var(--danger-soft); color: var(--danger); }

.layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100% - 56px); }
.sidebar { border-right: 1px solid var(--border); padding: 16px 10px; background: var(--panel); }
.sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 10px 8px; }
.folder-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; }
.folder-link:hover { background: var(--panel-2); }
.folder-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder-link .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.main { padding: 20px 24px 40px; min-width: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 15px; }
.crumbs button { border: 0; background: none; padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.crumbs button:hover { background: var(--panel-2); color: var(--text); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.row-actions { text-align: right; white-space: nowrap; }
.entry { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; color: var(--text); word-break: break-word; }
.entry:hover .label { text-decoration: underline; }
.icon { width: 18px; height: 18px; flex: none; }
.icon.dir { color: var(--accent); }
.icon.file { color: var(--muted); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.dropzone { position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent); z-index: 50; pointer-events: none; }
.progress { margin-bottom: 14px; padding: 12px 14px; }
.bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* dialogs */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow); width: min(480px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 22px 22px 18px; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* admin */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs button.active { color: var(--accent); border-color: var(--accent); }
.admin-main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 48px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 19px; }
.grant-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; padding: 2px; }
.grant-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.grant-row select { padding: 6px 8px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 14px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 10px; min-width: 0; }
  .sidebar .folder-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .sidebar h3 { display: none; }
  .folder-link { width: auto; flex: none; }
  .main { padding: 14px 16px 32px; }
  .hide-sm { display: none; }
  th, td { padding: 9px 10px; }
  .topbar { padding: 0 16px; }
  .who { display: none; }
}

/* share links */
.share-target { font-weight: 600; color: var(--text); margin: 2px 0 10px; word-break: break-word; }
.copy-row { display: flex; gap: 8px; margin-top: 14px; }
.copy-row input { flex: 1; min-width: 0; }
.share-main { max-width: 900px; margin: 0 auto; padding: 32px 16px 48px; }
.share-card { max-width: 480px; margin: 24px auto 0; padding: 28px; }
.share-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; word-break: break-word; }
.share-card .buttons { display: flex; justify-content: flex-end; margin-top: 18px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin: 0 0 14px; }
.share-file { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px; }
.share-file .big-icon, .big-icon { width: 40px; height: 40px; flex: none; }
.btn.big { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
#file-expiry { text-align: center; margin: 12px 0 0; }
td .entry { display: inline-flex; }
