:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --ink: #ffffff;
  --row: #fafafa;
  --row-alt: #ffffff;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  --folder-icon: #f59e0b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.title {
  font-weight: 700;
  font-size: 18px;
}

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

.truncate {
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 800px) {
  .truncate {
    max-width: 40vw;
  }
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
  transition: background 0.2s;
}

.container.drag-over {
  background: #f0f9ff;
  border: 2px dashed var(--accent);
  border-radius: 14px;
}

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

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 9px 13px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

button:hover,
.btn:hover {
  background: #f8fafc;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.thead,
.row {
  display: grid;
  grid-template-columns: 1fr 160px 120px 1fr 200px;
  gap: 0;
}

.thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.row {
  background: var(--row);
  transition: background 0.15s;
}

.row:hover {
  background: #f1f5f9;
}

.row:nth-child(even) {
  background: var(--row-alt);
}

.row:nth-child(even):hover {
  background: #f1f5f9;
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.action-btn:hover {
  background: #f0f9ff;
  border-color: var(--accent);
  color: #1d4ed8;
}

.action-icon {
  font-size: 18px;
  line-height: 1;
}

.cell {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.cell a.link {
  font-size: 12px;
  color: #2563eb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: underline;
  transition: color 0.2s;
}

.cell a.link:hover {
  color: #1d4ed8;
}

.cell .copy {
  font-size: 12px;
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.cell.actions {
  gap: 6px;
  justify-content: flex-start;
}

/* Compact action buttons for table rows */
.cell.actions .btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  gap: 4px;
}

.cell.actions form {
  display: inline;
}

.hide-b {
  border-bottom: 0;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #eef2ff;
  border-color: #e0e7ff;
  color: #4f46e5;
}

/* Breadcrumb navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.crumb-link {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.crumb-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

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

.crumb-current {
  color: var(--fg);
  font-weight: 600;
}

/* Folder styles */
.folder-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
  transition: color 0.2s;
}

.folder-link:hover {
  color: var(--accent);
}

.folder-icon {
  font-size: 18px;
  line-height: 1;
}

/* Modal (above header) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  z-index: 1000;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1100px, calc(100vw - 40px));
  height: min(90vh, 800px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  z-index: 1001;
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.modal-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100% - 110px);
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

textarea {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 10px;
  font-size: 14px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

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

.logout {
  margin-left: 12px;
}

.hidden {
  display: none;
}

/* Settings modal */
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-control input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
}

.setting-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.setting-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.setting-value {
  font-weight: 600;
  min-width: 80px;
  text-align: right;
  color: var(--accent);
}

.setting-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Progress bar */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  width: 0;
  display: none;
  z-index: 2000;
  transition: width 0.15s ease;
}

@media (max-width: 900px) {
  .thead,
  .row {
    grid-template-columns: 1fr 120px 100px 1fr 180px;
  }
}

@media (max-width: 640px) {
  .thead,
  .row {
    grid-template-columns: 1fr 110px 90px 1fr 160px;
  }
}
