:root {
  --pink: #f72585;
  --pink-dark: #c71065;
  --pink-soft: #fff0f7;
  --ink: #171217;
  --muted: #6f6870;
  --line: #e8dfe4;
  --paper: #ffffff;
  --wash: #fff9fc;
  --success: #08775f;
  --warning: #8a5200;
  --danger: #b42335;
  --shadow: 0 18px 50px rgba(46, 8, 28, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #fff 0%, var(--wash) 54%, #fff 100%);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--pink-dark); }
img, video { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.05; margin-bottom: .6rem; letter-spacing: -.035em; }
h2 { font-size: 1.35rem; line-height: 1.2; margin-bottom: .85rem; }
h3 { font-size: 1rem; margin-bottom: .4rem; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 78px;
  padding: 10px max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.app-brand { display: block; height: 58px; }
.app-brand img { width: 180px; height: 58px; object-fit: contain; object-position: left center; }
.app-nav { display: flex; align-items: center; gap: 6px; }
.app-nav a { min-height: 44px; padding: 11px 13px; display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; border-radius: 12px; font-weight: 750; }
.app-nav a:hover { background: var(--pink-soft); color: var(--pink-dark); }
.nav-toggle { display: none; width: 48px; height: 48px; border: 1px solid var(--line); background: white; border-radius: 14px; font-size: 1.5rem; }

.page-shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 80px; }
.page-shell.narrow { width: min(720px, calc(100% - 32px)); }
.page-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-title p { color: var(--muted); margin-bottom: 0; }
.eyebrow { margin: 0 0 7px; color: var(--pink-dark) !important; text-transform: uppercase; letter-spacing: .15em; font-size: .76rem; font-weight: 900; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 65ch; }

.panel-card, .property-card, .media-card, .screen-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-card { padding: clamp(20px, 3vw, 32px); margin-bottom: 24px; }
.panel-card.flush { padding: 0; overflow: hidden; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 24px; align-items: start; }
.three-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }

.stack-form { display: grid; gap: 17px; }
.inline-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.inline-form > label { flex: 1 1 210px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
fieldset { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; }
legend { padding: 0 8px; font-weight: 850; }
label { display: grid; gap: 7px; color: #382f37; font-size: .92rem; font-weight: 800; }
label small, .fine-print, .help { color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  color: var(--ink);
  background: white;
  border: 1px solid #cabfc6;
  border-radius: 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(247, 37, 133, .12); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--pink); }
.check-row, .choice-row { display: flex; flex-wrap: wrap; gap: 12px; }
.check-card { display: flex; flex: 1 1 170px; align-items: center; gap: 10px; min-height: 52px; padding: 12px 14px; background: var(--wash); border: 1px solid var(--line); border-radius: 13px; }

button, .button, .primary-button, .secondary-button, .danger-button, .icon-button {
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary-button { color: white; background: linear-gradient(135deg, var(--pink), var(--pink-dark)); box-shadow: 0 10px 24px rgba(199, 16, 101, .22); }
.primary-button:hover { filter: brightness(.96); }
.secondary-button, .button { color: var(--ink); background: white; border-color: #cfc3ca; }
.secondary-button:hover, .button:hover { border-color: var(--pink); color: var(--pink-dark); }
.danger-button { color: var(--danger); background: #fff5f6; border-color: #f1b9c0; }
.small-button { min-height: 40px; padding: 8px 12px; border-radius: 10px; font-size: .88rem; }
button:disabled { opacity: .55; cursor: wait; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.alert { margin: 0 0 20px; padding: 14px 16px; border-radius: 13px; border: 1px solid; }
.alert.success { color: var(--success); background: #effcf8; border-color: #a7e1cf; }
.alert.error { color: var(--danger); background: #fff4f5; border-color: #f0b5bd; }
.alert.warning { color: var(--warning); background: #fff9e9; border-color: #ead49a; }
.alert.info { color: #244766; background: #f1f8ff; border-color: #b7d7f2; }
.hidden { display: none !important; }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 28px 16px; background: radial-gradient(circle at 50% -10%, #401126 0, #160d13 38%, #080708 100%); }
.auth-card { width: min(500px, 100%); padding: clamp(24px, 5vw, 42px); background: rgba(255,255,255,.98); border: 1px solid rgba(255,255,255,.4); border-radius: 28px; box-shadow: 0 35px 100px rgba(0,0,0,.5); }
.install-card { width: min(720px, 100%); }
.auth-logo { display: block; width: min(330px, 100%); height: 170px; margin: -15px auto 8px; object-fit: contain; }
.auth-card h1 { font-size: 2.5rem; }
.auth-card .fine-print { margin: 22px 0 0; text-align: center; font-size: .85rem; }

.upload-drop {
  min-height: 170px;
  padding: 28px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 2px dashed #d0b5c3;
  border-radius: 18px;
  background: var(--wash);
  cursor: pointer;
}
.upload-drop:hover, .upload-drop.dragging { border-color: var(--pink); background: var(--pink-soft); }
.upload-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upload-drop strong { display: block; font-size: 1.15rem; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--pink-soft); border-radius: 13px; }
.file-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-stage { position: relative; display: grid; min-height: 320px; place-items: center; overflow: hidden; background: #100d0f; border-radius: 18px; }
.editor-stage canvas { display: block; max-width: 100%; max-height: 560px; }
.editor-empty { color: white; text-align: center; padding: 40px; }
.editor-controls { display: grid; gap: 14px; }
.color-input { padding: 4px; min-height: 48px; }
.range-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.range-line input { padding: 0; }
.range-value { min-width: 42px; text-align: right; }
.upload-progress { height: 12px; overflow: hidden; border-radius: 20px; background: #eee3e9; }
.upload-progress > span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--pink-dark), var(--pink)); transition: width .2s; }

.property-card { padding: 20px; }
.property-card.archived { opacity: .68; }
.property-meta { color: var(--muted); font-size: .9rem; }
.property-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 22px; }

.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; background: #f3eef1; color: #51474e; font-size: .78rem; font-weight: 850; }
.status-pill.live { color: var(--success); background: #ebfaf5; }
.status-pill.offline { color: var(--danger); background: #fff0f2; }
.dot { width: 8px; height: 8px; background: currentColor; border-radius: 50%; }

.dashboard-grid { display: grid; grid-template-columns: minmax(330px, .78fr) minmax(0, 1.4fr); gap: 24px; align-items: start; }
.screen-card { overflow: hidden; margin-bottom: 22px; }
.screen-heading { padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.screen-heading h2 { margin: 0; }
.remote-controls { padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; background: #170f14; }
.remote-controls button { min-height: 58px; color: white; background: #33242d; border-color: #4c3542; }
.remote-controls button:hover, .remote-controls button.active { background: var(--pink-dark); }
.screen-settings { padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: end; gap: 12px; border-bottom: 1px solid var(--line); }
.screen-settings label { min-width: 150px; flex: 1; }
.playlist-list { list-style: none; padding: 0; margin: 0; }
.playlist-item { display: grid; grid-template-columns: 32px 78px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.playlist-item:last-child { border-bottom: 0; }
.drag-handle { color: var(--muted); font-size: 1.35rem; cursor: grab; }
.playlist-thumb { width: 78px; height: 52px; object-fit: cover; border-radius: 9px; background: #160f13; }
.playlist-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.playlist-meta { color: var(--muted); font-size: .8rem; }
.playlist-actions { display: flex; gap: 6px; }
.playlist-actions button { width: 40px; min-height: 40px; padding: 0; }
.empty-state { padding: 38px 22px; color: var(--muted); text-align: center; }

.media-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.media-tools > * { flex: 1 1 180px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.media-card { overflow: hidden; box-shadow: none; }
.media-preview { position: relative; height: 148px; background: #160f13; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; }
.media-preview .type-badge { position: absolute; top: 9px; right: 9px; padding: 4px 8px; color: white; background: rgba(0,0,0,.72); border-radius: 999px; font-size: .72rem; font-weight: 900; }
.media-body { padding: 14px; }
.media-body h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-body p { color: var(--muted); font-size: .82rem; }
.media-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.media-actions .danger-button { grid-column: 1 / -1; }

.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li { padding: 13px 0; border-bottom: 1px solid var(--line); }
.activity-list li:last-child { border: 0; }
.activity-list time { display: block; color: var(--muted); font-size: .8rem; }
.user-table { width: 100%; border-collapse: collapse; }
.user-table th, .user-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.user-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; max-width: min(420px, calc(100% - 36px)); padding: 14px 18px; color: white; background: #21151c; border: 1px solid #543344; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.28); }

.player-page { min-height: 100vh; overflow: hidden; background: #000; }
.player-stage { position: fixed; inset: 0; display: grid; place-items: center; background: #000; }
.player-stage img, .player-stage video { width: 100%; height: 100%; object-fit: cover; }
.player-message { color: white; padding: 5vw; text-align: center; font-size: clamp(1.5rem, 4vw, 4rem); }
.player-blackout { position: fixed; inset: 0; z-index: 10; background: #000; }
.player-badge { position: fixed; right: 18px; bottom: 14px; z-index: 5; padding: 7px 10px; color: rgba(255,255,255,.66); background: rgba(0,0,0,.55); border-radius: 8px; font-size: 12px; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .app-nav { position: absolute; display: none; top: calc(100% + 1px); left: 12px; right: 12px; padding: 10px; flex-direction: column; align-items: stretch; background: white; border: 1px solid var(--line); border-radius: 0 0 18px 18px; box-shadow: var(--shadow); }
  .app-nav.open { display: flex; }
  .split-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid > aside { order: 2; }
}

@media (max-width: 640px) {
  .page-shell, .page-shell.narrow { width: min(100% - 22px, 1220px); padding-top: 28px; }
  .app-brand img { width: 150px; }
  .page-title { align-items: start; flex-direction: column; }
  .form-grid, .three-grid { grid-template-columns: 1fr; }
  .panel-card { padding: 18px; border-radius: 18px; }
  .remote-controls { grid-template-columns: repeat(2, 1fr); }
  .playlist-item { grid-template-columns: 25px 62px minmax(0, 1fr); }
  .playlist-thumb { width: 62px; height: 46px; }
  .playlist-actions { grid-column: 2 / -1; }
  .user-table, .user-table tbody, .user-table tr, .user-table td { display: block; width: 100%; }
  .user-table thead { display: none; }
  .user-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .user-table td { border: 0; padding: 5px 0; }
}
