* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, #eff6ff 0%, #f8fafc 45%, #f1f5f9 100%);
  color: #0f172a;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 56px; }

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #25f4ee);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.28);
}

.header-text { flex: 1; min-width: 0; }
h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1rem; font-weight: 700; }
.header-path { color: #64748b; font-size: 0.82rem; margin-top: 4px; }
.header-path code {
  background: #e2e8f0;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.78rem;
  word-break: break-all;
}

.link-home {
  color: #2563eb;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.08);
  white-space: nowrap;
}
.link-home:hover { background: rgba(37, 99, 235, 0.14); }

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05);
}

.card--login { max-width: 400px; }

.hint { color: #94a3b8; font-size: 0.85rem; }
.card--login .hint { margin-bottom: 14px; }

.field {
  display: block;
  margin-bottom: 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #475569;
}
.field input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 400;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.field-hint {
  display: block;
  font-weight: 400;
  color: #94a3b8;
  font-size: 0.76rem;
  margin-top: 4px;
}

.message { padding: 8px 12px; border-radius: 10px; font-size: 0.84rem; margin-top: 10px; }
.message.error { background: #fef2f2; color: #991b1b; }
.message.ok { background: #ecfdf5; color: #065f46; }

.btn-primary,
.btn-secondary,
.btn-muted,
.btn-danger,
.btn-play,
.btn-dl {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.86rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: #2563eb; color: #fff; width: 100%; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary--inline { width: auto; margin-top: 4px; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-secondary:disabled { opacity: 0.6; cursor: wait; }

@keyframes ql-spin { to { transform: rotate(360deg); } }

.btn-primary.is-loading,
.btn-secondary.is-loading,
.btn-muted.is-loading,
.btn-cleanup-half.is-loading,
.act-btn.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  opacity: 0.82;
  cursor: wait;
  pointer-events: none;
}
.btn-primary.is-loading .btn-spinner,
.btn-secondary.is-loading .btn-spinner,
.btn-muted.is-loading .btn-spinner,
.btn-cleanup-half.is-loading .btn-spinner,
.act-btn.is-loading .btn-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ql-spin 0.7s linear infinite;
}
.btn-secondary.is-loading .btn-spinner,
.btn-muted.is-loading .btn-spinner,
.btn-cleanup-half.is-loading .btn-spinner,
.act-del.is-loading .btn-spinner {
  border-color: rgba(100, 116, 139, 0.35);
  border-top-color: #2563eb;
}

.btn-muted { background: transparent; color: #64748b; border: 1px solid #cbd5e1; }
.btn-muted:hover { background: #f8fafc; }

/* --- Summary --- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: #dbeafe;
  position: relative;
}
.stat-card-icon::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 3px;
  background: #2563eb;
  opacity: 0.85;
}
.stat-card-icon--size { background: #d1fae5; }
.stat-card-icon--size::after { background: #059669; }
.stat-card-icon--disk { background: #fef3c7; }
.stat-card-icon--disk::after { background: #d97706; border-radius: 50%; inset: 11px; }

.stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  font-weight: 600;
}
.stat-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  margin-top: 2px;
}
.stat-value--sm { font-size: 0.92rem; font-weight: 700; }

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

/* --- Settings --- */
.settings-details { padding: 0; overflow: hidden; }
.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 0.95rem;
  user-select: none;
}
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary::before {
  content: "▸";
  margin-right: 8px;
  color: #94a3b8;
  transition: transform 0.15s;
}
.settings-details[open] .settings-summary::before { transform: rotate(90deg); }
.settings-summary-hint {
  font-weight: 500;
  font-size: 0.8rem;
  color: #94a3b8;
}
.settings-form { padding: 0 20px 18px; border-top: 1px solid #f1f5f9; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  padding-top: 14px;
}
.settings-form .field { margin-bottom: 0; }

/* --- Files section --- */
.files-card { padding: 0; overflow: hidden; }
.files-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.files-head h2 { margin: 0; }
.files-sub { color: #94a3b8; font-size: 0.8rem; margin-top: 3px; }

.files-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-cleanup-half {
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  background: #fffbeb;
  color: #b45309;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn-cleanup-half:hover { background: #fef3c7; border-color: #f59e0b; }
.btn-cleanup-half:disabled { opacity: 0.55; cursor: wait; }

.files-search { flex: 1; min-width: 180px; max-width: 280px; }
.files-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.86rem;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 11px center no-repeat;
}
.files-search input:focus {
  outline: none;
  border-color: #3b82f6;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.files-empty { padding: 28px 20px; text-align: center; }

.table-wrap { overflow-x: auto; }
.files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  table-layout: fixed;
}
.col-file { width: 46%; }
.col-specs { width: 16%; }
.col-time { width: 18%; }
.col-actions { width: 20%; }

.files-table th,
.files-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.files-table th {
  color: #64748b;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 1;
}
.files-table th.th-actions { text-align: right; }
.files-table tbody tr:hover { background: #f8fafc; }
.files-table tbody tr:last-child td { border-bottom: none; }

/* File cell: title + filename */
.file-cell { min-width: 0; }
.file-title {
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-title--muted { color: #64748b; font-weight: 500; }
.file-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  min-width: 0;
}
.file-name-btn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  background: transparent;
  border: none;
  color: #3b82f6;
  cursor: pointer;
  padding: 0;
  max-width: 100%;
  font-weight: 500;
}
.file-name-btn:hover { text-decoration: underline; }
.file-job-chip {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: ui-monospace, monospace;
}

.file-name-cell--editing .file-name-input {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  padding: 6px 8px;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Specs cell */
.file-specs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.chip-size { background: #f1f5f9; color: #475569; }
.chip-res { background: #eff6ff; color: #1d4ed8; }

/* Time cell */
.file-time-age {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.84rem;
}
.file-time-date {
  display: block;
  color: #94a3b8;
  font-size: 0.74rem;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Actions */
.file-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.act-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  transition: background 0.12s;
}
.act-play { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.act-play:hover { background: #dbeafe; }
.act-dl { background: #ecfdf5; color: #047857; border: 1px solid #bbf7d0; }
.act-dl:hover { background: #d1fae5; }
.act-del { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.act-del:hover { background: #fee2e2; }
.act-del:disabled { opacity: 0.5; cursor: wait; }

/* Video modal */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.video-modal[hidden] { display: none !important; }
.video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}
.video-modal-box {
  position: relative;
  width: min(920px, 100%);
  background: #0f172a;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.video-modal-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.video-modal-title {
  flex: 1;
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-word;
}
.video-modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.video-modal-close:hover { background: rgba(255, 255, 255, 0.18); }
.video-player {
  width: 100%;
  max-height: min(70vh, 520px);
  border-radius: 10px;
  background: #000;
}
body.modal-open { overflow: hidden; }

@media (max-width: 720px) {
  .stat-cards { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .files-head { align-items: stretch; }
  .files-toolbar { width: 100%; justify-content: stretch; }
  .files-search { max-width: none; flex: 1; }
  .col-file { width: 38%; }
  .col-specs { width: 18%; }
  .col-time { width: 20%; }
  .col-actions { width: 24%; }
  .files-table th,
  .files-table td { padding: 10px 10px; }
  .act-btn { padding: 6px 7px; font-size: 0.72rem; min-width: 30px; }
}
