:root {
  color-scheme: light;
  --bg: #edf3f6;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --surface-strong: #e6eef2;
  --text: #14212b;
  --muted: #657684;
  --line: #d6e1e7;
  --line-strong: #b8c8d1;
  --accent: #0f766e;
  --accent-strong: #0a5d57;
  --accent-soft: #dff5f1;
  --amber: #a15c05;
  --amber-soft: #fff5df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --ink: #101820;
  --focus: #2f80ed;
  --shadow: 0 18px 44px rgba(19, 32, 42, 0.12);
  --shadow-soft: 0 10px 24px rgba(19, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
.button-like {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

button:hover,
.button-like:hover {
  border-color: var(--line-strong);
  background: #fbfdfe;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.danger,
.danger-button {
  color: var(--danger);
}

.danger-button {
  border-color: #f3b8b1;
  background: var(--danger-soft);
}

.link-button,
.mini-link {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.link-button:hover,
.mini-link:hover {
  background: transparent;
  color: var(--accent-strong);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 440px);
  align-items: center;
  gap: 48px;
  padding: 42px max(28px, 8vw);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(47, 128, 237, 0.08)),
    var(--bg);
}

.auth-brand {
  max-width: 520px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 12px;
}

.auth-brand h1 {
  margin: 28px 0 10px;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 0.95;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.auth-panel {
  display: grid;
  gap: 20px;
  padding: 30px;
  border: 1px solid rgba(214, 225, 231, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-copy span,
.page-kicker {
  display: inline-block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.auth-copy h2,
.topbar h1,
.section-head h2 {
  margin: 4px 0 0;
}

.auth-copy h2 {
  font-size: 30px;
}

.auth-copy p {
  margin: 8px 0 0;
  color: var(--muted);
}

.form-stack,
.surface-form {
  display: grid;
  gap: 14px;
}

.action-wide {
  width: 100%;
}

.notice-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #bfe4df;
  border-radius: 8px;
  background: var(--accent-soft);
}

.notice-card span {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  transition: grid-template-columns 160ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f9fcfd;
}

.sidebar-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 14px 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-brand strong,
.sidebar-brand em {
  display: block;
}

.sidebar-brand em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.collapse-button {
  width: 34px;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0;
  font-size: 22px;
}

.sidebar-collapsed .sidebar-headline {
  padding: 14px 12px;
  flex-direction: column;
  justify-content: flex-start;
}

.sidebar-collapsed .sidebar-brand span:not(.brand-mark),
.sidebar-collapsed .nav-text {
  display: none;
}

.sidebar-collapsed .sidebar-brand {
  display: flex;
}

.sidebar-collapsed .collapse-button {
  transform: none;
}

.nav-list {
  display: grid;
  gap: 6px;
  padding: 14px 10px;
}

.nav-list a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--muted);
}

.nav-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-list a.active .nav-icon {
  background: var(--accent);
  color: #fff;
}

.sidebar-collapsed .nav-list {
  padding: 12px 10px;
  place-items: center;
}

.sidebar-collapsed .nav-list a {
  width: 44px;
  justify-content: center;
  padding: 0;
}

.nav-list a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-list a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.sidebar-footer button {
  width: 100%;
}

.sidebar-collapsed .sidebar-footer {
  padding: 12px 10px 16px;
}

.sidebar-collapsed .sidebar-footer button {
  width: 44px;
  padding: 0;
  margin: 0 auto;
}

.sidebar-collapsed .sidebar-footer .nav-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 86px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 24px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.breadcrumbs button {
  min-height: 28px;
  padding: 0 9px;
  border-color: transparent;
  color: var(--muted);
  background: var(--surface-soft);
}

.toolbar {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.page-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  padding: 20px 24px 28px;
}

.storage-panel,
.file-workspace,
.content-page,
.surface-form {
  min-width: 0;
}

.storage-panel,
.surface-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.storage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.section-head h2 {
  font-size: 18px;
}

.storage-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.nav-list,
.toolbar,
.storage-list {
  scrollbar-width: none;
}

.nav-list::-webkit-scrollbar,
.toolbar::-webkit-scrollbar,
.storage-list::-webkit-scrollbar {
  display: none;
}

.storage-item {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  border-color: transparent;
  background: transparent;
  text-align: left;
}

.storage-item.active {
  border-color: #9edbd4;
  background: var(--accent-soft);
}

.storage-item strong,
.storage-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-item span {
  color: var(--muted);
  font-size: 12px;
}

.storage-tools {
  display: flex;
  gap: 6px;
}

.storage-tools button {
  width: 31px;
  min-height: 31px;
  padding: 0;
}

.file-workspace {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.drop-zone {
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.file-table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--surface);
}

.file-table th,
.file-table td {
  height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.file-table th {
  height: 44px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.file-table tbody tr:hover {
  background: #fffaf0;
}

.file-table tr:last-child td {
  border-bottom: 0;
}

.file-table .name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-icon {
  width: 38px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.dir-row .file-icon {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.file-table .name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-table .select-col {
  width: 46px;
  text-align: center;
}

.file-table .select-col input {
  display: block;
  margin: 0 auto;
}

.file-table .num {
  width: 120px;
  text-align: right;
}

.file-table .actions {
  width: 290px;
  text-align: right;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.row-actions button {
  min-height: 31px;
  padding: 0 9px;
}

.upload-progress {
  display: grid;
  gap: 7px;
  padding: 12px 14px;
  border: 1px solid #f2d69d;
  border-radius: 8px;
  background: var(--amber-soft);
}

.upload-progress > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--amber);
  font-size: 12px;
}

.upload-progress > div > div {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-progress .ghost-button {
  min-height: 30px;
  padding: 0 10px;
  border-color: rgba(146, 99, 14, 0.28);
  color: var(--amber);
  background: rgba(255, 255, 255, 0.52);
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.content-page {
  padding: 20px 24px 28px;
}

.content-page.narrow {
  max-width: 940px;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-layout.single {
  grid-template-columns: 1fr;
}

.surface-form {
  align-content: start;
  padding: 18px;
}

.surface-form.wide {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.switch-row label,
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  white-space: nowrap;
}

.switch-row input,
.inline-check input {
  width: 18px;
  min-height: 18px;
}

.inline-check.setting-check {
  white-space: normal;
}

.inline-check.setting-check span {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-list {
  display: grid;
  gap: 9px;
}

.admin-item {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-item.user-item {
  grid-template-columns: minmax(160px, 1fr) 110px auto auto auto auto;
}

.admin-item.share-item {
  grid-template-columns: minmax(220px, 1fr) 180px 100px minmax(140px, 1fr) auto auto auto auto auto;
}

.admin-item.audit-item {
  grid-template-columns: minmax(240px, 1fr) minmax(160px, 2fr);
}

.admin-item strong,
.admin-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-item span {
  color: var(--muted);
  font-size: 12px;
}

.admin-item.muted {
  display: block;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.two-factor-box {
  display: grid;
  gap: 10px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20, 27, 33, 0.36);
}

.dialog-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.dialog-form.compact {
  width: min(440px, calc(100vw - 28px));
}

.dialog-form.preview-form {
  width: min(980px, calc(100vw - 28px));
  max-height: min(88vh, 900px);
}

.dialog-form header,
.dialog-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-form h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-form footer {
  justify-content: flex-end;
}

.preview-body {
  min-height: 280px;
  max-height: 68vh;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: 66vh;
}

.preview-body pre {
  width: 100%;
  min-height: 280px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    display: flex;
    min-width: 0;
    max-width: 100vw;
    overflow-x: auto;
  }

  .nav-list a {
    flex: 0 0 auto;
  }

  .sidebar-footer {
    display: none;
  }

  .collapse-button {
    display: none;
  }

  .page-grid {
    grid-template-columns: 1fr;
  }

  .storage-panel {
    max-height: 220px;
  }

  .storage-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 1fr);
    overflow-x: auto;
  }

  .settings-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-item,
  .admin-item.user-item,
  .admin-item.share-item,
  .admin-item.audit-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .auth-shell,
  .page-grid,
  .content-page {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
  }

  .toolbar {
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .auth-panel,
  .surface-form {
    padding: 16px;
  }

  .auth-brand h1 {
    font-size: 42px;
  }
}
