:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d8e0ea;
  --text: #152235;
  --muted: #667489;
  --primary: #174ea6;
  --primary-2: #2b6be7;
  --danger: #b42318;
  --ok: #067647;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: linear-gradient(180deg, #eef3fa, #f8fbfe); color: var(--text); }
a { color: inherit; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar { background: #0f1f38; color: #fff; padding: 16px 0; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 28px 0 16px; }
.page-head h1 { margin: 0 0 6px; }
.muted { color: var(--muted); }
.grid-2, .grid-3 { display: grid; gap: 18px; margin-bottom: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 16px 34px rgba(15, 31, 56, 0.06); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label span, fieldset legend { display: block; margin-bottom: 6px; font-size: 0.93rem; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; background: #fff; }
select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; background: #fff; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.check-grid { display: grid; gap: 10px; }
.check-item { display: flex; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border-radius: 12px; border: 1px solid var(--line); padding: 0 14px; background: #fff; text-decoration: none; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: 0; }
.btn.ghost { background: #fff; }
.btn.danger { background: #fff5f5; color: var(--danger); border-color: #f3b3b3; }
.icon-btn { min-width: 42px; padding: 0; font-weight: 700; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 0 10px; font-size: 0.84rem; background: #eaf0f8; }
.badge.ok { background: #e7f6ec; color: var(--ok); }
.badge.paused { background: #fff4e5; color: #b54708; }
.flash-stack { display: grid; gap: 10px; margin: 16px 0; }
.flash { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.flash.success { background: #ecfdf3; border-color: #abefc6; }
.flash.error { background: #fff4f3; border-color: #fecdca; }
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: min(1080px, calc(100% - 32px)); display: grid; grid-template-columns: 1.1fr 0.9fr; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: 0 24px 50px rgba(15, 31, 56, 0.12); }
.login-hero { padding: 40px; background: linear-gradient(135deg, #14315c, #2559a8); color: #fff; }
.login-card { padding: 34px; }
.login-hint { margin-top: 16px; color: var(--muted); }
.player-body { background: #050b12; color: #fff; }
.player-shell { min-height: 100vh; display: flex; flex-direction: column; }
.player-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; background: rgba(3, 8, 16, 0.82); position: fixed; inset: 0 0 auto 0; z-index: 10; }
.player-stage { flex: 1; display: grid; place-items: center; padding-top: 64px; }
.player-empty { color: #9fb0c7; font-size: 1.2rem; }
.player-media { width: 100vw; height: calc(100vh - 64px); object-fit: contain; background: #000; }
.player-body-kiosk .player-stage { padding-top: 0; }
.player-body-kiosk .player-media { height: 100vh; }
.admin-top-grid { align-items: start; }
.compact-card { padding: 16px; }
.compact-card h2 { margin-top: 0; margin-bottom: 12px; font-size: 1.05rem; }
.compact-form { gap: 10px; }
.compact-form input, .compact-form textarea, .compact-form select { padding: 10px 12px; }
.compact-table th, .compact-table td { padding: 9px 8px; font-size: 0.94rem; }
.ad-list { display: grid; gap: 10px; }
.ad-list-head, .ad-row { display: grid; grid-template-columns: 96px minmax(0, 2.2fr) 110px 96px minmax(0, 1.3fr) minmax(220px, 1.1fr); gap: 10px; align-items: center; }
.ad-list-head { padding: 0 4px 6px; color: var(--muted); font-size: 0.84rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.ad-row { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fbfdff; }
.ad-cell { min-width: 0; overflow: hidden; }
.ad-status-cell { display: flex; align-items: center; }
.ad-main-row { display: grid; grid-template-columns: minmax(160px, 1.1fr) minmax(120px, 0.9fr) minmax(140px, 1fr); gap: 6px; align-items: center; min-width: 0; }
.compact-input { padding: 8px 10px; border-radius: 10px; }
.strong-input { font-weight: 700; }
.title-input, .desc-input, .url-input { min-width: 0; width: 100%; }
.meta-stack, .screen-stack { display: grid; gap: 6px; }
.screen-stack { min-width: 0; }
.screen-pill { display: inline-flex; flex-direction: column; gap: 2px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; }
.screen-pill small { color: var(--muted); }
.sort-input { width: 78px; padding: 8px 10px; }
.text-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.text-link:hover { text-decoration: underline; }
.tv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.tv-card { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, #f9fbff, #eef4fb); text-decoration: none; color: inherit; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.tv-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(15, 31, 56, 0.08); border-color: #b8cae4; }
.tv-icon { width: 64px; flex: 0 0 64px; display: grid; place-items: center; }
.tv-icon-screen { width: 52px; height: 34px; display: block; border-radius: 8px; border: 3px solid #17345f; background: linear-gradient(135deg, #16315a, #2e67c4); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2); position: relative; }
.tv-icon-screen::after { content: ""; position: absolute; inset: 7px 10px; border-radius: 4px; background: rgba(255,255,255,0.18); }
.tv-icon-foot { width: 22px; height: 4px; display: block; margin-top: 7px; border-radius: 999px; background: #17345f; position: relative; }
.tv-icon-foot::before, .tv-icon-foot::after { content: ""; position: absolute; top: -5px; width: 8px; height: 8px; border-bottom: 3px solid #17345f; }
.tv-icon-foot::before { left: 1px; transform: rotate(28deg); }
.tv-icon-foot::after { right: 1px; transform: rotate(-28deg); }
.tv-card-body { display: grid; gap: 6px; min-width: 0; }
.tv-card-title { font-weight: 700; }
.tv-card-meta { color: var(--muted); font-size: 0.92rem; word-break: break-word; }
.tv-card-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

@media (max-width: 1400px) {
  .ad-list-head, .ad-row { grid-template-columns: 90px minmax(0, 2fr) 100px 90px minmax(0, 1.1fr) minmax(200px, 1fr); }
  .ad-main-row { grid-template-columns: minmax(150px, 1fr) minmax(110px, 0.8fr) minmax(120px, 0.9fr); }
}

@media (max-width: 1180px) {
  .ad-list-head, .ad-row { grid-template-columns: 90px minmax(0, 1.8fr) 90px 90px minmax(0, 1fr) minmax(180px, 0.9fr); }
  .ad-main-row { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .grid-2, .grid-3, .login-shell, .form-grid { grid-template-columns: 1fr; }
  .page-head, .topbar-inner { flex-direction: column; align-items: flex-start; }
  .tv-card { align-items: flex-start; }
  .ad-list-head { display: none; }
  .ad-row { grid-template-columns: 1fr; }
  .ad-status-cell { margin-bottom: 2px; }
}
