:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #eef4f7;
  --ink: #15202b;
  --muted: #657386;
  --line: #dce5eb;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #2563eb;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 18px 42px rgba(20, 32, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), rgba(15, 118, 110, 0.12)),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
}

button:hover {
  background: var(--primary-strong);
}

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

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

button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--surface-strong);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.icon-button:hover {
  background: var(--surface-strong);
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-content: center;
  padding: 24px;
}

.brand-mark {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.login-view h1 {
  margin: 0 0 26px;
  text-align: center;
  font-size: 32px;
  letter-spacing: 0;
}

.login-form {
  width: min(420px, calc(100vw - 48px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-form label:not(.check-row),
.space-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input,
.space-label select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

.login-form input:focus,
.space-label select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-form label + label {
  margin-top: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 18px;
  color: var(--ink);
  font-size: 14px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.login-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, auto) minmax(140px, auto);
  gap: 10px;
}

.login-actions button {
  width: 100%;
}

.button-icon {
  font-size: 19px;
  line-height: 1;
}

.error-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.account-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.account-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

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

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

.account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 14px 0;
}

.account-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.account-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.account-form {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.account-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-form input,
.account-form select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

.account-form input:focus,
.account-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-message {
  display: none;
  min-height: 20px;
  margin: 0;
  color: var(--primary-strong);
  font-size: 14px;
}

.form-message.visible {
  display: block;
}

.form-message.error {
  color: var(--danger);
}

.transfer-summary {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-actions .secondary-button {
  min-height: 38px;
}

.admin-page {
  min-height: 100vh;
}

.admin-workspace {
  align-content: start;
}

.admin-workspace > .form-message {
  min-height: 0;
}

.admin-section h3 {
  margin: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.admin-card,
.admin-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  align-content: center;
  padding: 13px;
}

.admin-card span,
.admin-card small,
.admin-list-body span {
  color: var(--muted);
}

.admin-card span {
  font-size: 12px;
  font-weight: 800;
}

.admin-card strong {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.admin-card small {
  font-size: 12px;
  font-weight: 700;
}

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

.admin-section h3 {
  font-size: 15px;
}

.admin-section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(96px, 0.8fr) minmax(96px, 0.8fr) minmax(96px, 0.8fr) minmax(180px, 1.5fr) minmax(84px, 0.7fr) auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.admin-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-filters input,
.admin-filters select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 10px;
}

.admin-filters input:focus,
.admin-filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.admin-filter-actions {
  display: flex;
  gap: 8px;
}

.admin-filter-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.admin-list {
  display: grid;
}

.admin-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.admin-list-item:last-child {
  border-bottom: 0;
}

.admin-list-body {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.admin-list-body strong,
.admin-list-body span {
  overflow-wrap: anywhere;
}

.admin-list-body span,
.admin-list-side {
  font-size: 13px;
  font-weight: 700;
}

.admin-list-side {
  color: var(--ink);
  white-space: nowrap;
}

.admin-meter {
  width: min(220px, 100%);
}

.main-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(15, 118, 110, 0.95));
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  gap: 16px;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.toolbar-left {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: end;
  gap: 16px;
}

.space-label {
  width: min(220px, 42vw);
}

.breadcrumbs {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 6px;
  padding-bottom: 2px;
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumbs button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  padding: 0 10px;
}

.breadcrumbs button:hover {
  background: var(--surface-strong);
}

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

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

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.status-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.status-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-card > strong {
  font-size: 20px;
}

.status-card > small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.capacity-card {
  align-content: stretch;
}

.capacity-meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.capacity-meter > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.2s ease;
}

.used-meter > div {
  background: #df6b57;
}

.free-meter > div {
  background: #2f9f75;
}

.status-action {
  width: max-content;
  min-height: 30px;
  margin-top: 6px;
  padding: 0 12px;
  font-size: 13px;
}

.upload-progress {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

#uploadBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.15s ease;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-bar.hidden {
  display: none;
}

.filter-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 13px;
}

.filter-chip:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.filter-chip.active {
  border-color: rgba(47, 159, 117, 0.42);
  background: rgba(47, 159, 117, 0.12);
  color: var(--primary-strong);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}

.selection-bar.hidden {
  display: none;
}

.selection-bar strong {
  color: var(--ink);
  font-size: 14px;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.selection-actions button {
  min-height: 34px;
  padding: 0 12px;
}

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

.danger-button:hover {
  background: var(--danger-bg);
}

.file-panel {
  position: relative;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.file-panel.drop-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 159, 117, 0.16);
}

.drop-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(248, 251, 252, 0.86);
}

.drop-overlay.hidden {
  display: none;
}

.drop-overlay > div {
  display: grid;
  min-width: 150px;
  min-height: 110px;
  place-items: center;
  gap: 8px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  padding: 18px;
}

.drop-overlay svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.drop-overlay strong {
  font-size: 18px;
}

.message {
  display: none;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  padding: 12px 16px;
}

.message.visible {
  display: block;
}

.message.error {
  color: var(--danger);
  background: var(--danger-bg);
}

.file-list {
  display: grid;
}

.file-header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 140px 170px 48px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 10px 14px;
}

.selection-heading,
.selection-cell {
  display: none;
}

.file-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 140px 170px 48px;
  align-items: center;
  min-height: 58px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 14px;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: #f8fbfc;
}

.file-row:focus-within {
  background: #f8fbfc;
}

.file-row.selected {
  background: rgba(47, 159, 117, 0.08);
}

.file-panel.selection-mode .file-header,
.file-panel.selection-mode .file-row {
  grid-template-columns: 34px 38px minmax(0, 1fr) 140px 170px 48px;
}

.file-panel.selection-mode .selection-heading,
.file-panel.selection-mode .selection-cell {
  display: grid;
  place-items: center;
}

.selection-cell input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.parent-row {
  background: #fcfdfd;
}

.parent-row .file-name button {
  font-size: 18px;
  letter-spacing: 0;
}

.parent-row .file-icon {
  background: #eef6f8;
  color: var(--accent);
}

.file-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--primary);
}

.file-icon-folder {
  background: #fff7df;
  color: #b7791f;
}

.file-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.file-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.file-name button {
  display: block;
  width: 100%;
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
  padding: 0;
  text-align: left;
}

.file-name button:hover {
  color: var(--accent);
}

.file-name small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-meta {
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.row-actions button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
}

.row-actions button:hover {
  background: var(--surface-strong);
}

.row-actions .danger {
  color: var(--danger);
}

.row-menu-button {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
}

.entry-menu {
  position: fixed;
  z-index: 120;
  display: grid;
  min-width: 176px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.entry-menu.hidden {
  display: none;
}

.entry-menu button {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  padding: 8px 10px;
  text-align: left;
}

.entry-menu button:hover,
.entry-menu button:focus-visible {
  background: var(--surface-strong);
}

.entry-menu button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.entry-menu .danger {
  color: var(--danger);
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-content: center;
  color: var(--muted);
  border-bottom: 0;
  text-align: center;
}

.preview-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

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

.preview-dialog h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.preview-body {
  display: grid;
  max-height: calc(100vh - 112px);
  overflow: auto;
  place-items: center;
  background: #f7fafb;
  padding: 16px;
}

.preview-body img,
.preview-body video {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  border-radius: 8px;
}

.preview-body pre {
  width: 100%;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 780px) {
  .admin-page .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-page .topbar-actions {
    justify-content: stretch;
  }

  .admin-page .topbar-actions button {
    flex: 1;
  }

  .toolbar,
  .toolbar-left {
    align-items: stretch;
    flex-direction: column;
  }

  .space-label {
    width: 100%;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

.toolbar-actions button {
  flex: 1;
}

  .login-actions {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: 34px minmax(0, 1fr) 44px;
    grid-template-areas:
      "icon name actions"
      "icon size actions"
      "icon modified actions";
    align-items: start;
  }

  .file-panel.selection-mode .file-row {
    grid-template-columns: 34px 34px minmax(0, 1fr) 44px;
    grid-template-areas:
      "select icon name actions"
      "select icon size actions"
      "select icon modified actions";
  }

  .file-header {
    display: none;
  }

  .selection-cell {
    grid-area: select;
    align-self: center;
  }

  .file-icon {
    grid-area: icon;
  }

  .file-name {
    grid-area: name;
  }

  .file-size {
    grid-area: size;
  }

  .file-modified {
    grid-area: modified;
  }

  .row-actions {
    grid-area: actions;
    flex-wrap: wrap;
  }

  .selection-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-actions {
    justify-content: stretch;
  }

  .selection-actions button {
    flex: 1;
  }

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

  .admin-filters {
    grid-template-columns: 1fr;
  }

  .admin-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .admin-list-item {
    grid-template-columns: 1fr;
  }

  .admin-list-side {
    white-space: normal;
  }
}
