:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --line: #d8e0df;
  --text: #17211f;
  --muted: #66736f;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --ink: #243447;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #15803d;
  --shadow: 0 16px 34px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #e6ecea;
  color: var(--text);
}

button.secondary:hover {
  background: #d8e2df;
}

.login-player-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #e6ecea;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.login-player-link:hover {
  background: #d8e2df;
}

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

button.small-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.icon-action {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
}

.icon-action.secondary {
  background: #e6ecea;
  color: var(--text);
}

.icon-action.warning {
  background: #fef3c7;
  color: var(--warn);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(183, 121, 31, 0.08)),
    var(--bg);
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.login-box h1 {
  font-size: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #17211f;
  color: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.sidebar-brand span {
  display: block;
  color: #b7c6c2;
  font-size: 12px;
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce8e5;
}

.tab:hover,
.tab.active {
  background: rgba(255, 255, 255, 0.1);
}

.content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(245, 247, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  font-size: 22px;
}

#userInfo {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

main {
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(23, 33, 31, 0.04);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

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

.metric strong {
  font-size: 30px;
}

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

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title h3 {
  font-size: 17px;
}

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

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

.wide-on-desktop {
  grid-column: span 2;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.check-field {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 20px;
  color: var(--text);
}

.check-field input {
  width: 18px;
  height: 18px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e6ecea;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.status.ativo {
  background: #dcfce7;
  color: var(--ok);
}

.status.inativo,
.status.revogado,
.status.bloqueado {
  background: #fee2e2;
  color: var(--danger);
}

.compact-list,
.playlist-list,
.media-picker {
  display: grid;
  gap: 10px;
}

.compact-row,
.playlist-card,
.media-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.compact-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.compact-row small,
.playlist-card small {
  color: var(--muted);
}

.media-picker-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.media-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 110px 90px 90px;
  align-items: center;
  gap: 10px;
}

.media-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.media-row input[type="checkbox"] {
  width: 18px;
}

.media-row input[type="number"] {
  min-width: 74px;
}

.muted-control {
  color: var(--muted) !important;
}

.muted-control input {
  opacity: 0.5;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.time-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 980px) {
  .app-view {
    grid-template-columns: 1fr;
  }

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

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

  .metric-grid,
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .input-action {
    grid-template-columns: 1fr;
  }

  .check-field {
    padding-top: 0;
  }

  .media-row {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 620px) {
  main,
  .topbar {
    padding: 14px;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .media-row {
    grid-template-columns: 1fr;
  }

  .time-grid {
    grid-template-columns: 1fr;
  }
}
