:root {
  --bg: #0d121a;
  --panel: #131b26;
  --panel-soft: #192332;
  --line: #253449;
  --text: #e5edf7;
  --muted: #9db0c9;
  --accent: #4b8dff;
  --accent-2: #63d3ff;
  --danger: #ff6b7a;
  --sidebar-width: 340px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, #182437 0%, var(--bg) 48%);
  color: var(--text);
}

a {
  color: var(--accent-2);
}

#filesApp.layout, .layout {
  display: grid;
  grid-template-columns: minmax(280px, var(--sidebar-width)) 1fr;
  min-height: 100dvh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.explorer-left {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-width: 0;
}

.files-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.explorer-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-height: 0;
  flex: 1 1 auto;
  align-items: stretch;
}

.explorer-tree {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-width: 0;
  overflow: auto;
  padding: 0;
}

.panel {
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.panel:last-child {
  border-right: none;
}

.sidebar {
  background: linear-gradient(180deg, #111927 0%, #0f1622 100%);
}

h1, h2, h3 {
  margin: 0 0 12px;
}

.status-line {
  color: var(--muted);
  margin-bottom: 14px;
}

.side-links {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.link-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  text-decoration: none;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.source-item,
.share-item,
li,
.tree-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 6px;
}

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

.source-status {
  color: #8cc27c;
  font-size: 12px;
}

.source-status.offline {
  color: #f9ae6d;
}

#shareUserSelect {
  min-height: 140px;
  width: 100%;
  overflow: auto;
}

.active,
.source-item.active {
  border-color: var(--accent);
  background: #173055;
}

.share-item {
  gap: 4px;
  cursor: pointer;
}

.share-item.selected,
.share-item.active {
  border-color: var(--accent);
  background: #173055;
}

.share-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.share-kind,
.share-meta {
  color: var(--muted);
  font-size: 12px;
}

.folder-tree {
  display: flex;
  flex-direction: column;
  align-content: flex-start;
  gap: 0;
  min-height: 0;
  overflow: auto;
  padding-right: 0;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  cursor: pointer;
  padding-top: 6px;
  padding-bottom: 6px;
}

.tree-item.selected,
.tree-item.active {
  border-color: var(--accent);
  background: #173055;
}

.tree-item .tree-expander {
  min-height: 24px;
  min-width: 24px;
  border-radius: 6px;
  padding: 0;
  line-height: 0;
}

.tree-expander-placeholder {
  display: inline-block;
  min-width: 24px;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.tree-icon {
  width: 18px;
}

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

.share-pill {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

.search-input {
  background: #101826;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
}

.explorer-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  margin-bottom: 0;
}

.explorer-split {
  display: grid;
  grid-template-columns: minmax(240px, var(--tree-width, 320px)) 10px 1fr;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.explorer-split .explorer-tree {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101826;
  padding: 8px;
}

.explorer-split .folder-tree {
  flex: 1 1 auto;
  padding-right: 0;
}

.explorer-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101826;
  overflow: hidden;
}

.files-pane .explorer-list {
  min-height: 0;
  overflow: auto;
  flex: 1 1 auto;
  border: none;
  border-radius: 0;
}

.explorer-resizer {
  width: 10px;
  cursor: col-resize;
  background: linear-gradient(180deg, rgba(37, 52, 73, 0.35), rgba(37, 52, 73, 0.7));
  border: 1px solid var(--line);
  border-radius: 8px;
}

.explorer-resizer:hover {
  background: linear-gradient(180deg, rgba(75, 141, 255, 0.35), rgba(75, 141, 255, 0.7));
  border-color: var(--accent);
}

.explorer-toolbar {
  display: grid;
  gap: 10px;
}

.explorer-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--muted);
  align-items: center;
}

.explorer-breadcrumb span {
  cursor: pointer;
}

.explorer-breadcrumb span.active {
  color: var(--text);
  font-weight: 600;
}

.explorer-list {
  border: none;
  border-radius: 0;
  overflow: hidden;
}

.explorer-tree .tree-item {
  border: none;
  border-radius: 0;
  background: transparent;
  padding-top: 2px;
  padding-bottom: 2px;
  min-height: 28px;
  gap: 5px;
}

.explorer-tree .tree-item.active,
.explorer-tree .tree-item.selected {
  border: none;
  background: rgba(75, 141, 255, 0.16);
}

.file-row {
  display: grid;
  grid-template-columns: 1.9fr 0.8fr 0.7fr;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  align-items: center;
}

.file-row.header {
  background: #0f1622;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

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

.file-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.file-row.selected {
  background: rgba(75, 141, 255, 0.1);
  border-left: 3px solid var(--accent);
}

.file-row .cell {
  min-width: 0;
}

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

.toolbar .chip {
  cursor: pointer;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #162235;
  color: var(--muted);
  padding: 6px 10px;
  min-height: 30px;
  align-items: center;
}

.toolbar .chip.active {
  border-color: var(--accent);
  color: var(--text);
}

.file-row.header .sortable {
  cursor: pointer;
}

.file-row.header .sortable:hover {
  color: var(--text);
}

.context-menu {
  position: fixed;
  display: grid;
  gap: 6px;
  background: #0f1622;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  z-index: 10;
  min-width: 180px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.context-menu button {
  width: 100%;
  min-height: 30px;
}

.icon {
  margin-right: 8px;
}

.explorer-list button {
  min-height: 30px;
  padding: 4px 9px;
}

.admin-explorer-card {
  min-height: 520px;
}

.admin-viewer-path {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #0f1622;
}

.admin-viewer-path span {
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.admin-empty-state {
  padding: 18px 14px;
  color: var(--muted);
}

.admin-share-actions {
  margin-bottom: 0;
}

.source-tree-item {
  font-weight: 600;
}

.card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.explorer-action-toolbar {
  display: block;
}

.toolbar-group {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid #253449;
  border-radius: 10px;
  padding: 4px;
  background: rgba(19, 27, 38, 0.72);
}

.toolbar-icon-row {
  gap: 6px;
}

.toolbar-gap {
  display: inline-block;
  width: 10px;
}

.toolbar-gap--section {
  width: 18px;
}

.tool-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
}

.tool-icon svg {
  width: 16px;
  height: 16px;
  justify-content: center;
  stroke: currentColor;
}

.explorer-action-toolbar button {
  min-width: 34px;
  padding: 0 8px;
}

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 22, 0.62);
}

.upload-sheet {
  width: min(640px, 94vw);
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.upload-subtitle {
  margin: 0;
  color: var(--muted);
}

.upload-dropzone {
  border: 2px dashed #304764;
  border-radius: 12px;
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  background: #101826;
  transition: all 180ms ease;
}

.upload-dropzone.dragging {
  border-color: var(--accent);
  color: #d7e9ff;
  background: rgba(75, 141, 255, 0.1);
}

.upload-summary {
  min-height: 20px;
}

.upload-actions {
  justify-content: flex-end;
}

.storage-toolbar {
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(120deg, rgba(75, 141, 255, 0.08), rgba(99, 211, 255, 0.04));
  border: 1px solid #28405f;
  border-radius: 12px;
  padding: 10px;
}

.storage-toolbar.placeholder .storage-badge {
  border-color: #3f546f;
}

.storage-widget {
  display: grid;
  gap: 8px;
  min-width: 320px;
  flex: 1;
}

.storage-head {
  display: grid;
  gap: 2px;
}

.storage-title {
  color: var(--text);
  font-weight: 600;
}

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

.storage-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #8ec4ff;
  font-size: 13px;
}

.storage-stats.empty {
  color: var(--muted);
}

.storage-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #0b121b;
  border: 1px solid #2a4468;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(99, 211, 255, 0.2);
}

.storage-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6ec6ff, #4f8eff, #83ffce);
  box-shadow: 0 0 20px rgba(99, 211, 255, 0.5);
  transition: width 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

.storage-glow {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.75;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.0) 65%);
  filter: blur(1px);
  transition: left 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

.storage-badge {
  min-width: 220px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  color: #8ec4ff;
  border: 1px solid #2e4c77;
  background: rgba(10, 20, 30, 0.6);
  display: inline-flex;
  align-items: center;
}

.storage-badge.empty {
  color: #9aa7b8;
}

@keyframes storage-float {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-1px);
  }
}

.storage-badge {
  animation: storage-float 1.9s ease-in-out infinite alternate;
}

.upload-native-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.picker-btn {
  cursor: pointer;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #22324b;
  color: var(--text);
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
}

.picker-btn:hover {
  border-color: var(--accent);
}

.picker-btn.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.picker-label {
  color: var(--muted);
  min-width: 135px;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
  background: #101826;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 10px;
}

input[type="text"],
input[type="password"] {
  flex: 1;
}

button {
  cursor: pointer;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #22324b;
  color: var(--text);
  padding: 7px 12px;
}

button:hover {
  border-color: var(--accent);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
}

thead th {
  color: var(--muted);
  font-weight: 600;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

progress {
  width: 100%;
  height: 12px;
  border-radius: 8px;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: #0f1622;
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.perm-form {
  display: grid;
  gap: 8px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(260px, var(--sidebar-width)) 1fr;
  }

  #filesApp.layout {
    grid-template-columns: minmax(320px, 360px) 1fr;
  }

  #filesApp .explorer-workspace {
    grid-template-columns: 1fr;
  }

  .explorer-split {
    grid-template-columns: 1fr;
  }

  .explorer-resizer {
    display: none;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
