:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6f4f2;
  --bg: #fafbfb;
  --sidebar: #f3f5f5;
  --card: #ffffff;
  --line: #e3e7e8;
  --text: #1c2526;
  --muted: #5f6b6d;
  --danger: #b42318;
  --success: #157a3e;
  --success-soft: #e5f5ea;
  --warning: #a15c07;
  --warning-soft: #fef3e2;
  --input: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2bb3a6;
    --brand-dark: #7fd9cf;
    --brand-soft: #12302d;
    --bg: #111617;
    --sidebar: #161c1d;
    --card: #1a2122;
    --line: #2a3335;
    --text: #e7eceb;
    --muted: #9aa7a8;
    --danger: #f97066;
    --success: #4ade80;
    --success-soft: #143021;
    --warning: #fbbf24;
    --warning-soft: #33280f;
    --input: #121819;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  grid-template-rows: 1fr auto;
  height: 100dvh;
}

/* ---------- Menu ---------- */
.sidebar {
  grid-row: 1 / 3;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 10px 16px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 10px 24px; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  color: inherit; text-decoration: none; position: relative;
}
.nav a:hover { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 2px; background: var(--brand);
}
.nav .ico { width: 18px; text-align: center; opacity: 0.8; }
.sidebar-note { margin-top: auto; padding: 0 10px; color: var(--muted); font-size: 12.5px; }

/* ---------- Conteúdo ---------- */
.main { overflow: auto; padding: 24px 28px 20px; min-width: 0; }
.view { max-width: 1180px; }
h1 { font-size: 22px; margin: 0 0 2px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 0 18px; font-size: 13.5px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); margin: 8px 0 0; }
.ok { color: var(--success); margin: 8px 0 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.card-head h2 { margin: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
.grid-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 20px; }

/* ---------- Formulários ---------- */
label.field { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; }
label.field:first-child { margin-top: 0; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line);
  border-bottom-color: color-mix(in srgb, var(--muted) 55%, var(--line));
  border-radius: 6px;
  padding: 8px 10px;
}
textarea { min-height: 110px; resize: vertical; font-size: 16px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 0; border-color: var(--brand); }
input.short { width: 90px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.cols { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label {
  border: 1px solid var(--line); border-radius: 18px; padding: 4px 12px; cursor: pointer; user-select: none; font-size: 13.5px;
}
.days input { display: none; }
.days label:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.radio-list label { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }
.radio-list input { accent-color: var(--brand); width: 17px; height: 17px; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; }

/* ---------- Botões ---------- */
.btn {
  font: inherit; font-size: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-soft) 50%, var(--card)); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn-small { padding: 3px 10px; font-size: 13px; }
.btn-icon { padding: 3px 9px; min-width: 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .push { margin-left: auto; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0 6px 6px; max-height: calc(100dvh - 260px); overflow: auto; }
.list li {
  display: flex; gap: 10px; align-items: center;
  padding: 10px; border-radius: 8px; cursor: pointer;
}
.list li:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.list li.selected { background: var(--brand-soft); }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { color: var(--muted); font-size: 13px; }
.list .pos { color: var(--brand); font-weight: 700; width: 22px; }
.empty { color: var(--muted); text-align: center; padding: 30px 12px; font-size: 14px; }

.pill { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 10px; margin-right: 6px; }
.pill.ok { background: var(--success-soft); color: var(--success); margin: 0 6px 0 0; }
.pill.draft { background: var(--warning-soft); color: var(--warning); }
.note { background: var(--brand-soft); color: var(--brand-dark); border-radius: 8px; padding: 10px 12px; margin-top: 14px; font-size: 14px; }
.warn-text { color: var(--warning); font-size: 12.5px; }
.counter { text-align: right; font-size: 12.5px; color: var(--muted); }
.counter.over { color: var(--danger); font-weight: 600; }
.next { text-align: right; font-size: 13px; }
.next strong { display: block; font-size: 14px; }

.now { font-size: 20px; margin: 4px 0 12px; color: var(--muted); }
.now.playing { color: var(--success); font-weight: 600; }

.log { list-style: none; margin: 0; padding: 0 16px 14px; max-height: 360px; overflow: auto; font-size: 13px; }
.log li { display: flex; gap: 10px; padding: 3px 0; }
.log time { color: var(--muted); width: 62px; flex: none; }
.log .warn { color: var(--warning); }
.log .error { color: var(--danger); margin: 0; }

.license-card { border-left: 4px solid var(--warning); }
.license-card.good { border-left-color: var(--success); }
.key { font-family: Consolas, "Courier New", monospace; font-size: 15px; letter-spacing: 0.5px; }

.progress { height: 3px; background: linear-gradient(90deg, var(--brand) 30%, transparent 30%); background-size: 200% 100%; animation: load 1s linear infinite; border-radius: 2px; margin-top: 8px; }
@keyframes load { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Faixa de aviso ---------- */
.banner {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--warning-soft); color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; font-weight: 600;
}
.banner .btn { margin-left: auto; }

/* ---------- Barra de status ---------- */
.statusbar {
  grid-column: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 28px; border-top: 1px solid var(--line); background: var(--card);
  font-size: 14px;
}
.statusbar .spacer { flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c3cbcc; flex: none; }
.dot.on { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 20%, transparent); }
#now-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Celular ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; }
  .sidebar {
    grid-row: 3; grid-column: 1;
    flex-direction: row; padding: 0 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .sidebar-note { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 0; padding: 7px 4px; font-size: 11.5px; flex: 1; text-align: center; }
  .nav a.active::before { display: none; }
  .nav .ico { font-size: 17px; width: auto; }
  .main { padding: 16px 16px 14px; }
  .statusbar { grid-column: 1; grid-row: 2; padding: 8px 16px; }
  .grid-2, .grid-eq, .cols { grid-template-columns: 1fr; }
  .list { max-height: none; }
  h1 { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .progress { animation: none; }
}

/* ---------- Ajustes gerais ---------- */
[hidden] { display: none !important; }
.grid-2.grid-2r { grid-template-columns: minmax(320px, 430px) 1fr; }
.stack-top { margin-top: 20px; }
.narrow { max-width: 680px; }
.grow-input { flex: 1; min-width: 200px; width: auto; }
.row + .row, .row + label.check { margin-top: 8px; }
[data-kind] { margin-top: 10px; }
@media (max-width: 820px) {
  .grid-2.grid-2r { grid-template-columns: 1fr; }
}

/* ---------- Música ---------- */
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.style-btn {
  text-align: left; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.style-btn span { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.style-btn small { color: var(--brand); font-weight: 600; font-size: 12px; }
.style-btn:hover { border-color: var(--brand); }
.style-btn.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }

/* ---------- Declaração de repertório ---------- */
.doc { max-width: 900px; }
.doc p { margin: 0 0 12px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 13.5px; }
.doc-table th, .doc-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table th { font-weight: 600; background: var(--brand-soft); }

@media print {
  .sidebar, .statusbar, .banner, .no-print { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; padding: 0; }
  body { background: #fff; color: #000; }
  .card.doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .doc-table th { background: #eee; }
}
