/* =====================================================================
   MyCloud — giao diện
   Màu dùng qua biến (token) để đổi Sáng/Tối ở một chỗ. Màu biểu đồ và màu
   loại file là bảng màu đã kiểm tra (độ tương phản, mù màu) cho cả 2 chế độ.
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f4f6f9; --card: #ffffff; --sidebar: #ffffff; --raised: #ffffff;
  --fg: #0f172a; --fg-2: #475569; --muted: #64748b; --faint: #94a3b8;
  --line: #e6e9ef; --line-strong: #d5dae3; --hover: #f2f4f8; --press: #e9edf3;
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: #eaf1ff; --accent-fg: #ffffff;
  --danger: #dc2626; --danger-soft: #fdecec; --warn: #b45309; --warn-soft: #fff6e5; --warn-line: #f5cf8a;
  --ok: #15803d; --ok-soft: #e8f6ed;
  --inverse: #0f172a; --inverse-fg: #f8fafc;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 18px rgba(15, 23, 42, .06);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .06);
  --radius: 16px; --radius-sm: 10px;
  /* biểu đồ */
  --series-1: #2a78d6; --series-2: #eb6834;
  --grid: #eef1f5; --axis: #cbd2dc;
  --seq-0: #eef1f5; --seq-1: #86b6ef; --seq-2: #5598e7; --seq-3: #2a78d6; --seq-4: #1c5cab; --seq-5: #104281;
  /* loại file (cùng bảng màu với biểu đồ dung lượng) */
  --c-folder: #e3a008;
  --c-image: #2a78d6; --c-video: #eb6834; --c-audio: #1baf7a; --c-document: #eda100;
  --c-archive: #e87ba4; --c-code: #008300; --c-design: #6250d6; --c-other: #94a3b8;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0e14; --card: #141922; --sidebar: #10141c; --raised: #1a202b;
    --fg: #e6e9ef; --fg-2: #b6bfcc; --muted: #8b95a5; --faint: #5f6b7c;
    --line: #232a36; --line-strong: #2f3846; --hover: #1b222d; --press: #222a37;
    --accent: #5b8cff; --accent-hover: #7aa2ff; --accent-soft: #1a2647; --accent-fg: #0b1020;
    --danger: #f87171; --danger-soft: #3a1a1d; --warn: #fbbf24; --warn-soft: #2a2010; --warn-line: #6b4f12;
    --ok: #4ade80; --ok-soft: #12291c;
    --inverse: #e6e9ef; --inverse-fg: #0f172a;
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
    --series-1: #3987e5; --series-2: #d95926;
    --grid: #1f2632; --axis: #344050;
    --seq-0: #1b222d; --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
    --c-folder: #f2b43a;
    --c-image: #3987e5; --c-video: #d95926; --c-audio: #199e70; --c-document: #c98500;
    --c-archive: #d55181; --c-code: #008300; --c-design: #9085e9; --c-other: #6b7686;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14; --card: #141922; --sidebar: #10141c; --raised: #1a202b;
  --fg: #e6e9ef; --fg-2: #b6bfcc; --muted: #8b95a5; --faint: #5f6b7c;
  --line: #232a36; --line-strong: #2f3846; --hover: #1b222d; --press: #222a37;
  --accent: #5b8cff; --accent-hover: #7aa2ff; --accent-soft: #1a2647; --accent-fg: #0b1020;
  --danger: #f87171; --danger-soft: #3a1a1d; --warn: #fbbf24; --warn-soft: #2a2010; --warn-line: #6b4f12;
  --ok: #4ade80; --ok-soft: #12291c;
  --inverse: #e6e9ef; --inverse-fg: #0f172a;
  --shadow-sm: none; --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
  --series-1: #3987e5; --series-2: #d95926;
  --grid: #1f2632; --axis: #344050;
  --seq-0: #1b222d; --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #b7d3f6;
  --c-folder: #f2b43a;
  --c-image: #3987e5; --c-video: #d95926; --c-audio: #199e70; --c-document: #c98500;
  --c-archive: #d55181; --c-code: #008300; --c-design: #9085e9; --c-other: #6b7686;
}

/* ---------- nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14.5px/1.55 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.wrap { overflow-wrap: anywhere; max-width: 420px; }
.center { text-align: center; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- nút & ô nhập ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: var(--fg);
  font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.btn .icon { width: 18px; height: 18px; }
.btn:hover { background: var(--hover); }
.btn:active { background: var(--press); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); box-shadow: 0 1px 2px rgba(37, 99, 235, .25); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex: none;
  border: 0; background: transparent; color: var(--fg-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn:disabled { opacity: .35; cursor: default; }
input:not([type=checkbox]):not([type=radio]), select {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--fg); transition: border-color .15s, box-shadow .15s;
}
input:not([type=checkbox]):not([type=radio]):focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--fg-2); }
.field input, .field select { width: 100%; font-weight: 400; }

/* ---------- khung ứng dụng ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 14px;
  background: var(--sidebar); border-right: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(140deg, #60a5fa 0%, #2563eb 55%, #1e3a8a 100%);
  box-shadow: 0 6px 14px rgba(37, 99, 235, .35);
}
.logo-mark .icon { width: 20px; height: 20px; stroke-width: 2; }
.logo.small { padding: 0; font-size: 16px; }
.logo.small .logo-mark { width: 28px; height: 28px; border-radius: 8px; }
.logo.small .logo-mark .icon { width: 16px; height: 16px; }
.cta { height: 44px; margin: 4px 0 10px; border-radius: 12px; font-size: 15px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--fg-2); font-weight: 550;
}
.nav a:hover { background: var(--hover); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.side-storage { margin-top: auto; display: grid; gap: 8px; padding: 14px; border-radius: 12px; background: var(--hover); font-size: 13px; }
.side-storage-head { display: flex; justify-content: space-between; font-weight: 600; }
.meter { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 16%, var(--line)); overflow: hidden; }
.meter > div { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .4s; }
.meter > div.warn { background: var(--warn); }
.usermenu { position: relative; margin-top: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; list-style: none;
}
.user-chip::-webkit-details-marker { display: none; }
.user-chip:hover, .usermenu[open] .user-chip { background: var(--hover); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, #a78bfa, #6366f1); color: #fff; font-weight: 700;
}
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }
.user-meta { display: grid; min-width: 0; line-height: 1.25; }
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 12px; color: var(--muted); }
.user-chip .chev { margin-left: auto; width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.usermenu:not([open]) .chev { transform: rotate(180deg); }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 60; display: grid; padding: 6px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--fg); cursor: pointer; text-align: left; font-size: 14px;
}
.menu-item .icon { width: 18px; height: 18px; color: var(--muted); }
.menu-item:hover { background: var(--hover); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.mobile-bar { display: none; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 96px; }
.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 32px; font-size: 14px;
  background: var(--warn-soft); border-bottom: 1px solid var(--warn-line);
}
.banner .icon { color: var(--warn); }
.banner a { margin-left: auto; color: var(--accent); font-weight: 600; }

/* ---------- đầu trang ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.2; }
.page-sub { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--hover); border: 1px solid var(--line); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 550; cursor: pointer;
}
.segmented button .icon { width: 18px; height: 18px; }
.segmented button.icon-only { padding: 0 8px; }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--fg); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

/* ---------- thẻ ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
h3.sub { font-size: 14px; margin: 20px 0 8px; }
.scroll-x { overflow-x: auto; }
.badge {
  display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 550;
  background: var(--hover); color: var(--fg-2); border: 1px solid var(--line); vertical-align: 1px;
}
.badge.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------- breadcrumb ---------- */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; font-size: 22px; font-weight: 700; }
.breadcrumb a { padding: 2px 8px; border-radius: 8px; color: var(--muted); }
.breadcrumb a:hover { background: var(--hover); color: var(--fg); }
.breadcrumb a:last-child { color: var(--fg); }
.breadcrumb .sep { width: 18px; height: 18px; color: var(--faint); }

/* ---------- bảng ---------- */
.files { width: 100%; border-collapse: collapse; }
.files th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.files td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files tbody tr:last-child td { border-bottom: 0; }
.files tbody tr { transition: background .1s; }
.files tbody tr:hover { background: var(--hover); }
.files tr.is-selected { background: var(--accent-soft); }
.files .chk { width: 44px; }
.files .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.files .date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.files tr.inactive td { opacity: .55; }
.files tr.inactive td:last-child { opacity: 1; }
.files.compact td, .files.compact th { padding: 7px 10px; font-size: 13px; }
.name-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.name-cell .name { font-weight: 550; overflow-wrap: anywhere; }
a.name:hover { color: var(--accent); }
.folder-link:hover { color: var(--accent); text-decoration: underline; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* chip biểu tượng loại file */
.fi {
  --c: var(--c-other);
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.fi .icon { width: 19px; height: 19px; }
.fi.sm { width: 30px; height: 30px; border-radius: 8px; }
.fi.sm .icon { width: 16px; height: 16px; }
.fi.lg { width: 64px; height: 64px; border-radius: 18px; }
.fi.lg .icon { width: 32px; height: 32px; stroke-width: 1.6; }
.t-folder { --c: var(--c-folder); } .t-image { --c: var(--c-image); } .t-video { --c: var(--c-video); }
.t-audio { --c: var(--c-audio); } .t-document { --c: var(--c-document); } .t-archive { --c: var(--c-archive); }
.t-code { --c: var(--c-code); } .t-design { --c: var(--c-design); } .t-other { --c: var(--c-other); }

/* ---------- trang Tệp ---------- */
.dropzone { position: relative; padding: 0; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.dropzone.over { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.dropzone.over::after {
  content: "Thả vào đây để tải lên"; position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent); color: var(--accent); font-weight: 650; font-size: 16px;
}
.empty { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }
.empty-state { display: grid; justify-items: center; gap: 10px; padding: 64px 16px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 6px 0 0; color: var(--fg); font-size: 17px; }
.empty-state p { margin: 0 0 8px; max-width: 360px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; padding: 16px; }
.g-item { position: relative; border-radius: 14px; padding: 8px; border: 1px solid transparent; min-width: 0; transition: background .12s, border-color .12s; }
.g-item:hover { background: var(--hover); }
.g-item.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.g-chk { position: absolute; top: 14px; left: 14px; z-index: 2; opacity: 0; transition: opacity .15s; }
.g-item:hover .g-chk, .g-item.selected .g-chk, .grid:has(.selected) .g-chk { opacity: 1; }
@media (hover: none) { .g-chk { opacity: 1; } }
.g-chk input { width: 18px; height: 18px; }
.g-thumb {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden;
  background: var(--hover); border: 1px solid var(--line);
}
.g-thumb img { width: 100%; height: 100%; object-fit: cover; transition: opacity .25s; }
.g-thumb img.pending { position: absolute; inset: 0; opacity: 0; }
.g-badge {
  position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(15, 23, 42, .62); color: #fff; backdrop-filter: blur(4px);
}
.g-badge .icon { width: 13px; height: 13px; margin-left: 2px; }
.g-name { margin-top: 8px; font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-meta { font-size: 12px; color: var(--muted); }

/* thanh thao tác nổi khi chọn file */
.selection-bar {
  position: fixed; left: calc(50% + 126px); bottom: 24px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 6px; max-width: calc(100vw - 32px);
  background: var(--inverse); color: var(--inverse-fg); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: rise .18s ease-out;
}
.selection-bar .count { padding: 0 10px 0 4px; font-weight: 600; white-space: nowrap; }
.selection-bar .bar-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border: 0; border-radius: 9px;
  background: transparent; color: inherit; cursor: pointer; font-weight: 550; white-space: nowrap;
}
.selection-bar .bar-btn .icon { width: 18px; height: 18px; }
.selection-bar .bar-btn:hover { background: color-mix(in srgb, var(--inverse-fg) 14%, transparent); }
.selection-bar .bar-btn:disabled { opacity: .4; cursor: default; background: transparent; }
.selection-bar .bar-btn.danger { color: #fca5a5; }
.selection-bar .divider { width: 1px; height: 22px; background: color-mix(in srgb, var(--inverse-fg) 22%, transparent); margin: 0 4px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }

/* bảng tiến độ upload nổi */
.upload-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 31; width: min(420px, calc(100vw - 32px));
  background: var(--raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.uploads-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.uploads-head h3 { margin: 0 auto 0 0; font-size: 15px; }
.upload-panel.collapsed #upload-list { display: none; }
.upload-panel.collapsed .uploads-head { border-bottom: 0; }
.upload-panel.collapsed #uploads-toggle .icon { transform: rotate(180deg); }
#upload-list { list-style: none; margin: 0; padding: 6px 0; max-height: 300px; overflow-y: auto; }
#upload-list li { display: grid; grid-template-columns: 30px 1fr auto 28px; gap: 4px 10px; align-items: center; padding: 8px 12px 8px 16px; font-size: 13px; }
#upload-list li .fi { grid-row: span 2; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.up-status { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
#upload-list progress { grid-column: 2 / 4; width: 100%; height: 4px; appearance: none; border: 0; border-radius: 99px; background: var(--line); overflow: hidden; }
#upload-list progress::-webkit-progress-bar { background: var(--line); }
#upload-list progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
#upload-list progress::-moz-progress-bar { background: var(--accent); }
li.done .up-status { color: var(--ok); }
#upload-list li.done progress::-webkit-progress-value { background: var(--ok); }
#upload-list li.done progress::-moz-progress-bar { background: var(--ok); }
li.failed .up-status { color: var(--danger); grid-column: 2 / 4; text-align: left; white-space: normal; }
li.failed progress { display: none; }
.up-cancel { width: 28px; height: 28px; grid-row: span 2; }

/* ---------- hộp thoại, xem trước, thông báo ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--raised); color: var(--fg); padding: 22px;
  width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
.dlg-title { margin: 0 0 14px; font-weight: 650; font-size: 17px; }
dialog form > input { width: 100%; }
dialog .field { margin-bottom: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 18px 0 0; padding: 0; }
dialog p.muted { font-weight: 400; }
dialog.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: rgba(8, 10, 14, .96); color: #f1f5f9;
}
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: rgba(0, 0, 0, .8); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.viewer-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.viewer-head .icon-btn { color: #e2e8f0; }
.viewer-head .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.viewer-head .btn { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .25); box-shadow: none; }
.viewer-head .btn:hover { background: rgba(255, 255, 255, .1); }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 12px 12px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100dvh - 76px); object-fit: contain; border-radius: 6px; }
.viewer-body audio { width: min(520px, 100%); }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.viewer-text {
  width: 100%; height: 100%; margin: 0; overflow: auto; padding: 18px; border-radius: 10px; background: #0f1218; color: #e5e7eb;
  font: 13px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.viewer-msg { color: #cbd5e1; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 12px; font-weight: 550;
  background: var(--inverse); color: var(--inverse-fg); box-shadow: var(--shadow-lg); animation: rise .18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.alert { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* ---------- trang Dung lượng ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; margin-bottom: 20px; }
.tile {
  display: grid; gap: 4px; align-content: start; padding: 18px 20px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-label { font-size: 13px; font-weight: 550; color: var(--muted); }
.tile-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile-icon .icon { width: 17px; height: 17px; }
.tile-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.tile-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tile-sub a { color: var(--accent); font-weight: 550; }
.segbar { display: flex; gap: 2px; height: 12px; margin: 6px 0 16px; }
.segbar.is-empty { background: var(--hover); border-radius: 6px; }
.seg { min-width: 3px; height: 100%; }
.seg:first-child { border-radius: 6px 0 0 6px; }
.seg:last-child { border-radius: 0 6px 6px 0; }
.seg:only-child { border-radius: 6px; }
.seg:hover, .seg:focus-visible { filter: brightness(1.12); outline: none; }
.c-image { background: var(--c-image); } .c-video { background: var(--c-video); } .c-audio { background: var(--c-audio); }
.c-document { background: var(--c-document); } .c-archive { background: var(--c-archive); } .c-code { background: var(--c-code); }
.c-design { background: var(--c-design); } .c-other { background: var(--c-other); }
.legend-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legend-table th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.legend-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.legend-table tr:last-child td { border-bottom: 0; }
.legend-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend-table tr.zero td { color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 10px; vertical-align: baseline; }
.dup-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.dup-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.dup-list { list-style: none; margin: 0; padding: 0; }
.dup-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 14px; flex-wrap: wrap; }
.dup-list label { display: flex; gap: 10px; align-items: center; min-width: 0; }
.dup-list .folder-link { font-size: 13px; overflow-wrap: anywhere; }

/* ---------- Nhật ký, Chia sẻ ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filters label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--fg-2); }
.act { display: inline-flex; align-items: center; gap: 10px; }
.act .fi { width: 30px; height: 30px; border-radius: 8px; }
.act .fi .icon { width: 16px; height: 16px; }
td.failed, .act.failed { color: var(--danger); }
.share-url { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; color: var(--accent); }
.share-url:hover { text-decoration: underline; }

/* ---------- Quản trị ---------- */
.tabs { display: flex; gap: 4px; margin: -4px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border: 0; background: transparent;
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button .icon { width: 18px; height: 18px; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.checklist { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.checklist div { overflow-wrap: anywhere; }
.chk-icon {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.chk-ok { --c: var(--ok); } .chk-warn { --c: var(--warn); } .chk-bad { --c: var(--danger); } .chk-off { --c: var(--muted); }
.checklist .small { margin-top: 2px; }
.progress-box { display: grid; gap: 8px; margin: 10px 0 4px; font-size: 14px; }
.progress-box progress { width: 100%; height: 8px; accent-color: var(--accent); }
details.runs { margin-top: 16px; }
details.runs summary, details.table-view summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 550; }
.create-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.create-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--fg-2); }
.create-form label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); height: 40px; }
.create-form input:not([type=checkbox]) { width: 190px; }
.create-form input[name=quota] { width: 110px; }
.usage { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 13px; }
.usage .meter { width: 120px; }

/* ---------- bảng điều khiển: biểu đồ ---------- */
.filter-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.dash { transition: opacity .2s; }
.dash.loading { opacity: .5; pointer-events: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(176px, 100%), 1fr)); gap: 14px; margin-bottom: 20px; }
.kpis .tile-value { font-size: 26px; }
.delta { font-size: 12.5px; color: var(--muted); }
.warn-text { color: var(--warn); font-weight: 600; }
.tile-sub .icon { width: 15px; height: 15px; vertical-align: -3px; color: var(--warn); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.chart-grid > .card { margin-bottom: 20px; }
.chart-card { display: grid; gap: 10px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-head p { margin: 2px 0 0; }
.chart { position: relative; min-height: 120px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-svg .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .s1 { stroke: var(--series-1); } .chart-svg .s2 { stroke: var(--series-2); }
.chart-svg .dot { stroke: var(--card); stroke-width: 2; }
.chart-svg .dot.s1 { fill: var(--series-1); } .chart-svg .dot.s2 { fill: var(--series-2); }
.chart-svg .bar.s1 { fill: var(--series-1); } .chart-svg .bar.s2 { fill: var(--series-2); }
.chart-svg .bar { transition: filter .12s; }
.chart-svg .col:hover .bar, .chart-svg .col.active .bar { filter: brightness(1.18); }
.chart-svg .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart-svg .end-label { fill: var(--fg-2); font-weight: 600; }
.chart-svg .value-label { fill: var(--fg); font-weight: 600; }
.chart-svg .bar-name { fill: var(--fg-2); font-size: 13px; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.chart-svg .hit:focus { outline: none; }
.chart-svg:focus { outline: none; }
.chart-svg:focus-visible, .chart-svg .hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-svg .cell { stroke: var(--card); stroke-width: 2; rx: 4; }
.chart-svg .cell.active { stroke: var(--fg); stroke-width: 2; }
.h0 { fill: var(--seq-0); background: var(--seq-0); } .h1 { fill: var(--seq-1); background: var(--seq-1); }
.h2 { fill: var(--seq-2); background: var(--seq-2); } .h3 { fill: var(--seq-3); background: var(--seq-3); }
.h4 { fill: var(--seq-4); background: var(--seq-4); } .h5 { fill: var(--seq-5); background: var(--seq-5); }
.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.key-line { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.key-line.s1 { background: var(--series-1); } .key-line.s2 { background: var(--series-2); }
.scale-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.scale-legend .sw { display: inline-block; width: 18px; height: 12px; border-radius: 3px; }
.scale-legend .gap { width: 10px; }
.chart-empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); font-size: 14px; }
.chart-tip {
  position: fixed; z-index: 120; pointer-events: none; min-width: 150px; padding: 10px 12px; border-radius: 10px;
  background: var(--raised); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13px;
}
.tip-title { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tip-row strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.tip-row .tip-label { color: var(--muted); }
.table-view .scroll-x { margin-top: 10px; }

/* ---------- trang đăng nhập, trang chia sẻ công khai ---------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, #8b5cf6 14%, transparent), transparent 70%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%); display: grid; gap: 16px; padding: 32px; border-radius: 22px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.auth-brand { display: grid; justify-items: center; gap: 12px; text-align: center; }
.auth-brand .logo-mark { width: 52px; height: 52px; border-radius: 15px; }
.auth-brand .logo-mark .icon { width: 28px; height: 28px; }
.auth-brand h1 { margin: 0; font-size: 24px; }
.auth-brand p { margin: -6px 0 0; color: var(--muted); }
.auth-card .btn { height: 44px; margin-top: 4px; }
.share-page main { max-width: 980px; margin: 0 auto; padding: 24px 20px 64px; }
.share-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card); }
.share-card { max-width: 780px; margin: 0 auto; }
.share-card .file-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.share-card .file-hero h1 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.share-pw { max-width: 400px; display: grid; gap: 14px; margin: 40px auto; }
.share-preview { display: block; max-width: 100%; max-height: 70vh; margin: 12px auto; border-radius: 10px; }
.share-audio { width: 100%; margin: 12px 0; }
.share-pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; }

/* ---------- chia sẻ: hộp thoại, link có giới hạn, làm việc chung ---------- */
.dlg-share { width: min(540px, calc(100vw - 32px)); }
.dlg-tabs { margin: -4px 0 16px; overflow: visible; } /* không cuộn -> không bị hộp thoại chọn làm ô focus đầu tiên */
.member-add { display: flex; gap: 8px; margin-bottom: 10px; }
.member-add input { flex: 1; min-width: 0; }
.member-add select { flex: none; }
.member-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.member-list li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto 38px; align-items: center; gap: 10px; padding: 5px 2px 5px 6px; border-radius: 10px; }
.member-list li:hover { background: var(--hover); }
.member-name { font-weight: 550; overflow-wrap: anywhere; }
select.role-select { height: 34px; padding: 0 8px; font-size: 13px; }
.member-empty { margin: 2px 0 8px; }
#collab-stop { margin-top: 2px; }
.field .inline-fields { display: flex; gap: 8px; }
.field .inline-fields input { width: 100px; flex: none; }
.field .inline-fields select { flex: 1; width: auto; }
fieldset.choices { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
fieldset.choices legend { padding: 0; margin-bottom: 6px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--fg); font-weight: 500; font-size: 14px;
}
.choice:hover { background: var(--hover); }
.choice:has(input[type=radio]:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.field .choice input[type=radio] { width: auto; flex: none; margin: 0; accent-color: var(--accent); }
.field .choice input[type=number] { width: 62px; height: 30px; padding: 0 8px; font-weight: 500; }
.share-summary { margin: 2px 0 6px; font-weight: 550; }

.share-limits { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.limit-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-size: 14px;
  background: var(--hover); border: 1px solid var(--line); color: var(--fg-2);
}
.limit-chip .icon { width: 16px; height: 16px; color: var(--muted); }
.limit-chip strong { color: var(--fg); }
.share-note { margin: 0 0 14px; }
.share-owner-note {
  display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 8px 12px; border-radius: 10px;
  background: var(--ok-soft); color: var(--ok); font-size: 13.5px; font-weight: 550;
}
.share-owner-note .icon { width: 16px; height: 16px; }
.share-thumb { display: block; width: 100%; max-width: 320px; margin: 4px 0 16px; border-radius: 12px; border: 1px solid var(--line); }
.share-limits-row { margin: -6px 0 14px; }

.space-info {
  display: flex; align-items: center; gap: 10px; margin: -8px 0 16px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--fg-2); font-size: 14px;
}
.space-info .icon { width: 18px; height: 18px; color: var(--accent); }
.space-info strong { color: var(--fg); }
.read-only .needs-write, .in-space .own-only { display: none !important; }
.read-only .dropzone.over::after { content: "Bạn chỉ có quyền xem thư mục này"; }
.collab-mark {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 6px;
  color: var(--accent); background: var(--accent-soft);
}
.collab-mark .icon { width: 14px; height: 14px; }
.g-name .collab-mark { width: 18px; height: 18px; margin-right: 6px; vertical-align: -4px; }
.g-name .collab-mark .icon { width: 12px; height: 12px; }
.avatar.xs { width: 22px; height: 22px; font-size: 11px; }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.people { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.card.dropzone > .card-head { padding: 16px 20px 4px; margin: 0; }
.empty-state.compact { padding: 24px 16px 32px; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.live-text { color: var(--accent); font-weight: 550; }
.share-url.ended { color: var(--muted); text-decoration: line-through; }

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 1100px) {
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .mobile-bar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 10px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .content { padding: 18px 16px 110px; }
  .banner { padding: 10px 16px; }
  .selection-bar { left: 50%; }
}
@media (max-width: 640px) {
  .page-title { font-size: 22px; }
  .breadcrumb { font-size: 18px; flex-basis: 100%; }
  .files .date { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; padding: 10px; }
  .actions .btn .label { display: none; }
  .actions .btn { padding: 0 11px; }
  .selection-bar { bottom: 12px; padding: 6px; overflow-x: auto; }
  .selection-bar .bar-btn .label { display: none; }
  .upload-panel { right: 16px; bottom: 16px; }
  .card { padding: 16px; }
  .tile-value { font-size: 24px; }
  .tiles, .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; }
  .create-form input:not([type=checkbox]) { width: 100%; }
  .create-form label { flex: 1 1 150px; }
  .auth-card { padding: 24px; }
  .member-add { flex-wrap: wrap; }
  .member-add input { flex-basis: 100%; }
  .member-add select { flex: 1; }
  /* bảng nhiều cột -> mỗi dòng thành một thẻ xếp dọc */
  .stack-table thead { display: none; }
  .stack-table, .stack-table tbody, .stack-table tr { display: block; width: 100%; }
  .stack-table tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .stack-table tbody tr:last-child { border-bottom: 0; }
  .files.stack-table td, .files.stack-table td.date { display: block; padding: 3px 0; border: 0; text-align: left; white-space: normal; }
  .stack-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; }
  .stack-table td.date .small, .stack-table td.num .small { display: inline; margin-left: 6px; }
  .stack-table td:last-child { padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
