:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --text: #17202a;
  --muted: #607083;
  --line: #d8e0e8;
  --primary: #116c5f;
  --primary-dark: #0b4f46;
  --accent: #2563eb;
  --danger: #b42318;
  --amber: #b7791f;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.1);
}

* {
  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;
}

.admin-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 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: #0f766e;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-lockup h1,
.brand-lockup p,
.panel-heading h2 {
  margin: 0;
}

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

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

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

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

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

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

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

.stat-panel.wide {
  grid-column: span 2;
}

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

.stat-panel strong {
  font-size: clamp(1.1rem, 1.6vw, 1.7rem);
  overflow-wrap: anywhere;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-stack {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  font-size: 1rem;
}

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

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

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);
}

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

.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 {
  background: var(--primary-dark);
}

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

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

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

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

.playlist-panel {
  min-height: 520px;
}

.playlist-list {
  display: grid;
  gap: 12px;
}

.playlist-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

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

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

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

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

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

.type-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e6f4f1;
  color: #0f766e;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

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

.item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

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

@media (max-width: 980px) {
  .status-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .stat-panel.wide {
    grid-column: auto;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

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

  .playlist-item {
    grid-template-columns: 1fr;
  }

  .thumb {
    width: 100%;
  }

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

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