:root {
  --primary: #1a73e8;
  --primary-dark: #0b56b6;
  --primary-soft: #e8f0fe;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e1e6ee;
  --text: #1a1f2e;
  --text-muted: #6b7280;
  --danger: #d93025;
  --success: #1e8e3e;
  --warning: #f29900;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(15, 30, 60, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.error { color: var(--danger); margin-top: 8px; font-size: 14px; }
.success { color: var(--success); }

/* ---------- Login ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  z-index: 100;
}
.login-card {
  background: white; padding: 40px; border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-card .logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 600; margin-bottom: 8px;
}
.webnet-logo-login {
  display: block; max-width: 220px; height: auto;
  margin: 0 auto 12px;
}
.login-title {
  font-size: 18px; font-weight: 600; color: var(--text);
  margin: 8px 0 16px;
}
.login-card p.muted { margin-bottom: 6px; }
.login-card input { text-align: left; }
.webnet-logo-sidebar {
  display: block; max-width: 100%; height: auto;
  max-height: 60px; object-fit: contain;
}
.login-card input {
  width: 100%; padding: 12px 14px; margin-top: 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
  box-sizing: border-box;
}
.login-card .btn { width: 100%; margin-top: 16px; }

/* ---------- App layout ---------- */
#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: white;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 6px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand small { display: block; font-size: 12px; color: var(--text-muted); }
.logo-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: block; padding: 10px 14px;
  text-decoration: none; color: var(--text);
  border-radius: 8px; font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: var(--primary-soft); }
.nav-link.active { background: var(--primary); color: white; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }

.content { padding: 28px 36px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 24px; }

.pill { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-ok { background: #e6f4ea; color: var(--success); }
.pill-err { background: #fce8e6; color: var(--danger); }
.pill-warn { background: #fef7e0; color: var(--warning); }

/* ---------- Cards & grids ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  border: 1px solid var(--border);
}
.stat .label { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 32px; font-weight: 700; margin: 0; }
.stat .accent { color: var(--primary); }

/* ---------- Tables ---------- */
.toolbar { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .left, .toolbar .right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #fafbfd; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

.btn {
  padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: filter .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(.95); }
.btn.primary { background: var(--primary); color: white; }
.btn.danger  { background: var(--danger); color: white; }
.btn.ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.success { background: var(--success); color: white; }
.btn.small   { padding: 5px 10px; font-size: 12px; }

input, select, textarea {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-soft); outline-offset: -1px; border-color: var(--primary);
}

/* ---------- Media grid ---------- */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.media-tile {
  background: white; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.media-tile .thumb {
  aspect-ratio: 16 / 9; background: #0f1115;
  display: flex; align-items: center; justify-content: center; color: #888;
  overflow: hidden; position: relative;
}
.media-tile .thumb img, .media-tile .thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.media-tile .badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.6); color: white; font-size: 11px;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.media-tile .meta { padding: 10px 12px; }
.media-tile .meta .name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-tile .meta .name:hover { white-space: normal; word-break: break-word; }
.media-tile .meta .sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.media-tile .actions { display: flex; flex-wrap: wrap; padding: 0 12px 12px; gap: 6px; }
.media-tile .actions .btn { flex: 1 1 auto; min-width: 0; }

/* ---------- Playlists ---------- */
.playlist-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.playlist-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.playlist-card header h3 { margin: 0; }
.playlist-items { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.playlist-item {
  background: #fafbfd; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; display: grid;
  grid-template-columns: 32px 60px 1fr 100px 80px 40px;
  gap: 10px; align-items: center;
  font-size: 13px;
}
.playlist-item .idx { color: var(--text-muted); font-weight: 600; text-align: center; }
.playlist-item .thumb-mini { aspect-ratio: 16/9; background: #0f1115; border-radius: 4px; overflow: hidden; }
.playlist-item .thumb-mini img { width: 100%; height: 100%; object-fit: cover; }
.playlist-item .duration-input { width: 70px; }
.playlist-item .type-badge { font-size: 11px; padding: 2px 6px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 4px; text-transform: uppercase; text-align: center; }
.playlist-item .thumb-mini .thumb-web {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.playlist-item .item-label {
  word-break: break-all; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.web-duration { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fixed-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted); cursor: pointer;
}
.fixed-toggle input { margin: 0; }

/* ---------- Assign ---------- */
.assign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.assign-grid .panel { background: white; padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.assign-grid .panel h3 { margin-top: 0; }
.checklist { max-height: 400px; overflow-y: auto; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; cursor: pointer; }
.checklist label:hover { background: var(--primary-soft); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: white; padding: 24px; border-radius: var(--radius);
  width: 100%; max-width: 720px; max-height: 80vh; overflow-y: auto;
}
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal h2 { margin: 0; }
.modal .field { margin-bottom: 12px; }
.modal .field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.modal .field input, .modal .field select { width: 100%; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: white;
  padding: 12px 20px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  font-size: 14px; z-index: 1000;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- Video Walls ---------- */
.wall-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.wall-card header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 14px; flex-wrap: wrap; }
.wall-card header h3 { margin: 0; }
.wall-card .meta-line { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.wall-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.wall-controls label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.wall-controls input.size { width: 60px; }
.wall-grid {
  display: grid; gap: 6px;
  background: #0f1115;
  border: 2px solid var(--border); border-radius: 8px;
  padding: 6px;
  margin: 0 auto 14px;
  aspect-ratio: 16 / 9;
  max-width: 600px;
}
.wall-cell {
  background: #1f2733; color: #cdd6e3;
  border-radius: 4px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; text-align: center;
  position: relative;
  min-height: 50px;
}
.wall-cell.assigned { background: var(--primary); color: white; }
.wall-cell .cell-pos { font-size: 10px; opacity: .6; position: absolute; top: 4px; left: 6px; }
.wall-cell select { width: 100%; font-size: 12px; padding: 4px; }
.wall-cell .name { font-weight: 600; word-break: break-word; }
.wall-cell .ori { font-size: 9px; opacity: .8; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.orientation-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-dark); text-transform: uppercase;
}
.orientation-pill.vertical { background: #fef7e0; color: var(--warning); }
.media-tile .badge.orientation { left: 8px; right: auto; }
.media-tile .badge.orientation.vertical { background: rgba(242, 153, 0, .85); }

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; padding: 12px; overflow-x: auto; }
  nav { flex-direction: row; }
  .assign-grid { grid-template-columns: 1fr; }
}

/* ===================== Atribuir (assign) - tema CLARO v20260519g ===================== */
.assign-step {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.step-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.step-hdr h3 { margin: 0; font-size: 16px; color: var(--text); }
.step-num {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #4a92f0);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 6px rgba(26,115,232,0.25);
}
.step-num.gray { background: linear-gradient(135deg, #9aa3b2, #b8c0cc); box-shadow: none; }

/* Playlist cards */
.assign-playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.assign-pl-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.assign-pl-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(26,115,232,0.15);
}
.assign-pl-card.selected {
  border-color: var(--success);
  background: #f0faf3;
  box-shadow: 0 0 0 3px rgba(30,142,62,0.12), 0 4px 14px rgba(30,142,62,0.18);
}
.assign-pl-card.remove-card {
  background: #fef9f9;
  border-color: #e6c5c5;
  border-style: dashed;
}
.assign-pl-card.remove-card.selected {
  background: #fee7e7;
  border-color: var(--danger);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(217,48,37,0.12);
}
.assign-pl-card .pl-name { font-weight: 700; font-size: 15px; color: var(--text); margin-bottom: 4px; }
.assign-pl-card .pl-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.assign-pl-card .pl-preview { display: flex; gap: 4px; margin-top: 8px; }
.assign-pl-card .pl-thumb {
  width: 50px; height: 50px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.assign-pl-card .pl-thumb img, .assign-pl-card .pl-thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.assign-pl-card .pl-thumb.web-thumb,
.assign-pl-card .pl-thumb.more-thumb,
.assign-pl-card .pl-thumb.empty-thumb {
  font-size: 16px; color: var(--text-muted); font-weight: 600; background: var(--bg);
}
.assign-pl-card .pl-check {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: none;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 6px rgba(30,142,62,0.4);
}
.assign-pl-card.selected .pl-check { display: flex; }
.assign-pl-card.remove-card.selected .pl-check { background: var(--danger); }

/* TV cards */
.assign-tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}
.assign-tv-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
}
.assign-tv-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(26,115,232,0.15);
}
.assign-tv-card.selected {
  border-color: var(--success);
  background: #f0faf3;
  box-shadow: 0 0 0 3px rgba(30,142,62,0.12), 0 4px 14px rgba(30,142,62,0.18);
}
.assign-tv-card.status-off { opacity: 0.75; }
.assign-tv-card .tv-row1 {
  display: flex; align-items: center; gap: 10px;
}
.assign-tv-card .tv-row1 input[type=checkbox] {
  width: 20px; height: 20px; cursor: pointer; flex-shrink: 0;
  accent-color: var(--success);
}
.assign-tv-card .tv-icon { font-size: 24px; }
.assign-tv-card .tv-name-block { flex: 1; min-width: 0; }
.assign-tv-card .tv-name {
  font-weight: 700; color: var(--text); font-size: 14px;
  white-space: normal; word-break: break-word; line-height: 1.25;
}
.assign-tv-card .tv-code { color: var(--text-muted); font-size: 11px; font-family: monospace; }
.assign-tv-card .tv-row2, .assign-tv-card .tv-row3 { padding-left: 30px; }
.assign-tv-card .tv-row2 { font-size: 13px; color: var(--text); }
.assign-tv-card .tv-row2 span[style*="color:#9bd"] { color: var(--primary) !important; }

.tv-status {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.tv-status.on { background: #dcfce7; color: #166534; }
.tv-status.idle { background: #fef3c7; color: #92400e; }
.tv-status.off { background: #fee2e2; color: #991b1b; }

/* Action bar */
.assign-action-bar {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(10px);
  margin-top: 24px;
  padding: 18px 22px;
  border-top: 2px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; align-items: center; gap: 16px;
  box-shadow: 0 -4px 20px rgba(15,30,60,0.08);
  z-index: 10;
}
.action-summary { font-size: 15px; color: var(--text); flex: 1; }
.action-summary strong { color: var(--success); }
.action-summary span[style*="color:#9cff9c"] { color: var(--success) !important; }
.btn-mega {
  background: #e1e6ee;
  color: var(--text-muted);
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: not-allowed;
  transition: all 0.2s;
}
.btn-mega.ready {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(34,197,94,0.35);
}
.btn-mega.ready:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(34,197,94,0.45); }
.btn-mega:disabled { cursor: not-allowed; }

/* Atribuições atuais (resumo) */
.assign-current-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.assign-current-table th {
  text-align: left; padding: 10px 14px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.assign-current-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.assign-current-table tbody tr:last-child td { border-bottom: none; }
.assign-current-table tbody tr:hover { background: var(--primary-soft); }
.assign-current-table td span[style*="color:#9bd"] { color: var(--primary) !important; }

/* Hero header da página Atribuir */
#view-assign > div[style*="background:linear-gradient(135deg,#1e3a5f,#2a4a7f)"] {
  background: linear-gradient(135deg, var(--primary), #4a92f0) !important;
  box-shadow: 0 4px 14px rgba(26,115,232,0.25);
}
#view-assign > div[style*="background:linear-gradient(135deg,#1e3a5f,#2a4a7f)"] p {
  color: rgba(255,255,255,0.92) !important;
}
