:root {
  --bg: #0f1419;
  --panel: #151c24;
  --panel2: #1b2430;
  --text: #e8eef6;
  --muted: #9aa7b6;
  --line: #2a3544;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1a2a44 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100%;
}

a {
  color: #93c5fd;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(15, 20, 25, 0.75);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
}
.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
}
.nav a.active {
  background: rgba(59, 130, 246, 0.15);
  color: #dbeafe;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: linear-gradient(180deg, rgba(27, 36, 48, 0.92), rgba(21, 28, 36, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2,
.card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}
.card h4 {
  margin: 14px 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
  line-height: 1.45;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.primary {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.35);
}
.btn.secondary {
  background: rgba(255, 255, 255, 0.06);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-link {
  border: 0;
  background: transparent;
  color: #93c5fd;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.row-actions.spread {
  justify-content: space-between;
}

.form-import input[type='file'] {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  margin: 10px 0 0;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.12);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
.table th,
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}
.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.18);
  position: sticky;
  top: 0;
}
.table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.td-actions {
  white-space: nowrap;
}
.row-zero td {
  color: #cbd5e1;
  opacity: 0.75;
}

.filters .f-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.filters label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.filters input,
.filters select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}
.f-span2 {
  grid-column: span 2;
}
@media (max-width: 1000px) {
  .filters .f-grid {
    grid-template-columns: 1fr;
  }
  .f-span2 {
    grid-column: auto;
  }
}

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-panel {
  position: relative;
  max-width: 860px;
  margin: 6vh auto;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-body {
  padding: 14px;
  max-height: 70vh;
  overflow: auto;
}
.kv-modal {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px 12px;
  margin: 0;
}
.kv-modal dt {
  margin: 0;
  color: var(--muted);
}
.kv-modal dd {
  margin: 0;
  word-break: break-word;
}
.btn-icon {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(21, 28, 36, 0.95);
  box-shadow: var(--shadow);
  max-width: min(520px, calc(100vw - 32px));
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.ok {
  border-color: rgba(34, 197, 94, 0.35);
}
.toast.err {
  border-color: rgba(239, 68, 68, 0.35);
}
.toast.warn {
  border-color: rgba(245, 158, 11, 0.35);
}

.alert {
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.18);
}
.alert.warn {
  border-color: rgba(245, 158, 11, 0.35);
}
.list-compact {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.cal-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1000px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
}

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cal-toolbar h2 {
  margin: 0;
  flex: 1;
  text-transform: capitalize;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cal-week-sum {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.08);
  border-radius: 8px;
}

.cal-week-sum-sim {
  color: #c7d2fe;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.cal-week-sum-sim-n {
  color: var(--muted);
  font-weight: 500;
}

.cal-day-sum-line {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cal-day-qtd-split {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cal-cell {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 8px;
  min-height: 84px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 4px;
  align-content: start;
}
.cal-cell:disabled {
  opacity: 0.45;
  cursor: default;
}
.cal-cell.muted {
  opacity: 0.45;
}
.cal-cell.is-today {
  outline: 2px solid rgba(59, 130, 246, 0.65);
}
.cal-cell.is-selected {
  outline: 2px solid rgba(52, 211, 153, 0.9);
  outline-offset: 1px;
  z-index: 1;
}
.cal-cell .d {
  font-weight: 800;
}
.cal-cell .amt {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.cal-cell .n {
  font-size: 12px;
  color: var(--muted);
}

.cal-cell.heat-1 {
  background: rgba(59, 130, 246, 0.08);
}
.cal-cell.heat-2 {
  background: rgba(59, 130, 246, 0.14);
}
.cal-cell.heat-3 {
  background: rgba(59, 130, 246, 0.22);
}
.cal-cell.heat-4 {
  background: rgba(59, 130, 246, 0.32);
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.14);
}
.kpi-label {
  color: var(--muted);
  font-size: 12px;
}
.kpi-val {
  font-weight: 800;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.rank-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}
.rank-list li {
  margin: 6px 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.rank-list strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.panel {
  position: sticky;
  top: 84px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.panel-head h3 {
  margin: 0;
}
.day-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.day-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.14);
}
.day-item .t {
  font-weight: 800;
}
.day-item .s {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.day-item .v {
  margin-top: 8px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.day-detail-card .day-placeholder {
  margin: 0;
}
.day-detail-list {
  margin-top: 10px;
}
.day-detail-h {
  margin: 14px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.day-detail-h:first-of-type {
  margin-top: 4px;
}
.day-planos-block {
  margin: 12px 0 8px;
}
.day-planos-block .day-detail-h {
  margin-top: 0;
}
.day-planos-list {
  margin-bottom: 4px;
}
.day-detail-h--sim {
  color: #ddd6fe;
}
.day-detail-empty {
  margin: 0 0 4px;
}
.day-table {
  display: grid;
  gap: 8px;
}
.day-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}
.day-table-row--zero {
  opacity: 0.55;
}
.day-table-row--sim {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(109, 40, 217, 0.12);
}
.day-table-nome {
  font-weight: 700;
  word-break: break-word;
}
.day-table-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.day-table-val {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  padding-top: 2px;
}
.badge.badge--sim {
  color: #f5f3ff;
  background: rgba(109, 40, 217, 0.5);
  border-color: rgba(167, 139, 250, 0.55);
}

.mt {
  margin-top: 10px;
}

.sim-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}
.sim-form input[type='text'] {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.sim-grupos {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.sim-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}
.sim-row-txt {
  min-width: 0;
}

.cal-cell.has-sim {
  border: 2px solid rgba(167, 139, 250, 0.85);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.35),
    inset 0 0 0 1px rgba(167, 139, 250, 0.12);
  position: relative;
}
.cal-cell.has-sim::after {
  content: 'sim';
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e9d5ff;
  background: rgba(109, 40, 217, 0.55);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}
.cal-cell.sim-only-day {
  background: linear-gradient(
    145deg,
    rgba(109, 40, 217, 0.22) 0%,
    rgba(59, 130, 246, 0.12) 100%
  ) !important;
}
.sim-hint {
  display: block;
  font-size: 11px;
  color: #c7d2fe;
  font-variant-numeric: tabular-nums;
}

.day-item-sim {
  border-color: rgba(165, 180, 252, 0.35);
  background: rgba(59, 130, 246, 0.08);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 6px;
}
