:root {
  --font-body: -apple-system, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;

  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbfd;
  --color-surface-offset: #f0f0f2;
  --color-border: rgba(0, 0, 0, 0.08);

  --color-text: #1d1d1f;
  --color-text-muted: #6e6e73;
  --color-text-faint: #a1a1a6;
  --color-text-inverse: #ffffff;

  --color-primary: #0071e3;
  --color-primary-hover: #0077ed;
  --color-primary-active: #005bb5;

  --color-success: #1d8a4e;
  --color-success-bg: rgba(29, 138, 78, 0.1);
  --color-danger: #d70015;
  --color-danger-bg: rgba(215, 0, 21, 0.08);
  --color-warning: #b45309;
  --color-warning-bg: rgba(180, 83, 9, 0.1);
  --color-neutral-bg: rgba(0, 0, 0, 0.05);

  --color-bot-video: #0071e3;
  --color-bot-video-bg: rgba(0, 113, 227, 0.1);
  --color-bot-clicker: #7a39bb;
  --color-bot-clicker-bg: rgba(122, 57, 187, 0.1);
  --color-bot-market: #b07a00;
  --color-bot-market-bg: rgba(180, 122, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.10);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --space-12: 48px; --space-16: 64px;

  --transition: 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100dvh;
}

img, video { display: block; max-width: 100%; }
button { cursor: pointer; font: inherit; color: inherit; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }

a, button, input, select, textarea {
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), color var(--transition), transform var(--transition);
}

.hidden { display: none !important; }

/* ==================== LOGIN ==================== */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--color-bg);
}

.login-overlay.active { display: flex; }

.login-card {
  width: min(100%, 400px);
  padding: var(--space-10);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
  border-radius: var(--radius-md);
  background: rgba(0, 113, 227, 0.1);
  color: var(--color-primary);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.login-card h1 {
  margin-bottom: var(--space-2);
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.login-card > p {
  margin-bottom: var(--space-8);
  font-size: 14px;
  color: var(--color-text-muted);
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: 13px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  padding: 12px 14px;
  font-size: 15px;
}

.login-card input:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.login-card .btn { width: 100%; margin-top: var(--space-2); }

.login-error {
  margin: 0 0 var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-size: 13px;
}

/* ==================== ЛЕЙАУТ + САЙДБАР ==================== */

.app-layout {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar-top { display: flex; flex-direction: column; gap: var(--space-8); }

.sidebar-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  background: rgba(0, 113, 227, 0.1);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-1); }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  width: 100%;
}

.sidebar-link:hover { background: var(--color-surface-offset); color: var(--color-text); }

.sidebar-link.active {
  background: rgba(0, 113, 227, 0.1);
  color: var(--color-primary);
}

.sidebar-link-icon { font-size: 14px; opacity: 0.8; }

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-backup-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.sidebar-backup-btn:hover { background: var(--color-neutral-bg); color: var(--color-text); }

.current-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.current-user div { min-width: 0; display: flex; flex-direction: column; }

.current-user strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.current-user span {
  color: var(--color-text-muted);
  font-size: 12px;
}

.logout-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-btn:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.app-shell {
  flex: 1;
  max-width: 1280px;
  padding: var(--space-8) var(--space-6);
  min-width: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-8);
  margin-bottom: var(--space-10);
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}

.topbar-copy h1 {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.topbar-copy p {
  color: var(--color-text-muted);
  font-size: 15px;
  max-width: 46ch;
}

.topbar-stats { display: flex; gap: var(--space-3); flex-wrap: wrap; }

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  min-width: 108px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.stat-card span { font-size: 12px; color: var(--color-text-muted); font-weight: 500; }
.stat-card strong { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card-green strong { color: var(--color-success); }
.stat-card-red strong { color: var(--color-danger); }
.stat-card-blue strong { color: var(--color-primary); }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: var(--space-6); align-items: start; }

.panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.form-panel { position: sticky; top: var(--space-6); }
.panel-head { margin-bottom: var(--space-5); }
.panel-head h2 { font-size: 19px; font-weight: 700; margin-bottom: var(--space-1); }
.panel-head p { font-size: 13px; color: var(--color-text-muted); }

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
.field-grid .field { margin-bottom: 0; }

.field label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.field small { font-size: 12px; color: var(--color-text-faint); }
.file-name-display { font-size: 12px; color: var(--color-primary); word-break: break-all; }

.field input[type="text"],
.field input[type="file"],
.field input[type="password"],
.field select,
.field textarea {
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 15px;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.field textarea { resize: vertical; min-height: 72px; }

.btn { border-radius: var(--radius-full); font-size: 15px; font-weight: 600; padding: 12px 20px; }
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

#submitBtn { width: 100%; }
#submitBtn { position: sticky; bottom: 16px; z-index: 20; box-shadow: var(--shadow-lg); }

.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); font-size: 13px; padding: 6px 14px; }
.btn-danger:hover { background: rgba(215, 0, 21, 0.14); }

.btn-secondary { background: var(--color-neutral-bg); color: var(--color-text); font-size: 13px; padding: 6px 14px; }
.btn-secondary:hover { background: rgba(0, 0, 0, 0.08); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  padding: 6px 4px;
}
.btn-link:hover { text-decoration: underline; }

.list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-6); flex-wrap: wrap; }
.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.filters select {
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
}

.filters select:focus { outline: none; border-color: var(--color-primary); }

.creative-list { display: grid; gap: var(--space-4); margin-top: var(--space-5); }

.creative-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-5);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  transition: box-shadow var(--transition), transform var(--transition);
}

.creative-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.creative-preview {
  width: 140px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-offset);
  position: relative;
}

.creative-image-preview, .creative-video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.file-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-faint); font-size: 12px;
  background: var(--color-surface-offset);
}

.video-preview-wrap { position: relative; width: 100%; height: 100%; }

.video-preview-button {
  position: absolute; bottom: var(--space-2); left: var(--space-2); right: var(--space-2);
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px);
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 8px; border-radius: var(--radius-sm);
  text-align: center;
}

.creative-meta { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.creative-topline { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.creative-topline h3 { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }

.inline-controls { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.inline-select {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: var(--color-neutral-bg);
  color: var(--color-text-muted);
  cursor: pointer;
}

.inline-select.badge { background: var(--color-neutral-bg); color: var(--color-text-muted); }
.inline-select.badge-active { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(29, 138, 78, 0.25); }
.inline-select.badge-paused { background: var(--color-neutral-bg); color: var(--color-text-muted); }
.inline-select.badge-usage { background: rgba(0, 113, 227, 0.1); color: var(--color-primary); border-color: rgba(0, 113, 227, 0.25); }
.inline-select.badge-bot-video { background: var(--color-bot-video-bg); color: var(--color-bot-video); border-color: rgba(0, 113, 227, 0.25); }
.inline-select.badge-bot-clicker { background: var(--color-bot-clicker-bg); color: var(--color-bot-clicker); border-color: rgba(122, 57, 187, 0.25); }
.inline-select.badge-bot-market { background: var(--color-bot-market-bg); color: var(--color-bot-market); border-color: rgba(180, 122, 0, 0.25); }

.inline-select.link-select {
  background: transparent;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
}

.inline-select.link-select:focus { border-style: solid; }

.creative-info { font-size: 13px; color: var(--color-text-muted); display: flex; gap: var(--space-4); flex-wrap: wrap; }
.creative-info strong { color: var(--color-text); font-weight: 600; }

.notes-textarea {
  width: 100%;
  resize: none;
  overflow: hidden;
  min-height: 40px;
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
}

.notes-textarea::placeholder { color: var(--color-text-faint); }

.notes-textarea:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.stocks-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.stocks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.btn-file-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(0, 113, 227, 0.1);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  cursor: pointer;
}

.btn-file-label:hover { background: rgba(0, 113, 227, 0.16); }

.hidden-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.stocks-list { display: flex; flex-direction: column; gap: var(--space-1); }

.stock-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  border: 1px solid var(--color-border);
}

.stock-chip-name {
  font-size: 12px;
  color: var(--color-text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.stock-chip-name:hover { color: var(--color-primary); }

.stock-chip-delete {
  font-size: 11px;
  color: var(--color-text-faint);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.stock-chip-delete:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.stocks-empty { font-size: 12px; color: var(--color-text-faint); }

.creative-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ==================== АККАУНТЫ / ДОМЕНЫ ==================== */

.resource-panel { max-width: 760px; }

.resource-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.resource-form-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.resource-form input[type="text"] {
  flex: 1;
  min-width: 220px;
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 15px;
}

.resource-form input[type="text"]:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.resource-form select {
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
}

.btn-resource-add { white-space: nowrap; }

.credentials-toggle {
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.credentials-toggle summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  list-style: none;
}

.credentials-toggle summary::-webkit-details-marker { display: none; }
.credentials-toggle[open] summary { margin-bottom: var(--space-3); }

.credentials-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.credentials-grid label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.credentials-grid input {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text);
}

.credentials-grid input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.resource-filters { margin-bottom: var(--space-4); }

.resource-filters select {
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
}

.resource-list { display: flex; flex-direction: column; gap: var(--space-2); }

.resource-row-wrap {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.resource-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.resource-row-wrap .resource-row { border-bottom: none; }

.resource-value {
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}

.resource-status-select {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.resource-status-select.status-free {
  background: var(--color-success-bg);
  color: var(--color-success);
  border-color: rgba(29, 138, 78, 0.25);
}

.resource-status-select.status-in-use {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: rgba(180, 83, 9, 0.25);
}

.resource-delete, .resource-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.resource-delete:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.resource-icon-btn:hover { background: rgba(0, 113, 227, 0.1); color: var(--color-primary); }

.credentials-panel {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4);
  background: var(--color-surface-offset);
}

.credentials-panel .credentials-grid { margin-bottom: var(--space-3); }
.credentials-panel input { background: var(--color-surface); }

.credentials-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

/* ==================== АДМИНКА ПОЛЬЗОВАТЕЛЕЙ ==================== */

.users-panel { max-width: 860px; }

.user-form {
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
}

.user-form .field { margin-bottom: var(--space-4); }
.user-form .btn { width: 100%; }

.users-list { display: flex; flex-direction: column; gap: var(--space-2); }

.user-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.user-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.user-info strong { font-size: 14px; overflow-wrap: anywhere; }
.user-info span { font-size: 12px; color: var(--color-text-muted); }

.you-label {
  display: inline-block;
  margin-left: var(--space-1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 113, 227, 0.1);
  color: var(--color-primary);
  font-size: 10px;
  vertical-align: middle;
}

.user-status {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.user-active { background: var(--color-success-bg); color: var(--color-success); }
.user-disabled { background: var(--color-danger-bg); color: var(--color-danger); }

.user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ==================== ОБЩИЕ БЛОКИ ==================== */

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--space-16) var(--space-8); color: var(--color-text-muted);
}

.empty-icon { font-size: 32px; color: var(--color-text-faint); margin-bottom: var(--space-4); }
.empty-state h3 { color: var(--color-text); margin-bottom: var(--space-2); font-size: 17px; }
.empty-state p { font-size: 14px; max-width: 36ch; }

@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-offset) 25%, #e5e5e7 50%, var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-image { width: 140px; aspect-ratio: 3 / 4; }
.skeleton-heading { height: 18px; width: 60%; margin-bottom: var(--space-2); }
.skeleton-text { height: 12px; width: 90%; margin-bottom: var(--space-2); }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(8px); }

.modal-dialog {
  position: relative; z-index: 1;
  max-width: min(820px, 92vw); width: 100%;
  background: #000; border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute; top: var(--space-3); right: var(--space-3); z-index: 2;
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.25); }
.modal-video { width: 100%; max-height: 80vh; display: block; }
body.modal-open { overflow: hidden; }

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
  }

  .sidebar-top { flex-direction: row; align-items: center; gap: var(--space-4); }
  .sidebar-nav { flex-direction: row; }
  .sidebar-bottom { flex-direction: row; align-items: center; }
  .sidebar-backup-btn { width: auto; white-space: nowrap; }
  .current-user { border-top: none; padding: 0; }

  .layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .creative-card { grid-template-columns: 1fr; }
  .creative-preview { width: 100%; aspect-ratio: 16 / 10; }
  .topbar { align-items: flex-start; }

  .resource-form-row { flex-direction: column; }
  .resource-form input[type="text"] { min-width: 0; }
  .credentials-grid { grid-template-columns: 1fr; }

  .user-row { align-items: flex-start; flex-wrap: wrap; }
  .user-actions { width: 100%; justify-content: flex-start; }
}
