/* 云仓NAS — fresh, light storage workspace */
:root {
  color-scheme: light;
  --bg: #f5f9f8;
  --surface: #ffffff;
  --surface-2: #eff6f4;
  --ink: #20312e;
  --muted: #70817d;
  --border: #e0ebe8;
  --accent: #29998b;
  --accent-soft: #e4f4f1;
  --accent-strong: #20796f;
  --success: #258b70;
  --danger: #d6535e;
  --warning: #b98332;
  --radius: 15px;
  --shadow: 0 8px 26px rgba(34, 78, 70, 0.07);
  --sidebar: 220px;
  --topbar: 56px;
  --font: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
    background: linear-gradient(180deg, #fbfdfc 0%, var(--bg) 100%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.login-brand { flex-direction: column; align-items: flex-start; gap: 0; }
.login-brand h1 { width: 100%; }
.brand-logo { display: block; width: 100%; height: auto; }
.login-brand p { padding-left: 14px; margin-top: 0; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  flex-shrink: 0; object-fit: contain;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #258f84, #66b8ae);
  color: white; font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 11px; }
.login-card label, .form-col label {
  display: block; margin-bottom: 12px; font-weight: 500; color: var(--ink);
}
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); border-radius: 10px; padding: 8px 14px;
  font: inherit; font-weight: 550; cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px; font-size: 16px; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px;
}
.sidebar-title { font-weight: 650; letter-spacing: -0.02em; flex: 1; min-width: 0; }
.sidebar-logo { display: block; width: 158px; max-width: 100%; height: auto; }
.sidebar-close { display: none; margin-left: auto; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-ico { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-foot { padding: 8px; display: grid; gap: 10px; }
.user-chip {
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  font-weight: 600; font-size: 13px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-bottom-nav { display: none; }
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: rgba(255,255,255,0.86);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.topbar-title { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.menu-btn { display: none; }

.page { padding: 20px; display: grid; gap: 16px; align-content: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- dashboard ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  box-shadow: 0 3px 12px rgba(39, 88, 78, 0.035);
}
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 550; }
.stat-card .value { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat-meter { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #eaf1ef; }
.stat-meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6bbcaf, var(--accent)); }
.dashboard-lower {
  display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.95fr);
  gap: 16px; align-items: stretch;
}
.dashboard-recent, .type-panel { min-width: 0; }
.dashboard-recent .panel-head { margin-bottom: 12px; }
.type-panel .panel-head { align-items: flex-start; }
.type-panel .chart-caption { margin-top: 2px; font-size: 12px; }
.chart-total {
  padding: 5px 9px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-strong); font-size: 11px; font-weight: 650; white-space: nowrap;
}
.type-chart-content {
  display: grid; grid-template-columns: minmax(130px, 174px) minmax(0, 1fr);
  align-items: center; gap: 14px; min-height: 184px;
}
.type-pie { display: block; width: 100%; max-width: 174px; margin: 0 auto; }
.type-pie.is-empty { padding: 14px; }
.type-legend { display: grid; gap: 11px; min-width: 0; }
.type-legend-item {
  display: grid; grid-template-columns: 10px minmax(38px, 1fr) auto 38px;
  align-items: center; gap: 7px; font-size: 12px; min-width: 0;
}
.type-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--type-color); }
.type-name { color: var(--ink); }
.type-count, .type-percent { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.type-percent { color: var(--ink); font-weight: 650; }
.type-empty { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.access-list { display: grid; gap: 8px; }
.access-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 14px; background: var(--surface-2); border-radius: 12px;
}
.access-details { min-width: 0; }
.access-label { margin-bottom: 3px; font-size: 12px; }
.access-item code {
  font-family: var(--mono); font-size: 12px; color: var(--accent-strong);
  word-break: break-all;
}

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td {
  padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 12px; color: var(--muted); font-weight: 600;
  background: #f7faf9; position: sticky; top: 0;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: default; }
.table tbody tr:hover { background: #f4f9f7; }
.table tbody tr.directory-row { cursor: pointer; }
.table tbody tr.directory-row:hover { background: #eaf6f3; }
.table tbody tr.directory-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.file-name {
  display: flex; align-items: center; gap: 10px; font-weight: 550;
}
.file-ico {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 13px; flex: 0 0 auto;
}
.file-ico.dir { background: #e6f3f0; color: #267c72; }
.file-ico.video { background: #eaf3f8; color: #467f9d; }
.file-ico.photo { background: #eaf5ef; color: #4d8268; }
.file-ico.audio { background: #eef4f3; color: #587d78; }
.file-ico.doc { background: #edf4f3; color: #4f7e79; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn { padding: 5px 10px; font-size: 12px; }
.file-list-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: 10px; }
.file-list-head .muted { font-size: 12px; }
.file-batch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface);
}
.file-batch-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.file-batch-actions .btn { min-height: 38px; padding: 7px 12px; }
.file-selection-control { display: none; flex: 0 0 auto; align-items: center; margin: 0; }
.file-selection-control input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
#page-files.selection-mode .file-selection-control { display: flex; }
#page-files.selection-mode .file-more-btn { display: none; }
#files-table tr.is-selected { background: var(--accent-soft); }
#files-table th:last-child, #files-table td:last-child { width: 70px; text-align: center; }
.file-more-btn { width: 42px; height: 42px; font-size: 23px; line-height: 1; }
.file-action-sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.file-action-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.file-action-card {
  position: relative; width: min(420px, 100%); max-height: min(85dvh, 600px); overflow: auto;
  padding: 14px; border-radius: 16px; background: var(--surface); box-shadow: 0 20px 60px rgba(15,23,42,.22);
}
.file-action-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.file-action-head strong { min-width: 0; overflow-wrap: anywhere; }
.file-action-options { display: grid; gap: 6px; }
.file-action-option {
  width: 100%; min-height: 48px; padding: 10px 14px; text-align: left;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--ink); font: inherit; cursor: pointer;
}
.file-action-option.danger { color: var(--danger); background: #fff5f5; border-color: #fecaca; }
.path-link {
  background: none; border: none; color: var(--accent-strong);
  font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-align: left;
}

/* ---------- toolbar / dropzone ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 8px; }
.breadcrumbs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.breadcrumbs button {
  border: none; background: none; color: var(--accent-strong);
  font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px; border-radius: 6px;
}
.breadcrumbs button:hover { background: var(--accent-soft); }
.breadcrumbs .sep { opacity: 0.5; }
.media-folders { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.media-folder { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.media-folder span:last-child { overflow-wrap: anywhere; text-align: left; }
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center; color: var(--muted);
  background: rgba(255,255,255,0.5); transition: 0.15s ease;
}
.dropzone.dragover {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong);
}

/* ---------- media grids ---------- */
.media-grid, .photo-grid {
  display: grid; gap: 12px;
}
.media-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.media-card, .photo-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.media-card:hover, .photo-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.media-thumb, .photo-thumb {
  aspect-ratio: 16/9; background: #0b1220; position: relative; overflow: hidden;
}
.photo-thumb { aspect-ratio: 1/1; background: var(--surface-2); }
.media-thumb img, .photo-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.35));
  color: white; font-size: 28px; opacity: 0.95;
}
.media-meta, .photo-meta { padding: 10px 12px; }
.media-meta .title, .photo-meta .title {
  font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-meta .sub, .photo-meta .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tv-source-btn { margin-top: 9px; width: 100%; }
.hls-link-list { display: grid; gap: 8px; }
.hls-link-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.hls-link-info { min-width: 0; }
.hls-link-path { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hls-link-meta { margin-top: 3px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.hls-link-actions { display: flex; gap: 8px; flex-shrink: 0; }
.empty {
  padding: 48px 16px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- downloads ---------- */
.transfer-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}
.transfer-tabs a {
  color: var(--muted); text-decoration: none; padding: 9px 15px;
  border-radius: 10px; font-weight: 600;
}
.transfer-tabs a:hover, .transfer-tabs a.active { color: var(--accent-strong); background: var(--accent-soft); }
.transfer-panel { display: grid; gap: 16px; }
.transfer-panel.hidden { display: none; }
.download-details { min-width: 220px; flex: 1; }
.download-progress { margin-top: 6px; font-size: 12px; }
.download-form {
  display: grid; grid-template-columns: 1fr 160px auto; gap: 10px;
}
.download-list { display: grid; gap: 10px; }
.download-item {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  background: var(--surface);
}
.download-item .row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
}
.download-item .name { font-weight: 600; word-break: break-all; }
.download-item .url { color: var(--muted); font-size: 12px; word-break: break-all; margin-top: 2px; }
.progress {
  height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
  margin-top: 10px;
}
.progress-bar {
  height: 100%; width: 0%; background: linear-gradient(90deg, #6bbcaf, var(--accent));
  transition: width 0.25s ease;
}
.download-actions { display: flex; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.done { background: #ecfdf5; color: var(--success); }
.badge.run { background: var(--accent-soft); color: var(--accent-strong); }
.badge.err { background: #fff1f2; color: var(--danger); }
.badge.pause { background: #fff7ed; color: var(--warning); }

/* ---------- settings / sysinfo ---------- */
.form-col { max-width: 420px; }
.settings-layout { display: grid; grid-template-columns: 218px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-menu {
  position: sticky; top: calc(var(--topbar) + 20px);
  display: grid; gap: 3px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.settings-menu-group { padding: 13px 11px 5px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .08em; }
.settings-menu a {
  display: flex; align-items: center; gap: 10px; min-height: 39px;
  padding: 8px 11px; border-radius: 9px; color: var(--ink);
  text-decoration: none; white-space: nowrap; font-weight: 520;
}
.settings-menu a span { width: 19px; text-align: center; color: var(--muted); }
.settings-menu a:hover { background: var(--surface-2); }
.settings-menu a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.settings-menu a.active span { color: var(--accent-strong); }
.settings-content { min-width: 0; }
.settings-panel { min-height: 250px; }
.settings-panel[data-settings-panel="system"] { width: 100%; max-width: 760px; }
.settings-panel .panel-head .muted { margin-top: 3px; font-size: 12px; }
.settings-panel #member-form { margin-bottom: 20px; }
.sysinfo { display: grid; gap: 8px; }
.sysinfo .item {
  display: grid; grid-template-columns: clamp(90px, 24%, 140px) minmax(0, 1fr); gap: 16px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.sysinfo .item:last-child { border-bottom: none; }
.sysinfo .k { color: var(--muted); }
.sysinfo .v { min-width: 0; font-family: var(--mono); font-size: 12px; text-align: left; overflow-wrap: anywhere; }

/* ---------- modal / player / lightbox ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative; width: min(960px, 100%); background: var(--surface);
  border-radius: 16px; overflow: hidden; box-shadow: 0 20px 60px rgba(15,23,42,0.28);
}
.player-card { width: min(1100px, 100%); background: #0b1220; color: #fff; }
.document-card { width: min(1280px, 100%); height: min(850px, calc(100dvh - 32px)); display: flex; flex-direction: column; }
.document-card .modal-head { flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.document-card .modal-title { min-width: 0; }
.document-card .modal-actions { flex: 0 0 auto; }
.document-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.document-body > iframe, .document-body > #office-editor { width: 100%; height: 100%; border: 0; }
.document-text { width: 100%; height: 100%; padding: 20px; resize: none; border: 0; outline: none; background: #fff; color: var(--ink); font: 14px/1.65 Consolas, 'Microsoft YaHei', monospace; tab-size: 2; }
.document-text[readonly] { background: #f8fbfa; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
}
.player-card .modal-head { background: #0b1220; }
.modal-title {
  font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-actions { display: flex; gap: 8px; align-items: center; }
.player-card video {
  width: 100%; max-height: min(70vh, 620px); background: #000; display: block;
}
.lightbox-card { width: min(1000px, 100%); background: #0b1220; color: #fff; }
.lightbox-card img {
  width: 100%; max-height: 75vh; object-fit: contain; display: block; background: #000;
}
.lightbox-card .btn.ghost { color: #fff; border-color: rgba(255,255,255,0.2); }

/* ---------- toast ---------- */
.toast-wrap {
  position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px;
}
.toast {
  background: #111827; color: #fff; padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow); min-width: 220px; max-width: 360px; font-size: 13px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
/* ---------- upload tasks / sharing / family ---------- */
.task-list { display: grid; gap: 10px; }
.upload-panel .panel-head { justify-content: flex-start; margin-bottom: 10px; }
.upload-panel .panel-head .upload-hint { font-size: 12px; }
.upload-panel .panel-head #uploads-refresh { margin-left: auto; }
.upload-list-scroll { overflow-x: auto; }
#upload-task-list {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px 260px 220px 130px;
  column-gap: 14px;
  row-gap: 6px;
  min-width: 1150px;
}
.upload-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px 260px 220px 130px;
  grid-template-columns: subgrid;
  align-items: center; min-width: 0; min-height: 52px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.upload-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.upload-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.upload-progress { margin-top: 0; height: 6px; }
.upload-state { display: flex; align-items: center; gap: 6px; min-width: 0; }
.upload-error { color: var(--danger); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.upload-actions { display: grid; grid-template-columns: 60px 60px; justify-content: end; gap: 6px; white-space: nowrap; }
.upload-actions .btn { width: 60px; padding: 6px 0; border-radius: 8px; font-size: 12px; }
.upload-actions [data-upload-pause], .upload-actions [data-upload-retry] { grid-column: 1; }
.upload-actions [data-upload-remove] { grid-column: 2; }
.task-item { padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.task-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.task-main strong { overflow-wrap: anywhere; font-size: 13px; }
.task-item .muted { font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.task-actions select { width: auto; min-height: 34px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); }
.task-item .error { margin-top: 6px; overflow-wrap: anywhere; }
.share-card { width: min(480px, 100%); padding-bottom: 16px; }
.share-card .form-col { padding: 0 16px; }
.share-created { padding: 4px 16px 0; }
.share-created label { display: block; margin-bottom: 8px; }
.share-page { background: var(--bg); min-height: 100vh; }
.share-layout { width: min(760px, calc(100% - 28px)); margin: 38px auto; display: grid; gap: 20px; }
.share-layout .panel { min-height: 200px; }
.share-layout .brand h1 { font-size: 20px; margin: 0; }
.share-layout .brand p { margin: 0; }
.share-layout #share-content { display: grid; gap: 14px; }
.share-layout #share-content.hidden { display: none; }
.share-layout .form-col { margin-bottom: 14px; }
.share-item .task-main { gap: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-105%);
    transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-btn { display: inline-grid; place-items: center; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 35; display: none;
  }
  .sidebar-backdrop.show { display: block; }
  .download-form { grid-template-columns: 1fr; }
  .page { padding: 14px; }
  .topbar { padding: 0 12px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: min(82vw, 320px); }
  .sidebar .nav a { min-height: 48px; }
  .sidebar-close, .topbar .icon-btn { width: 44px; height: 44px; }
  .topbar { height: 54px; }
  .topbar-actions .btn { min-height: 44px; }
  .page { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); gap: 12px; }
  .panel { padding: 14px; }
  .mobile-bottom-nav {
    position: fixed; inset: auto 0 0; z-index: 32;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border); background: rgba(255,255,255,.97);
    box-shadow: 0 -4px 18px rgba(34,78,70,.07);
  }
  .mobile-bottom-nav a {
    display: grid; justify-items: center; align-content: center; gap: 2px;
    min-height: 48px; border-radius: 10px; color: var(--muted);
    text-decoration: none; font-size: 11px; font-weight: 600;
  }
  .mobile-bottom-nav a span { font-size: 20px; line-height: 1; }
  .mobile-bottom-nav a.active { background: var(--accent-soft); color: var(--accent-strong); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { min-width: 0; padding: 12px; }
  .stat-card .value { font-size: clamp(16px, 4.4vw, 21px); overflow-wrap: anywhere; }
  #page-dashboard .table-wrap, #page-files .table-wrap { overflow: visible; border: 0; background: transparent; }
  #recent-table, #files-table { display: block; width: 100%; min-width: 0; }
  #recent-table tbody, #files-table tbody { display: grid; gap: 8px; }
  #recent-table tr, #files-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px;
    min-width: 0; padding: 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px;
  }
  #recent-table td, #files-table td { display: block; min-width: 0; padding: 0; border: 0; font-size: 12px; color: var(--muted); }
  #recent-table td:first-child, #files-table td:first-child { grid-column: 1 / -1; color: var(--ink); font-size: 13px; }
  #recent-table td:nth-child(3), #files-table td:nth-child(3) { text-align: right; }
  #recent-table td:nth-child(4) { display: none; }
  #files-table td:nth-child(4) { grid-column: 1 / -1; margin-top: 6px; }
  #files-table td[colspan] { grid-column: 1 / -1; }
  #files-table thead { display: none; }
  .file-name { min-width: 0; }
  .file-name span { min-width: 0; overflow-wrap: anywhere; }
  #files-table tr[data-entry-path] td:first-child { grid-column: 1; grid-row: 1; }
  #files-table tr[data-entry-path] td:nth-child(2) { grid-column: 1; grid-row: 2; }
  #files-table tr[data-entry-path] td:nth-child(3) { grid-column: 2; grid-row: 2; white-space: nowrap; }
  #files-table tr[data-entry-path] td:nth-child(4) { grid-column: 2; grid-row: 1; margin: 0; align-self: center; justify-self: end; width: auto; }
  #page-files.selection-mode #files-table tr[data-entry-path] td:first-child { grid-column: 1 / -1; }
  #page-files.selection-mode #files-table tr[data-entry-path] td:nth-child(4) { display: none; }
  .file-more-btn { width: 44px; height: 44px; }
  .file-list-head .btn { min-height: 44px; }
  .file-batch-bar {
    position: fixed; left: 8px; right: 8px; bottom: calc(61px + env(safe-area-inset-bottom));
    z-index: 34; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px;
    box-shadow: 0 -8px 28px rgba(34,78,70,.14);
  }
  .file-batch-actions { display: grid; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .file-batch-actions .btn { min-width: 0; min-height: 44px; padding: 6px 2px; font-size: 12px; }
  #page-files.selection-mode { padding-bottom: calc(174px + env(safe-area-inset-bottom)); }
  .file-action-sheet { place-items: end center; padding: 0; }
  .file-action-card {
    width: 100%; max-height: 80dvh; padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }
  #files-table tr.directory-row { cursor: pointer; }
  #page-files .toolbar-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .btn, .panel-head .btn { min-height: 44px; }
  .dropzone { display: none; }
  .breadcrumbs { width: 100%; min-width: 0; flex-wrap: nowrap; font-family: var(--font); font-size: 13px; }
  .breadcrumbs button { min-width: 0; max-width: 100%; min-height: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .breadcrumbs button:last-child { flex: 1; text-align: left; }
  .breadcrumbs .sep { display: none; }
  .media-grid { grid-template-columns: minmax(0, 1fr); }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .media-meta .btn { min-height: 44px; }
  .transfer-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 6px; margin-bottom: 10px; }
  .transfer-tabs a { min-width: 0; min-height: 48px; padding: 8px 5px; text-align: center; }
  .upload-panel .upload-hint { display: none; }
  .upload-list-scroll { overflow: visible; }
  #upload-task-list { min-width: 0; grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .upload-row {
    width: 100%; min-width: 0; min-height: 0; padding: 12px;
    grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
  }
  .upload-name { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; }
  .upload-meta { grid-column: 1 / -1; white-space: normal; }
  .upload-progress { grid-column: 1 / -1; height: 8px; }
  .upload-state { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; }
  .upload-error { max-width: none; white-space: normal; overflow-wrap: anywhere; }
  .upload-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); margin-top: 2px; }
  .upload-actions .btn { width: 100%; min-height: 44px; }
  .upload-actions [data-upload-pause], .upload-actions [data-upload-retry], .upload-actions [data-upload-remove] { grid-column: auto; }
  .download-details { min-width: 0; flex-basis: 100%; }
  .download-actions { width: 100%; flex-wrap: wrap; align-items: center; }
  .download-actions .btn { flex: 1 1 74px; min-height: 44px; }
  .download-form input, .download-form select, .download-form .btn { min-height: 44px; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-menu { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 10px; }
  .settings-menu-group { display: block; grid-column: 1 / -1; padding: 9px 5px 0; }
  .settings-menu a { min-width: 0; min-height: 48px; padding: 8px; white-space: normal; font-size: 13px; }
  .settings-panel { min-height: 0; }
  .hls-link-actions .btn, .access-item .btn { min-height: 44px; }
  .modal { padding: 8px; }
  .modal-card { max-height: calc(100dvh - 16px); overflow: auto; }
  .document-card { height: calc(100dvh - 16px); max-height: none; overflow: hidden; }
  .document-card .modal-head { padding: 8px 10px; }
  .document-card .modal-actions .muted { display: none; }
  .document-text { padding: 14px; font-size: 13px; }
  .modal-head .icon-btn, .modal-actions .btn { min-height: 44px; }
  .lightbox-card .modal-title { display: none; }
  .lightbox-card .modal-actions { width: 100%; justify-content: space-between; }
  .toast-wrap { left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .share-layout { width: calc(100% - 24px); margin: 16px auto; }
  .share-item .task-main { flex-wrap: wrap; }
  .share-item .task-main .btn { min-height: 44px; }
}

@media (max-width: 1024px) {
  .dashboard-lower { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .type-chart-content { grid-template-columns: minmax(112px, 132px) minmax(0, 1fr); gap: 10px; }
  .type-legend { gap: 8px; }
  .type-legend-item { grid-template-columns: 9px minmax(32px, 1fr) auto 34px; gap: 5px; font-size: 11px; }
  .type-pie { max-width: 132px; }
  .hls-link-row { align-items: flex-start; flex-direction: column; }
  .hls-link-actions { width: 100%; }
  .hls-link-actions .btn { flex: 1; }
}
