@font-face {
  font-family: Alexandria;
  src: url('/dashboard/assets/alexandria.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #10100f;
  --panel: #201f1d;
  --panel-2: #292725;
  --line: #3f3f3b;
  --text: #fff;
  --muted: #babab5;
  --accent: #f094b5;
  --accent-2: #92d6aa;
  --danger: #ff8f98;
  --brand: #8f1440;
  --brand-surface: #480a20;
  --surface-raised: #262321;
  --focus: #f094b5;
}

html { background: var(--bg); }
body {
  min-height: 100vh;
  font-family: Alexandria, sans-serif;
  line-height: 1.55;
  background: radial-gradient(ellipse 55% 36% at 50% -12%, #3c1724 0%, transparent 78%), var(--bg);
}
.page { max-width: 1680px; padding: clamp(20px, 3vw, 48px); }
.hero { align-items: center; gap: 24px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.hero-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: nowrap; min-width: 0; margin-inline-start: auto; }
.hero-actions > * { flex: 0 0 auto; }
.hero-actions .language-picker { display: block; width: 148px; min-width: 0; margin: 0; line-height: 1.2; }
.hero-actions .language-picker select { display: block; width: 100%; height: 42px; min-height: 42px; margin: 0; padding: 8px 30px 8px 12px; font-size: 13px; }
.hero-actions #refreshButton { height: 42px; min-height: 42px; padding: 8px 14px; white-space: nowrap; }
.hero-actions .access-account-button { height: 42px; min-height: 42px; max-width: 190px; padding: 4px 8px; border-color: transparent; border-radius: 10px; background: transparent; }
.hero-actions .access-account-button:hover { border-color: var(--line); background: var(--surface-raised); }
.hero-actions .access-account-button .access-avatar { width: 32px; height: 32px; border-radius: 50%; font-size: 12px; }
.hero-actions .access-account-copy strong { font-size: 12px; }
.hero-actions .access-account-button small { font-size: 10px; }
.brand-logo { display: block; flex: 0 0 auto; width: 160px; height: auto; margin: 0; object-fit: contain; object-position: left center; }
.language-picker { color: var(--muted); font-size: 12px; font-weight: 500; }
.language-picker select { min-width: 142px; margin-top: 5px; }
.dashboard-tabs { gap: 6px; padding: 6px; margin-bottom: 26px; border-radius: 16px; background: #1a1918; }
.dashboard-tab { min-width: 150px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.dashboard-tab:hover { background: #2b2927; color: var(--text); }
.dashboard-tab[aria-selected='true'] { border-color: var(--brand); background: var(--brand); color: #fff; }
.grid { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); gap: 22px; }
.panel { padding: clamp(20px, 2vw, 30px); border-radius: 20px; background: linear-gradient(155deg, #23211f, #1b1a19); box-shadow: 0 18px 48px #0003; }
.panel h2 { margin: 0 0 12px; font-size: clamp(21px, 1.7vw, 27px); font-weight: 600; letter-spacing: -.035em; }
.panel h3 { font-size: 18px; font-weight: 600; letter-spacing: -.025em; }
.panel > p.muted, .section-title .muted { font-size: 13px; line-height: 1.7; }
.tab-panel > .panel + .panel { margin-top: 22px; }
.device-card, .app-card, .policy-card, .priority-card, .ad-form-card { background: var(--surface-raised); border-color: var(--line); box-shadow: none; }
.device-card, .app-card { border-radius: 16px; }
.device-card:hover, .app-card:hover { transform: translateY(-2px); background: #302d2b; }
.device-card.active { border-color: var(--accent); background: #3a252e; }
.ad-mode, .ad-preview, .ad-empty, .ad-filter-chips, .channel-switch { background: #1a1918; }
.ad-mode:has(input:checked) { background: #3b202a; }
.ad-card-number { background: #482735; color: var(--accent); }
.notice, .app-action-status { border-color: #5a3b48; background: #34222a; }
.notice { line-height: 1.6; }
.app-action-status[data-state='success'] { border-color: #4a7659; }
.app-action-status[data-state='failed'] { border-color: #8b4551; }
.coverage-table th { background: #242220; }
.coverage-table th, .coverage-table td { border-bottom-color: #3f3f3b; }
.coverage-pill { background: #363330; }
.coverage-pill.yes { background: #23452e; }
.ad-filter-chip[aria-pressed='true'], .channel-switch button[aria-pressed='true'] { background: var(--brand); color: #fff; }
input, textarea, select {
  min-height: 44px;
  border-radius: 11px;
  background: #151514;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
input::placeholder, textarea::placeholder { color: #8f8f8b; }
input[type='file'] { padding: 9px; }
input[type='checkbox'] { min-height: 0; accent-color: var(--brand); }
label { color: #dddcd9; font-size: 13px; font-weight: 500; }
label > input, label > select, label > textarea { display: block; margin-top: 7px; }
label.checkbox-row > input, label:has(> input[type='checkbox']) > input { display: inline-block; margin-top: 0; }
.row > label { flex: 1 1 230px; min-width: min(100%, 230px); }
button { min-height: 43px; border: 1px solid transparent; border-radius: 11px; background: var(--brand); color: white; font: 600 13px Alexandria, sans-serif; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
button:hover { background: #aa1f53; }
button:active { transform: translateY(1px); }
button.secondary { background: #302e2b; color: var(--text); }
button.secondary:hover { background: #3a3734; border-color: var(--accent); }
button.ghost { background: transparent; color: var(--accent); }
button.ghost:hover { background: #3b242e; }
button.danger, .danger-action { background: #3b2027 !important; color: var(--danger) !important; border-color: #8b4551 !important; }
button.danger:hover, .danger-action:hover { background: #50232d !important; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, .device-card:focus-visible, .app-card:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px #f094b555;
}
summary { cursor: pointer; color: var(--accent); }
.pill { background: #2d2a28; }
.banner-card img { background: #151514; }
.apps-context { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); align-items: end; gap: 14px; }
.apps-target-field { min-width: 0; }
.apps-target-field label { display: block; }
.apps-target-field select { display: block; width: 100%; max-width: 440px; }
.apps-context .muted { grid-column: 1 / -1; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.apps-layout { display: grid; grid-template-columns: minmax(270px, 330px) minmax(0, 1fr); gap: 22px; align-items: start; }
.apps-sidebar { display: grid; gap: 11px; position: sticky; top: 18px; }
.apps-sidebar .section-title { margin-bottom: 0; gap: 12px; }
.apps-sidebar .section-title p { margin: 0; }
.apps-sidebar .section-title h2 { margin-bottom: 2px; }
.apps-sidebar label { margin-top: 7px; }
.apps-sidebar input, .apps-sidebar select { margin-top: 0; }
.apps-sidebar-hint { margin: 3px 0 0; font-size: 12px; }
.apps-new-button { white-space: nowrap; padding-inline: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px !important; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.app-catalog-list { display: grid; gap: 7px; max-height: min(64vh, 770px); overflow-y: auto; padding: 2px; }
.app-catalog-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #262321; }
.app-catalog-item[data-selected='true'] { border-color: var(--accent); background: #37232b; }
.app-catalog-item .app-select { display: grid; grid-template-columns: 42px minmax(0, 1fr); grid-column: 1; gap: 11px; align-items: center; padding: 0; min-height: 42px; border: 0; background: transparent; text-align: start; }
.app-catalog-item .app-select:hover { background: transparent; }
.app-catalog-item .app-select strong, .app-catalog-item .app-select small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-catalog-item .app-select strong { color: #fff; font-size: 13px; }
.app-catalog-item .app-select small { color: var(--muted); font-size: 11px; font-weight: 400; }
.app-catalog-item .app-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--brand-surface); color: var(--accent); font-size: 18px; font-weight: 700; }
.apps-detail-panel { min-height: 360px; }
.apps-detail-panel .app-grid { display: block; }
.apps-detail-panel .app-card { padding: 0; border: 0; background: transparent; cursor: default; }
.apps-detail-panel .app-card:hover { transform: none; background: transparent; }
.app-workspace-header { display: flex; align-items: center; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.app-workspace-header .app-avatar { display: grid; place-items: center; width: 64px; height: 64px; flex: 0 0 auto; border-radius: 15px; background: var(--brand-surface); color: var(--accent); font-size: 28px; font-weight: 700; }
.app-workspace-header h2 { margin: 0 0 3px; }
.app-workspace-header code { display: block; max-width: 100%; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.app-workspace-badges { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 22px; }
.app-device-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 20px;
  margin: 18px 0 22px;
  padding: 16px 18px;
  border: 1px solid #694351;
  border-radius: 14px;
  background: linear-gradient(120deg, #35232b, #282523 72%);
}
.app-device-actions h3 { margin: 0; color: var(--text); font-size: 16px; font-weight: 600; }
.app-action-buttons { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.app-action-buttons button, .app-action-download { min-height: 42px; }
.app-action-buttons button { padding: 9px 15px; }
.app-action-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.app-action-download:hover { border-color: var(--accent); background: #302e2b; color: var(--text); }
.app-action-download:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px #f094b555; }
.app-device-actions > .install-unavailable, .app-device-actions > .notice { grid-column: 1 / -1; margin: 0; }
.app-fleet-results { grid-column: 1 / -1; min-width: 0; }
.app-fleet-results:empty { display: none; }
.app-fleet-summary { margin: 0; color: var(--muted); font-size: 13px; }
.app-fleet-results details { margin-top: 8px; }
.app-fleet-results details > summary { font-size: 13px; }
.app-fleet-result-list { display: grid; gap: 0; max-height: 220px; overflow: auto; margin-top: 8px; border-top: 1px solid var(--line); }
.app-fleet-result-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.app-fleet-result-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.app-fleet-result-row > span:last-child { flex: 0 0 auto; color: var(--muted); text-align: end; }
.app-fleet-result-row[data-state='queued'] > span:last-child { color: var(--accent-2); }
.app-fleet-result-row[data-state='skipped'] > span:last-child, .app-fleet-result-row[data-state='failed'] > span:last-child { color: var(--danger); }
.app-workspace-section { margin-top: 12px !important; padding: 2px 0 0 !important; border-top: 1px solid var(--line); }
.app-workspace-section summary { padding: 16px 0; font-weight: 600; color: #fff !important; }
.app-workspace-section summary::marker { color: var(--accent); }
.app-workspace-section[open] summary { color: var(--accent) !important; }
.app-workspace-section > form, .app-workspace-section > .stack, .app-workspace-section > div { margin-bottom: 18px; }
.app-danger-zone { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.apps-history { margin-top: 22px; }
.reset-dialog { background: #211f1e; }
::selection { background: var(--brand); color: #fff; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 980px) { .apps-layout { grid-template-columns: 1fr; } .apps-sidebar { position: static; } .app-catalog-list { max-height: 320px; } }
@media (max-width: 700px) {
  .page { padding: 16px; }
  .hero { align-items: center; gap: 8px; margin-bottom: 18px; padding-bottom: 14px; }
  .brand-logo { width: clamp(78px, 24vw, 112px); }
  .hero-actions { width: auto; align-items: center; gap: 4px; }
  .hero-actions .language-picker { width: clamp(94px, 28vw, 116px); }
  .hero-actions #refreshButton { padding: 8px; font-size: 12px; }
  .hero-actions .access-account-button { width: 38px; min-width: 38px; max-width: 38px; padding: 3px; justify-content: center; }
  .hero-actions .access-account-copy { display: none; }
  .hero-actions .access-account-button .access-avatar { width: 30px; height: 30px; }
  .dashboard-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .dashboard-tab { flex: 0 0 auto; min-width: 132px; }
  .panel { padding: 18px; }
  .section-title, .published-header { align-items: flex-start; flex-direction: column; }
  .apps-sidebar .section-title { align-items: center; flex-direction: row; }
  .app-device-actions { grid-template-columns: 1fr; padding: 14px; }
  .app-action-buttons { justify-content: flex-start; }
  .apps-context { grid-template-columns: 1fr; }
  .apps-target-field select { max-width: none; }
  .app-fleet-result-row { align-items: flex-start; flex-direction: column; gap: 2px; }
}
@media (max-width: 420px) { .page { padding: 12px; } }
@media (prefers-reduced-motion: reduce) { button, .device-card, .app-card { transition: none; } }
