:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --text-secondary: #475569;
  --brand: #1d4ed8;
  --brand-2: #0ea5e9;
  --link: #1d4ed8;
  --danger: #dc2626;
  --line: #dbe3ef;
  --card-border: #ecf0f6;
  --surface-soft: #e2e8f0;
  --surface-soft-2: #f1f5f9;
  --surface-white: #ffffff;
  --bg-grad-a: #dbeafe;
  --bg-grad-b: #e0f2fe;
  --shape-a: #60a5fa;
  --shape-b: #34d399;
  --overlay: rgba(15, 23, 42, 0.45);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1f242c;
    --card: #2a3038;
    --ink: #e8ecf1;
    --muted: #b0bac6;
    --text-secondary: #d1d9e3;
    --brand: #3b82f6;
    --brand-2: #0ea5e9;
    --link: #0ea5e9;
    --danger: #ef4444;
    --line: #3f4754;
    --card-border: #3a424f;
    --surface-soft: #3a434f;
    --surface-soft-2: #343c46;
    --surface-white: #313944;
    --bg-grad-a: rgba(96, 165, 250, 0.14);
    --bg-grad-b: rgba(45, 212, 191, 0.1);
    --shape-a: #3b82f6;
    --shape-b: #14b8a6;
    --overlay: rgba(2, 6, 23, 0.62);
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, var(--bg-grad-a) 0%, transparent 40%),
    radial-gradient(circle at 85% 10%, var(--bg-grad-b) 0%, transparent 35%),
    var(--bg);
  min-height: 100vh;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: opacity 200ms;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

a:visited {
  opacity: 0.7;
}

.file-link {
  cursor: pointer;
  text-decoration: underline;
}

.page {
  width: min(1100px, 92vw);
  margin: 28px auto;
  position: relative;
  z-index: 2;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.35;
  z-index: 1;
}

.bg-shape-a {
  width: 280px;
  height: 280px;
  background: var(--shape-a);
  top: -90px;
  right: -40px;
}

.bg-shape-b {
  width: 220px;
  height: 220px;
  background: var(--shape-b);
  bottom: -80px;
  left: -50px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  animation: reveal 300ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-card {
  max-width: 480px;
  margin: 80px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.field-row,
.upload-row,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  flex-wrap: wrap;
}

.field-row label {
  min-width: 180px;
  color: var(--muted);
}

.login-card .field-row {
  display: grid;
  grid-template-columns: 115px 1fr;
  column-gap: 10px;
  align-items: center;
}

.login-card .field-row label {
  min-width: 0;
}

.login-card .field-row input {
  width: 100%;
  min-width: 0;
}

input,
select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  min-width: 180px;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.password-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.password-input-wrap input {
  padding-right: 68px;
}

.toggle-password-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
  opacity: 0.7;
}

.generate-password-btn {
  position: absolute;
  right: 34px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px;
  opacity: 0.7;
}

.toggle-password-btn:hover,
.toggle-password-btn.is-active,
.generate-password-btn:hover {
  opacity: 1;
}

input[type="checkbox"] {
  min-width: 0;
  width: auto;
  padding: 0;
  border: 0;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  margin-right: 4px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
}

.btn-ghost {
  color: var(--ink);
  background: var(--surface-soft);
}

.btn-danger {
  color: #fff;
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

#filesSection .upload-row {
  margin-top: 32px;
}

.collapsible-section {
  margin-bottom: 28px;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--card-border);
  cursor: pointer;
  font-size: 1.06rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  transition: opacity 0.2s ease;
}

.collapsible-header:hover {
  opacity: 0.75;
}

.collapse-icon {
  width: 0.92rem;
  height: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  color: var(--muted);
  font-size: 0;
  line-height: 0;
}

.collapse-icon::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}

.collapsible-title {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.collapsible-count {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.retention-info {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.collapsible-section.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.collapsible-content {
  padding: 8px 0 0;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.collapsible-section.collapsed .collapsible-content {
  max-height: 0;
  padding: 0;
}

.col-filename { width: 37%; }
.col-size     { width: 10%; white-space: nowrap; }
.col-date     { width: 16%; white-space: nowrap; }
.col-owner    { width: 12%; }
.col-actions  { width: 25%; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  flex: 1;
}

.section-header .btn {
  flex-shrink: 0;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.4rem;
  padding: 4px 6px;
  border-radius: 50%;
  transition: color 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  line-height: 1;
}

.icon-btn:hover {
  opacity: 0.75;
}

.icon-btn:active {
  transform: scale(0.95);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.icon-btn.spinning {
  animation: spin 0.6s linear infinite;
  pointer-events: none;
}

.login-actions {
  margin-left: 125px;
  justify-content: flex-end;
}

.remember-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-left: 125px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
}

.users-table .role-cell {
  padding-right: 2px;
  white-space: nowrap;
}

.users-table .role-toggle-col {
  width: 1%;
  white-space: nowrap;
  padding-left: 2px;
  padding-right: 2px;
}

.users-table .role-toggle-btn {
  padding: 0 2px;
}

.muted {
  color: var(--muted);
}

.message {
  min-height: 20px;
  color: var(--text-secondary);
  white-space: pre-line;
}

.error-message {
  color: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px 20px;
  width: min(480px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-expires {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.share-url-input {
  width: 100%;
  min-width: 0;
  font-size: 0.85rem;
  background: var(--surface-soft-2);
  color: var(--ink);
  cursor: text;
  user-select: all;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.link-btn {
  background: transparent;
  border: 0;
  color: var(--link);
  cursor: pointer;
  font-weight: 600;
}

.delete-btn {
  background: transparent;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font-weight: 600;
}

.file-action-btn {
  font-size: 1.02rem;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.link-btn:hover,
.delete-btn:hover {
  background: var(--surface-soft-2);
}

.users-table .link-btn,
.users-table .delete-btn {
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  line-height: inherit;
  width: auto;
  height: auto;
  border-radius: 0;
  display: inline;
  padding: 0;
}

.users-table .link-btn:hover,
.users-table .delete-btn:hover {
  background: transparent;
}

.owner-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-soft);
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.file-age-indicator {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.95rem;
  line-height: 1;
  vertical-align: text-bottom;
}

.file-age-indicator.warning {
  color: #ca8a04;
}

.file-age-indicator.expired {
  color: var(--danger);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.users-table th {
  white-space: nowrap;
}

.users-table th,
.users-table td {
  vertical-align: top;
}

.users-table th.user-col,
.users-table td.user-col {
  width: 20%;
  white-space: nowrap;
}

.users-table th.role-cell,
.users-table td.role-cell {
  width: 1%;
  white-space: nowrap;
  padding-right: 1px;
}

.users-table th.role-toggle-col,
.users-table td.role-toggle-col {
  width: 1%;
  white-space: nowrap;
  padding-left: 0;
  padding-right: 18px;
}

.users-table .role-toggle-btn {
  display: inline-block;
  min-width: 14px;
  text-align: left;
}

.users-table th.mfa-toggle-col,
.users-table td.mfa-toggle-col {
  width: 1%;
  white-space: nowrap;
  padding-left: 0;
  padding-right: 20px;
}

.users-table .mfa-toggle-btn {
  display: inline-block;
  min-width: 14px;
  text-align: left;
}

.users-table .action-col {
  white-space: nowrap;
  width: 1%;
}

.users-table th.mfa-required-cell,
.users-table td.mfa-required-cell {
  width: 1%;
  white-space: nowrap;
  padding-right: 1px;
  text-align: center;
}

.users-table th.mfa-cell,
.users-table td.mfa-cell {
  width: 1%;
  white-space: nowrap;
  padding-right: 20px;
}

.users-table th.status-cell,
.users-table td.status-cell {
  width: 28%;
  padding-right: 20px;
}

.hidden {
  display: none !important;
}

.mfa-prompt {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.mfa-qr {
  display: block;
  width: 160px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: var(--surface-white);
  margin: 8px 0 12px;
}

.drop-zone {
  position: relative;
}

.drop-zone.drop-zone-active {
  background-color: rgba(29, 78, 216, 0.06);
}

@media (max-width: 760px) {
  .page {
    width: 95vw;
  }

  .field-row label {
    min-width: 120px;
  }

  .login-card .field-row {
    grid-template-columns: 120px 1fr;
  }

  input,
  select {
    flex: 1;
    min-width: 0;
  }

  .login-actions {
    margin-left: 0;
    justify-content: flex-start;
  }

  .remember-row {
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

