:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0b84d8;
  --accent-2: #14b8a6;
  --warning: #b45309;
  --danger: #b42318;
  --success: #047857;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

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

button, .upload-button {
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  white-space: nowrap;
}

button:hover, .upload-button:hover {
  filter: brightness(1.05);
}

button.secondary, button.ghost {
  background: #e6edf5;
  color: var(--ink);
}

button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}

button.danger {
  background: #fee4e2;
  color: var(--danger);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.muted, .status {
  color: var(--muted);
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 48px;
  align-items: center;
  padding: 56px;
  background:
    linear-gradient(rgba(15, 23, 42, 0.74), rgba(15, 23, 42, 0.82)),
    url("https://images.unsplash.com/photo-1557804506-669a67965ba0?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
  color: #fff;
}

.login-copy {
  max-width: 760px;
}

.login-copy h1 {
  font-size: clamp(42px, 6vw, 78px);
  margin-bottom: 22px;
}

.login-copy p:not(.eyebrow) {
  color: rgba(255, 255, 255, 0.82);
  font-size: 22px;
  line-height: 1.45;
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  background: #101828;
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 22px;
  position: sticky;
  top: 0;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  display: inline-flex;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand small {
  color: rgba(255, 255, 255, 0.62);
  display: block;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 7px;
}

nav a {
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.72);
  padding: 12px;
  text-decoration: none;
}

nav a.active, nav a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.sidebar-foot {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar, .panel-head, .preview-toolbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 22px;
}

.topbar-actions, .toolbar, .row-actions, .preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.stats article, .manager, .preview-panel, .settings-panel, .screen-preview-panel, .media-manager-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.03);
}

.stats article {
  padding: 18px;
}

.stats span {
  display: block;
  font-size: 26px;
  font-weight: 850;
  margin-bottom: 6px;
}

.stats small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 20px;
}

.manager, .preview-panel, .settings-panel, .screen-preview-panel, .media-manager-panel {
  padding: 18px;
}

.screen-preview-panel, .media-manager-panel {
  margin-bottom: 20px;
}

.panel-head {
  margin-bottom: 16px;
}

.panel-head p {
  color: var(--muted);
  margin-bottom: 0;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.compact-check {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  white-space: nowrap;
}

.compact-check input, .switch input {
  width: auto;
}

.items {
  display: grid;
  gap: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.ad-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.ad-item.selected {
  border-color: rgba(11, 132, 216, 0.7);
  box-shadow: 0 0 0 3px rgba(11, 132, 216, 0.14);
}

.ad-summary {
  align-items: center;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 14px;
}

.media-thumb {
  aspect-ratio: 16 / 9;
  background: #111827;
  border-radius: 7px;
  color: #fff;
  display: grid;
  font-weight: 800;
  overflow: hidden;
  place-items: center;
}

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

.summary-text h3 {
  font-size: 18px;
  margin-bottom: 7px;
  overflow-wrap: anywhere;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  align-items: center;
  background: #eef6ff;
  border-radius: 999px;
  color: #175cd3;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  min-height: 24px;
  padding: 0 10px;
}

.pill.good {
  background: #ecfdf3;
  color: var(--success);
}

.pill.warn {
  background: #fffaeb;
  color: var(--warning);
}

.pill.off {
  background: #f2f4f7;
  color: var(--muted);
}

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

.wide {
  grid-column: 1 / -1;
}

.two-col {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.switch {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 40px;
}

.upload-button input {
  display: none;
}

.inspector {
  display: grid;
  align-content: start;
  gap: 16px;
}

.preview-panel {
  position: sticky;
  top: 22px;
}

.preview-toolbar {
  margin-bottom: 12px;
}

.preview-stage, .screen-stage {
  aspect-ratio: 16 / 9;
  background: #111827;
  border-radius: 8px;
  color: #fff;
  display: grid;
  overflow: hidden;
  padding: 26px;
  place-items: center;
  text-align: center;
}

.screen-stage {
  padding: 0;
}

.screen-stage > div {
  padding: 34px;
}

.preview-stage h2, .screen-stage h2 {
  font-size: clamp(24px, 4vw, 48px);
  line-height: 1.08;
  margin-bottom: 10px;
}

.preview-stage p, .screen-stage p {
  color: rgba(255, 255, 255, 0.84);
  font-size: 18px;
  margin-bottom: 0;
}

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

.screen-preview-footer {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(130px, auto) minmax(120px, 1fr) auto;
  margin-top: 12px;
}

.progress-track {
  background: #e6edf5;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.progress-track span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  display: block;
  height: 100%;
  transition: width 180ms linear;
  width: 0;
}

.media-list {
  display: grid;
  gap: 10px;
}

.media-row {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 116px minmax(0, 1fr) auto auto;
  padding: 12px;
}

.media-mini {
  aspect-ratio: 16 / 9;
  background: #111827;
  border-radius: 7px;
  overflow: hidden;
}

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

.media-detail {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.media-detail strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-detail span {
  color: var(--muted);
  font-size: 13px;
}

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

.status {
  margin: 14px 0 0;
  min-height: 20px;
}

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

  .sidebar {
    min-height: auto;
    position: static;
  }

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

  .preview-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .login-screen {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .content {
    padding: 18px;
  }

  .topbar, .panel-head, .ad-summary {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .filters, .item-fields, .two-col, .settings-grid, .stats, .screen-preview-footer, .media-row {
    grid-template-columns: 1fr;
  }
}
