:root {
  color-scheme: light;
  --bg: #edf1f5;
  --panel: #ffffff;
  --panel-soft: #f6f8fa;
  --text: #17202a;
  --muted: #5e6d7c;
  --line: #d8e1ea;
  --primary: #0f766e;
  --primary-dark: #0b5d56;
  --accent: #2563eb;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 16px 42px rgba(23, 32, 42, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.62;
}

.admin-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 22px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-lockup h1,
.brand-lockup p,
.page-heading h2,
.files-header h2,
.tool-form h3,
.file-toolbar h3 {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}

.brand-lockup p,
.muted-line {
  color: var(--muted);
  margin-top: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar-actions,
.files-actions,
.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(240px, 1.2fr) minmax(280px, 2fr);
  gap: 12px;
  margin-bottom: 16px;
}

.panel,
.stat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-panel {
  min-height: 92px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.stat-panel span {
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-panel strong {
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.stat-button {
  width: 100%;
  color: inherit;
  text-align: left;
}

.stat-button:hover,
.stat-button:focus-visible {
  border-color: var(--primary);
  outline: none;
  background: #f2fbf9;
}

.storage-stat strong {
  font-size: 1.05rem;
}

.storage-track {
  height: 8px;
  border-radius: 999px;
  background: #e5ebf1;
  overflow: hidden;
}

.storage-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.storage-track.large {
  height: 12px;
}

.page-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.page-nav {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-link {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  font-weight: 700;
}

.page-link:hover,
.page-link.active {
  background: #eef9f7;
  border-color: #9bd2ca;
  color: var(--primary-dark);
}

.page-content {
  min-width: 0;
}

.panel {
  padding: 18px;
}

.admin-page {
  min-height: 560px;
}

.compact-form {
  width: min(420px, calc(100vw - 32px));
}

.page-heading,
.files-header,
.file-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.page-heading h2,
.files-header h2 {
  font-size: 1.16rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--accent);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 140px;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 118px;
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.mini-button {
  border: 0;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.ghost-button,
.mini-button {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger-button {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #ffd5d2;
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
}

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

.page-message {
  padding-left: 4px;
}

.session-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.session-row {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 12px;
}

.session-row.selected {
  border-color: var(--primary);
  background: #eef9f7;
}

.session-row strong,
.session-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row small {
  color: var(--muted);
  margin-top: 3px;
}

.folder-mark {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 38px;
  border-radius: 6px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 800;
}

.files-header {
  align-items: flex-start;
}

.storage-detail {
  display: grid;
  gap: 10px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.storage-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.storage-detail-head strong {
  color: var(--text);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.tool-form {
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tool-form h3,
.file-toolbar h3 {
  font-size: 0.95rem;
}

.muted-control {
  opacity: 0.7;
}

.file-toolbar {
  margin-bottom: 10px;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-row {
  display: grid;
  grid-template-columns: 34px 96px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.row-order {
  width: 28px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.thumb {
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #17202a;
  color: #ffffff;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-main {
  min-width: 0;
}

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

.file-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e6f4f1;
  color: var(--primary);
  padding: 3px 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

.item-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-button {
  min-width: 42px;
  padding: 0 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 840px;
}

.settings-save {
  width: min(260px, 100%);
  margin-top: 8px;
}

.empty-state {
  margin: 42px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1080px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-shell {
    grid-template-columns: 1fr;
  }

  .page-nav {
    position: static;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .page-link {
    text-align: center;
  }

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

@media (max-width: 720px) {
  .admin-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  .status-grid,
  .settings-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .page-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .files-header,
  .file-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .files-actions {
    width: 100%;
  }

  .topbar-actions > *,
  .files-actions > * {
    flex: 1;
  }

  .file-row {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .thumb {
    width: 100%;
    grid-column: 1 / -1;
  }

  .file-main,
  .item-actions {
    grid-column: 1 / -1;
  }

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

  .item-actions > * {
    flex: 1;
  }
}
