/* ==========================================================================
   Workspace demo — styles
   Desktop first, usable on tablet.
   ========================================================================== */

/* ---------- 1. Tokens & reset ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #18202b;
  --ink-2: #3d4756;
  --muted: #6b7480;
  --line: #e5e8ec;
  --line-2: #eef0f3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee2e2;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 12px 28px -12px rgba(16, 24, 40, .25), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .35);
  --sidebar-w: 248px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ta-r { text-align: right; }

code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--line-2);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- 2. Buttons & controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface-2); border-color: #d7dbe1; }
.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px -8px rgba(79, 70, 229, .9);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  flex: none;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- 3. Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.field input, .field select, .field textarea {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-weight: 400;
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.form-error {
  margin: 2px 0 0;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  min-width: 210px;
}
.search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.seg button.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-count { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.seg button.is-active .seg-count { color: var(--accent); }

.select-wrap select {
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7480' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}

/* ---------- 4. Auth screen ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 20px;
  background:
    radial-gradient(1000px 500px at 82% -10%, #e0e7ff 0%, transparent 60%),
    radial-gradient(800px 420px at -5% 110%, #dcfce7 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 445px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 30px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  box-shadow: 0 10px 20px -10px rgba(79, 70, 229, .9);
  flex: none;
}
.brand-mark-sm { width: 36px; height: 36px; border-radius: 10px; }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: .01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.auth-lead { margin: 16px 0 18px; color: var(--muted); font-size: 13.5px; }
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--line-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-tab.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.demo-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.demo-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 10px;
}
.demo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-row .btn { flex: 1; justify-content: center; }
.demo-hint { margin-top: 9px; font-size: 12.5px; color: var(--muted); }
.auth-note { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.auth-build { margin-top: 10px; font-size: 11.5px; letter-spacing: .02em; }

/* ---------- 5. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  background: #141b2d;
  color: #c7d0dd;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 22px;
  min-height: 0;
}
.brand-sidebar { color: #fff; padding: 0 6px; }
.brand-sidebar .brand-name { color: #fff; }
.brand-sidebar .brand-sub { color: #8b95a7; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: #c7d0dd;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.is-active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(79, 70, 229, .95);
}
.nav-label { flex: 1; text-align: left; font-weight: 600; }
.nav-badge {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
}
.user-card { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 6px 8px; border-radius: 10px; text-align: left; transition: background .12s; }
.user-card:hover { background: rgba(255, 255, 255, .08); }
.user-card.is-active { background: rgba(255, 255, 255, .14); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13.5px;
  flex: none;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: #94a3b8; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .icon-btn { color: #c7d0dd; }
.sidebar-foot .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.topbar h1 { font-size: 18px; }
.topbar p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.demo-pill {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #ddd9ff;
  padding: 4px 9px;
  border-radius: 99px;
}

/* ---------- 6. Views, toolbar, crumbs ---------- */
.view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* content must keep its natural height and let the view scroll instead of
   flex-shrinking overflow-hidden panels (which clips rows on small screens) */
.view > * { flex: none; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-height: 30px; }
.crumb {
  border: 0;
  background: transparent;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
}
button.crumb:hover { background: var(--line-2); color: var(--ink); }
.crumb.is-current { color: var(--ink); cursor: default; }
.crumb-sep { color: #c3c9d2; font-size: 12px; }
.view-foot { display: flex; font-size: 12.5px; }

.notice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid #ddd9ff;
  background: var(--accent-soft);
  color: #3730a3;
  border-radius: 12px;
  font-size: 13px;
}
.notice svg { width: 16px; height: 16px; flex: none; }
.trash-soon { color: var(--amber); font-weight: 600; }

/* ---------- 7. Panels & file list ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 96px 132px 200px;
  gap: 10px;
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
}
.list-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 96px 132px 200px;
  gap: 10px;
  padding: 8px 16px;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
#panel-drive.mode-search .list-head,
#panel-drive.mode-search .list-row { grid-template-columns: minmax(220px, 1fr) minmax(140px, 220px) 200px; }

.row-name {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  color: inherit;
}
.fname {
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell:has(.chip) { display: inline-flex; align-items: center; gap: 8px; }

.ftype {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--line-2);
  color: var(--muted);
}
.ftype svg { width: 17px; height: 17px; }
.ftype-folder { background: var(--accent-soft); color: var(--accent); }
.ftype-image { background: var(--violet-soft); color: var(--violet); }
.ftype-pdf { background: var(--danger-soft); color: var(--danger); }
.ftype-audio { background: #fce7f3; color: #be185d; }
.ftype-video { background: var(--blue-soft); color: var(--blue); }
.ftype-code { background: #e0f2fe; color: #0369a1; }
.ftype-text { background: var(--green-soft); color: var(--green); }
.ftype-archive { background: var(--amber-soft); color: var(--amber); }
.ftype-file { background: var(--line-2); color: var(--muted); }
.ftype-task { background: #ccfbf1; color: #0f766e; }
.ftype-note { background: var(--amber-soft); color: var(--amber); }

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--line-2);
  padding: 2px 7px;
  border-radius: 6px;
  line-height: 1.5;
  flex: none;
}
.chip-banned { background: var(--danger-soft); color: #b91c1c; }
.avatar-banned { filter: grayscale(1); opacity: .65; }

.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity .12s; }
.list-row:hover .row-actions,
.list-row:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* ---------- 8. Tasks (3-column board) ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.board-col {
  display: flex;
  flex-direction: column;
  min-height: 260px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.board-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.board-head h3 { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.col-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.col-todo .col-dot { background: #94a3b8; }
.col-inprogress .col-dot { background: var(--blue); }
.col-done .col-dot { background: var(--green); }
.board-count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--line-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}
.board-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  min-height: 90px;
  transition: background .12s;
}
.board-body.drop-target {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
  border-radius: 10px;
}
.board-empty { padding: 20px 10px; text-align: center; color: var(--muted); font-size: 12.5px; border: 1px dashed var(--line); border-radius: 10px; }
.board-body .empty { padding: 22px 10px; }
.board-body .empty svg { width: 26px; height: 26px; }

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: border-color .12s, box-shadow .12s, opacity .12s;
}
.task-card:hover { border-color: #c9cede; box-shadow: var(--shadow-md); }
.task-card.dragging { opacity: .5; }
.task-card.prio-high { border-left-color: var(--danger); }
.task-card.prio-medium { border-left-color: var(--amber); }
.task-card.prio-low { border-left-color: var(--blue); }
.task-card-head { display: flex; align-items: flex-start; gap: 7px; }
.prio-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.task-card.prio-high .prio-dot { background: var(--danger); }
.task-card.prio-medium .prio-dot { background: var(--amber); }
.task-card.prio-low .prio-dot { background: var(--blue); }
.task-card-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; line-height: 1.45; }
.task-card-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.task-card:hover .task-card-actions,
.task-card:focus-within .task-card-actions { opacity: 1; }
@media (hover: none) { .task-card-actions { opacity: 1; } }
.task-card-desc {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.task-card-time { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.task-card .status-select { height: 24px; font-size: 11.5px; padding: 0 22px 0 9px; }
#col-done .task-card { opacity: .8; }
#col-done .task-card:hover { opacity: 1; }
.board-col .pager { border-top: 1px solid var(--line-2); background: transparent; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--line-2);
  color: var(--ink-2);
}
.pill svg { width: 13px; height: 13px; flex: none; }
.pill-due-overdue { background: var(--danger-soft); color: #b91c1c; }
.pill-due-today { background: var(--amber-soft); color: var(--amber); }
.pill-prio-high { background: var(--danger-soft); color: #b91c1c; }
.pill-prio-medium { background: var(--amber-soft); color: var(--amber); }
.pill-prio-low { background: var(--blue-soft); color: var(--blue); }

select.status-select {
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0 26px 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7480' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

/* ---------- 9. Notes ---------- */
.view-notes { padding: 0; gap: 0; overflow: hidden; }
.view-notes > .notes-layout { flex: 1; height: 100%; min-height: 0; }
.notes-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }
.note-doc > .empty { margin: auto; }
.notes-pane {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
.notes-pane-head {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--line-2);
}
.notes-pane-head .search { min-width: 0; }
.notes-list { overflow: auto; flex: 1; }
.note-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.note-item:hover { background: var(--surface-2); }
.note-item.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.note-item-title {
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-item-snippet {
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-item-time { font-size: 11.5px; color: #9aa2ae; }

.note-doc {
  overflow: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 26px clamp(28px, 6vw, 96px) 60px;
  background: var(--bg);
}
.note-head { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 780px; margin: 0 auto; }
.note-title-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 24px;
  font-weight: 650;
  color: var(--ink);
  padding: 4px 0;
}
.note-title-input::placeholder { color: #b9c0cb; }
.note-title-input:focus { outline: none; border-bottom: 2px solid var(--accent); }
.note-meta { width: 100%; max-width: 780px; margin: 6px auto 0; font-size: 12.5px; }
.note-back { display: none; }
.note-body {
  width: 100%;
  max-width: 780px;
  margin: 14px auto 0;
  flex: 1;
  min-height: 340px;
  border: 0;
  background: transparent;
  resize: none;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-2);
}
.note-body:focus { outline: none; }
.note-preview {
  width: 100%;
  max-width: 780px;
  margin: 14px auto 0;
  flex: 1;
}
.note-status { width: 100%; max-width: 780px; margin: 12px auto 0; font-size: 12.5px; }

/* ---------- 10. Modal / viewer / editor ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: 0; } }
.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  animation: pop .16s ease-out;
  position: relative;
  padding: 0;
}
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1080px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-2);
}
.modal-head h3 { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line-2);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}
.modal-error { margin: 0 18px 16px; }
.confirm-text { color: var(--ink-2); }
.confirm-text strong { color: var(--ink); }

.viewer-media { display: grid; place-items: center; background: #0b1220; border-radius: 12px; overflow: hidden; min-height: 200px; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 66vh; display: block; }
.viewer-media audio { width: min(560px, 100%); margin: 0 24px 34px; }
.audio-art {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  display: grid;
  place-items: center;
  color: #fff;
  margin: 40px 0 26px;
}
.audio-art svg { width: 46px; height: 46px; }
.viewer-frame { width: 100%; height: 66vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.viewer-pre {
  margin: 0;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 64vh;
  overflow: auto;
}
.viewer-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; gap: 8px; }
.viewer-none {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 46px 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}
.viewer-none svg { width: 34px; height: 34px; color: #b6bdc9; }
.viewer-none h3 { font-size: 15px; color: var(--ink); }
.viewer-none p { font-size: 13px; max-width: 340px; }

.editor-textarea {
  width: 100%;
  min-height: 420px;
  max-height: 58vh;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  background: #fbfcfe;
  display: block;
}
.editor-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  max-height: 58vh;
  overflow: auto;
}
.editor-foot { margin-top: 8px; font-size: 12px; }
.editor-seg { margin-bottom: 12px; }

/* ---------- 11. Toasts & empty states ---------- */
.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 350px;
}
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }
.toast {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  padding: 11px 14px;
  font-size: 13px;
  animation: slide .18s ease-out;
}
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--blue); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 7px;
  padding: 54px 24px;
  color: var(--muted);
}
.empty svg { width: 38px; height: 38px; color: #b6bdc9; margin-bottom: 4px; }
.empty h3 { font-size: 15px; color: var(--ink); }
.empty p { font-size: 13px; max-width: 360px; }
.empty-actions { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; justify-content: center; }

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  padding: 12px;
  text-align: center;
  background: var(--danger-soft);
  color: #991b1b;
  font-weight: 600;
}

/* ---------- 12. Markdown ---------- */
.markdown {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-2);
  word-wrap: break-word;
}
.markdown > :first-child { margin-top: 0; }
.markdown h1 { font-size: 24px; margin: 26px 0 12px; color: var(--ink); }
.markdown h2 { font-size: 19px; margin: 24px 0 10px; color: var(--ink); }
.markdown h3 { font-size: 16px; margin: 20px 0 8px; color: var(--ink); }
.markdown h4, .markdown h5, .markdown h6 { font-size: 14.5px; margin: 18px 0 8px; color: var(--ink); }
.markdown p { margin: 0 0 13px; }
.markdown ul, .markdown ol { margin: 0 0 13px; padding-left: 22px; }
.markdown li { margin: 4px 0; }
.markdown blockquote {
  margin: 0 0 13px;
  padding: 9px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
}
.markdown pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 12px;
  overflow: auto;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
}
.markdown pre code { background: none; color: inherit; padding: 0; }
.markdown a { color: var(--accent); text-decoration: none; font-weight: 600; }
.markdown a:hover { text-decoration: underline; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.markdown img { border-radius: 12px; border: 1px solid var(--line); }
.markdown del { color: var(--muted); }

/* ---------- 13. Admin: nav section, users, logs, settings ---------- */
.nav-section {
  margin: 14px 0 4px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #7e8aa0;
}
.nav-more { display: none; }
.nav-sheet, .nav-sheet-backdrop { display: none; }
.nav-sheet-title {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #7e8aa0;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.25; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 0; }

.users-head, #users-list .list-row { grid-template-columns: minmax(180px, 1.3fr) 130px minmax(150px, 1fr) 230px; }
.user-cell { cursor: default; }
.user-cell-text { display: flex; flex-direction: column; min-width: 0; }
.user-cell-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.user-cell-email { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#users-list .row-actions { opacity: 1; }
.icon-btn:disabled { opacity: .38; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }

.logs-head, #logs-list .list-row { grid-template-columns: minmax(240px, 1fr) 170px 90px 100px; }
.log-main { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 6px; flex: none; }
.log-row.log-warn .dot { background: var(--amber); }
.log-text { min-width: 0; }
.log-action { font-weight: 600; font-size: 13.5px; }
.log-detail { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-module { text-transform: capitalize; }

.settings-tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.settings-tabs button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.settings-tabs button:hover { color: var(--ink); }
.settings-tabs button.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-panels { max-width: 820px; }
.settings-panel { display: flex; flex-direction: column; gap: 14px; }
.card { padding: 18px; border-radius: 14px; }
.card h3 { font-size: 15px; }
.card-sub { font-size: 12.5px; margin-top: 4px; line-height: 1.55; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line-2); cursor: pointer; }
.card .switch-row:first-of-type { border-top: 0; padding-top: 6px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.switch-text .muted { font-size: 12.5px; line-height: 1.45; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 42px; height: 24px; border-radius: 99px; background: #d3d8e0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.storage-list { display: flex; flex-direction: column; margin-top: 8px; }
.storage-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.storage-row:first-child { border-top: 0; }
.storage-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-size { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.storage-total { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 12px; border-top: 2px solid var(--line); font-size: 13.5px; }
.storage-note { margin-top: 10px; font-size: 12.5px; line-height: 1.55; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.card-danger { border-color: #f0c8c8; }

.access-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  margin-top: 12px;
}
.access-ok { color: var(--green); font-weight: 700; }
.access-blocked { color: var(--danger); font-weight: 700; }
.whitelist-editor { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.whitelist-editor input {
  flex: 1;
  min-width: 170px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.whitelist-editor input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.whitelist-list { display: flex; flex-direction: column; margin-top: 10px; }
.ip-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.ip-row code { padding: 2px 7px; }
.ip-row .icon-btn { margin-left: auto; }
.whitelist-empty { padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.access-hint { margin-top: 10px; font-size: 12.5px; line-height: 1.55; }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.kv:first-child { border-top: 0; }
.kv > span { color: var(--muted); flex: none; }
.kv > strong { font-weight: 600; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-wrap { white-space: normal; word-break: break-word; }

.profile-wrap { max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.profile-head-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.profile-head-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-head-text .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 13e. Access gate (simulated) ---------- */
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.access-gate-card {
  max-width: 430px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.access-gate-icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  margin-bottom: 14px;
}
.access-gate-icon svg { width: 26px; height: 26px; }
.access-gate-card h2 { font-size: 19px; margin-bottom: 8px; }
.access-gate-card p { font-size: 13.5px; color: var(--ink-2); margin-bottom: 10px; }
.access-gate-card .btn { margin-top: 12px; }

body.compact .list-row { padding: 4px 16px; }
body.compact .task-card { padding: 7px 10px; }
body.compact .note-item { padding: 9px 16px; }

/* ---------- 13b. Pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px;
  border-top: 1px solid var(--line-2);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.pager-info { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; align-items: center; gap: 4px; }
.pg-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: background .12s, border-color .12s, color .12s;
}
.pg-btn svg { width: 14px; height: 14px; }
.pg-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: #dcd9ff; color: var(--accent); }
.pg-btn.is-current { background: var(--accent); border-color: transparent; color: #fff; }
.pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-gap { padding: 0 3px; color: var(--muted); font-size: 12.5px; }
.pager-sm { padding: 8px 12px; }
.pager-sm .pg-btn { min-width: 27px; height: 27px; font-size: 12px; }
.pager-sm .pager-info { font-size: 12px; }

/* ---------- 13c. Drive: selection & grid view ---------- */
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell .row-name { flex: 1; min-width: 0; }
.row-check { display: grid; place-items: center; padding: 2px; flex: none; cursor: pointer; }
.row-check input, .tile-check input, .list-head input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.list-head .name-cell { gap: 8px; }
.list-head .name-cell input { width: 14px; height: 14px; }
.list-row.is-selected { background: var(--accent-soft); }

.sel-toolbar {
  background: var(--accent-soft);
  border: 1px solid #dcd9ff;
  border-radius: 12px;
  padding: 8px 12px;
}
.sel-count { font-weight: 700; color: #3730a3; font-size: 13.5px; }
.seg-icons button { padding: 6px 9px; }
.seg-icons svg { width: 15px; height: 15px; }

#panel-drive.is-grid .list-head { display: none; }
#panel-drive.is-grid .list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding: 16px;
}
#panel-drive.is-grid .empty { grid-column: 1 / -1; }
.tile {
  position: relative;
  display: flex;
  min-height: 196px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.tile:hover { border-color: #c9cede; box-shadow: var(--shadow-sm); }
.tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tile-open {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.tile-thumb { flex: 1; display: grid; place-items: center; min-height: 132px; }
.tile-thumb svg { width: 30px; height: 30px; }
.tile-thumb-folder { background: var(--accent-soft); color: var(--accent); }
.tile-thumb-image { background: var(--violet-soft); color: var(--violet); }
.tile-thumb-pdf { background: var(--danger-soft); color: var(--danger); }
.tile-thumb-audio { background: #fce7f3; color: #be185d; }
.tile-thumb-video { background: var(--blue-soft); color: var(--blue); }
.tile-thumb-code { background: #e0f2fe; color: #0369a1; }
.tile-thumb-text { background: var(--green-soft); color: var(--green); }
.tile-thumb-archive { background: var(--amber-soft); color: var(--amber); }
.tile-thumb-file { background: var(--line-2); color: var(--muted); }
.tile-thumb-img {
  flex: 1;
  min-height: 132px;
  background-color: #0b1220;
  background-size: cover;
  background-position: center;
  transition: transform .25s ease;
}
.tile:hover .tile-thumb-img { transform: scale(1.04); }
.tile-info { display: flex; flex-direction: column; gap: 1px; padding: 8px 11px; border-top: 1px solid var(--line-2); min-width: 0; }
.tile-name { font-weight: 600; font-size: 12.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: 11.3px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-info-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 0;
  padding-top: 22px;
  background: linear-gradient(transparent, rgba(15, 23, 42, .8) 45%);
}
.tile-info-overlay .tile-name { color: #fff; }
.tile-info-overlay .tile-meta { color: #cbd5e1; }
.tile-thumb-img { background-color: #0b1220; }

.upload-overall { margin-bottom: 14px; }
.upload-overall-top, .upload-file-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 13px; }
.upload-list { display: flex; flex-direction: column; gap: 12px; }
.upload-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; }
.upload-preview {
  width: 96px; height: 72px; border-radius: 10px; overflow: hidden;
  display: grid; place-items: center; background: var(--line-2); color: var(--muted);
}
.upload-preview img, .upload-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-preview svg { width: 28px; height: 28px; }
.upload-preview pre { margin: 0; padding: 6px; font-size: 9px; line-height: 1.3; white-space: pre-wrap; overflow: hidden; max-height: 72px; }
.upload-name { font-weight: 650; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 8px; }
.upload-bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }
.upload-bar.is-done > span { background: var(--green); }
.upload-bar.is-error > span { background: var(--danger); }
.upload-state { margin-top: 4px; font-size: 12px; color: var(--muted); }
.upload-state.is-done { color: var(--green); font-weight: 650; }
.upload-state.is-error { color: var(--danger); }
.tile-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .12s;
  cursor: pointer;
}
.tile:hover .tile-check,
.tile:focus-within .tile-check,
.tile.is-selected .tile-check,
#panel-drive.selecting .tile-check { opacity: 1; }
@media (hover: none) { .tile-check { opacity: 1; } }

/* ---------- 13d. Expenses ---------- */
.month-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.month-label { min-width: 132px; text-align: center; font-weight: 600; font-size: 13.5px; }
.delta { font-weight: 700; font-size: 17px; }
.delta-up { color: var(--danger); }
.delta-down { color: var(--green); }

.expense-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.cat-row { display: grid; grid-template-columns: 150px minmax(60px, 1fr) 130px; gap: 10px; align-items: center; padding: 7px 0; }
.cat-row + .cat-row { border-top: 1px solid var(--line-2); }
.cat-name { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; min-width: 0; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cat-bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.cat-fill { display: block; height: 100%; border-radius: 99px; }
.cat-amt { text-align: right; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cat-chip { display: inline-flex; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; }

.budget-top { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.budget-spent { font-size: 20px; font-weight: 700; }
.budget-bar { height: 10px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin: 10px 0 8px; }
.budget-fill { display: block; height: 100%; border-radius: 99px; transition: width .2s; }
.budget-ok { background: var(--green); }
.budget-warn { background: var(--amber); }
.budget-over { background: var(--danger); }
.budget-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; flex-wrap: wrap; }
.budget-pct { font-weight: 700; }
.budget-pct.budget-ok { color: var(--green); background: transparent; }
.budget-pct.budget-warn { color: var(--amber); background: transparent; }
.budget-pct.budget-over { color: var(--danger); background: transparent; }
.budget-over-text { color: var(--danger); font-weight: 600; }
#expense-budget .btn { margin-top: 14px; }
#expense-budget > p { margin-top: 6px; font-size: 13px; }

.exp-head, #expense-list .list-row { grid-template-columns: 92px minmax(160px, 1fr) 150px 110px 90px; }
.exp-desc { color: var(--ink); font-weight: 500; }
.exp-amount { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ftype-expense { background: var(--green-soft); color: var(--green); }

/* ---------- 13f. Grab (URL → Drive) ---------- */
.grab-hero {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  border-color: #dcd9ff;
  background: linear-gradient(180deg, #fbfbff 0%, var(--surface) 100%);
}
.grab-hero-text h2 { font-size: 16px; }
.grab-hero-text p { font-size: 12.5px; margin-top: 4px; max-width: 760px; line-height: 1.55; }
.grab-input-row { display: flex; gap: 9px; align-items: stretch; }
.grab-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.grab-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grab-input svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.grab-input input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 42px; font-size: 13.5px; }
.grab-hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--line);
  padding-top: 4px;
}
.grab-hero .switch-row { border-top: 0; padding: 4px 0; flex: 1; min-width: 300px; }
.grab-hero .switch-text strong { font-size: 12.8px; }
.grab-hero .switch-text .muted { font-size: 11.8px; }
.grab-cap { font-size: 11.8px; flex: none; }

.ftype-grab { background: #ecfeff; color: #0e7490; }
.grab-head, #grab-list .list-row { grid-template-columns: minmax(240px, 1fr) 190px 90px 96px 172px; }
.grab-name { cursor: default; }
.grab-name .user-cell-name { min-width: 0; }
.grab-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grab-url-text { font-family: var(--mono); font-size: 11.5px; }
#grab-list .row-actions { opacity: 1; }
.icon-btn.grab-accent:hover { background: var(--accent-soft); color: var(--accent); }

.grab-status { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.grab-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  line-height: 1.6;
}
.grab-chip-queued { background: var(--line-2); color: var(--muted); }
.grab-chip-down { background: var(--blue-soft); color: var(--blue); }
.grab-chip-done { background: var(--green-soft); color: var(--green); }
.grab-chip-moved { background: var(--accent-soft); color: var(--accent); }
.grab-chip-error { background: var(--danger-soft); color: #b91c1c; }
.chip.grab-sim { background: #e0f2fe; color: #0369a1; }
.grab-progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 132px; }
.grab-progress { flex: 1; height: 7px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.grab-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6366f1, #0ea5e9);
  transition: width .18s linear;
}
.grab-fill.is-indet { width: 40%; animation: grab-slide 1s ease-in-out infinite alternate; }
@keyframes grab-slide { from { margin-left: -12%; } to { margin-left: 72%; } }
.grab-pct { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }
.grab-error-text { font-size: 11.5px; color: #b91c1c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.grab-modal-note { margin-top: 12px; font-size: 12.5px; line-height: 1.55; }

/* ---------- 13g. Clean (server storage checkup) ---------- */
.clean-hero {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-color: #dcd9ff;
  background: linear-gradient(180deg, #fbfbff 0%, var(--surface) 100%);
}
.clean-hero-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 12px; }
.clean-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.clean-panel-head h3 { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.clean-panel-head .muted { font-size: 12px; }
.clean-panel-actions { margin-left: auto; display: flex; gap: 8px; }
.clean-head, .clean-row { grid-template-columns: minmax(240px, 1fr) 110px 150px 100px; }
.clean-row .row-actions { opacity: 1; }
.clean-name { cursor: default; }
.clean-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--muted);
  font-size: 12.5px;
}
.clean-clear svg { width: 16px; height: 16px; color: var(--green); flex: none; }

/* ---------- 14. Responsive ---------- */
@media (max-width: 1120px) {
  :root { --sidebar-w: 74px; }
  .sidebar { align-items: center; padding: 18px 10px; }
  .brand-sidebar { padding: 0; }
  .brand-text, .nav-label, .user-meta { display: none; }
  .nav { width: 100%; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    min-width: 17px;
    padding: 1px 5px;
    font-size: 10px;
  }
  .sidebar-foot { width: 100%; justify-content: center; padding: 8px; }
  .nav-section {
    margin: 10px 6px 6px;
    padding: 0;
    font-size: 0;
    border-top: 1px solid rgba(255, 255, 255, .14);
  }
  .list-head, .list-row { grid-template-columns: minmax(200px, 1fr) 84px 116px 150px; }
  #panel-drive.mode-search .list-head,
  #panel-drive.mode-search .list-row { grid-template-columns: minmax(200px, 1fr) minmax(120px, 200px) 150px; }
  .act-edit, .act-move { display: none; }
  .grab-head, #grab-list .list-row { grid-template-columns: minmax(180px, 1fr) 168px 76px 84px 150px; }
}

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }

  /* --- footer: bottom nav with safe-area support --- */
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    flex-direction: row;
    height: calc(60px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    z-index: 50;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .brand-sidebar, .sidebar-foot, .nav-section { display: none; }
  .nav > .nav-item[data-view="users"],
  .nav > .nav-item[data-view="logs"],
  .nav > .nav-item[data-view="settings"] { display: none; }
  .nav .nav-more { display: flex; }
  .nav { flex-direction: row; justify-content: center; gap: 4px; width: 100%; overflow: visible; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; padding: 5px 6px; font-size: 11px; min-width: 0; }
  .nav-label { display: block; text-align: center; flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-badge { top: 2px; left: calc(50% + 8px); right: auto; }

  /* admin sheet above the bottom nav */
  body.sheet-open .nav-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0 0 calc(60px + env(safe-area-inset-bottom)) 0;
    background: rgba(15, 23, 42, .45);
    z-index: 55;
    animation: fade .14s ease-out;
  }
  body.sheet-open .nav-sheet {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    z-index: 56;
    background: #141b2d;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 16px;
    padding: 8px;
    box-shadow: var(--shadow-lg);
    animation: slide .18s ease-out;
  }

  /* --- header: compact topbar --- */
  .topbar {
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    gap: 10px;
  }
  .topbar-titles { min-width: 0; }
  .topbar h1 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar p { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .view { padding: 14px 14px 26px; }
  .view-notes { padding: 0; }

  .list-head, .list-row { grid-template-columns: minmax(0, 1fr) auto; }
  .list-head > :nth-child(2), .list-head > :nth-child(3),
  .list-row > :nth-child(2), .list-row > :nth-child(3) { display: none; }
  #panel-drive.mode-search .list-head,
  #panel-drive.mode-search .list-row { grid-template-columns: minmax(0, 1fr) auto; }
  #panel-drive.mode-search .list-head > :nth-child(2),
  #panel-drive.mode-search .list-row > :nth-child(2) { display: block; }

  .users-head, #users-list .list-row { grid-template-columns: minmax(0, 1fr) auto; }
  .logs-head, #logs-list .list-row { grid-template-columns: minmax(0, 1fr) 84px; }
  #panel-trash .list-head, #panel-trash .list-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  #panel-trash .list-head > :nth-child(3),
  #panel-trash .list-row > :nth-child(3) { display: block; }

  .grab-input-row { flex-direction: column; }
  .grab-input-row .btn { justify-content: center; }
  .grab-hero .switch-row { min-width: 0; }
  .grab-hero-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .grab-cap { align-self: flex-start; }
  #panel-grab .list-head, #panel-grab .list-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  #panel-grab .list-head > :nth-child(2) { display: block; }
  #panel-grab .list-row > :nth-child(2) { display: flex; }
  #panel-grab .list-head > :nth-child(4), #panel-grab .list-row > :nth-child(4) { display: none; }
  .grab-progress-wrap { min-width: 96px; }
  .grab-error-text { max-width: 140px; }

  #panel-drive.is-grid .list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 10px;
  }
  .board { grid-template-columns: 1fr; }
  .expense-grid { grid-template-columns: 1fr; }
  .cat-row { grid-template-columns: 110px minmax(40px, 1fr) 104px; }
  #expense-list .list-head, #expense-list .list-row { grid-template-columns: 78px minmax(0, 1fr) 92px auto; }
  #expense-list .list-head > :nth-child(2),
  #expense-list .list-row > :nth-child(2) { display: block; }
  #expense-list .list-head > :nth-child(3),
  #expense-list .list-row > :nth-child(3) { display: none; }
  .tile { min-height: 164px; }
  .tile-thumb, .tile-thumb-img { min-height: 104px; }
  .sel-toolbar { padding: 8px 10px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .notes-layout { grid-template-columns: 1fr; }
  .note-doc { display: none; }
  .notes-layout.editing .notes-pane { display: none; }
  .notes-layout.editing .note-doc { display: flex; padding: 16px 16px 80px; }
  .note-back { display: inline-grid; }
  .note-head { flex-wrap: wrap; row-gap: 8px; }
  .note-title-input { font-size: 22px; }
  #note-delete { order: 3; }
  #note-mode { flex: 1 1 100%; order: 5; }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .modal-backdrop { padding: 14px; align-items: flex-end; }
  .modal { max-height: calc(100vh - 40px); }
  .toasts { right: 12px; left: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); max-width: none; }
}

@media (max-width: 560px) {
  .auth-card { padding: 22px; }
  .topbar-actions .btn { display: none; }
  .topbar p, .demo-pill { display: none; }
  #grab-list [data-grab-act="open-url"] { display: none; }
  .grab-error-text { max-width: 100px; }
  .grab-url-text { font-size: 11px; }
}
