﻿:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #11151b;
  --panel-2: #161b22;
  --line: #2b323d;
  --muted: #8d99a8;
  --text: #f5f7fb;
  --red: #d5001c;
  --red-soft: rgba(213, 0, 28, .14);
  --green: #35c77b;
  --blue: #5aa9ff;
  --amber: #f3b74e;
  --shadow: 0 20px 50px rgba(0, 0, 0, .28);
}

body.theme-light {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --line: #d6dee8;
  --muted: #5f6f84;
  --text: #111827;
  --shadow: 0 14px 35px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: #06070a;
  border-right: 1px solid var(--line);
}

body.theme-light .sidebar {
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--red);
  color: white;
  font-weight: 900;
  border-radius: 8px;
}

.brand strong { display: block; font-size: 19px; }
.brand small { display: block; color: var(--muted); margin-top: 3px; }

nav { display: grid; gap: 7px; }

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-btn:hover, .nav-btn.active {
  color: white;
  background: var(--panel-2);
}

body.theme-light .nav-btn:hover,
body.theme-light .nav-btn.active {
  color: var(--text);
}

.nav-btn.active {
  box-shadow: inset 3px 0 0 var(--red);
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 14px; margin-bottom: 10px; color: #c8d0da; }

body.theme-light h3 {
  color: #334155;
}

.cycle-box {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0b0e13;
  color: white;
  padding: 8px 10px;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea {
  background: #ffffff;
  color: var(--text);
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--red);
}

textarea {
  min-height: 74px;
  resize: vertical;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-body { padding: 18px; }

.metric {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0d1016;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

body.theme-light th {
  background: #eef2f7;
  color: #475569;
}

td input, td select {
  min-width: 90px;
  min-height: 32px;
  padding: 6px 8px;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ok { color: var(--green); }
.bad { color: #ff6b7b; }
.warn { color: var(--amber); }
.blue { color: var(--blue); }

.primary, .ghost, .danger, .success {
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 7px;
  font-weight: 800;
}

.primary { background: var(--red); color: white; }
.ghost { background: #202631; color: white; border: 1px solid var(--line); }
.danger { background: rgba(213, 0, 28, .18); color: #ff8a98; border: 1px solid rgba(213, 0, 28, .4); }
.success { background: rgba(53, 199, 123, .16); color: #8af0bb; border: 1px solid rgba(53, 199, 123, .35); }
.full { width: 100%; }

body.theme-light .ghost {
  background: #f8fafc;
  color: var(--text);
}

body.theme-light .danger {
  color: #b42336;
}

body.theme-light .success {
  color: #087443;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.state-pill, .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #202631;
  color: #cbd4df;
  font-size: 12px;
  font-weight: 800;
}

body.theme-light .state-pill,
body.theme-light .pill {
  background: #e8edf5;
  color: #334155;
}

.pill.ok { background: rgba(53, 199, 123, .13); }
.pill.bad { background: rgba(213, 0, 28, .13); }
.pill.warn { background: rgba(243, 183, 78, .14); }

.empty {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

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

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-6 { grid-column: span 6; }

.import-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0e13;
}

body.theme-light .import-card {
  background: #f8fafc;
}

.import-card code {
  color: #c3ccd8;
  word-break: break-all;
  white-space: normal;
}

.dependent-row td {
  background: #0c1118;
}

body.theme-light .dependent-row td {
  background: #f8fafc;
}

.dependent-table {
  min-width: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.dependent-table th {
  position: static;
  z-index: auto;
}

.dependent-table th,
.dependent-table td {
  padding: 9px 10px;
  font-size: 12px;
}

.dependent-table td {
  background: var(--panel);
}

.dependent-table td input {
  max-width: 220px;
}

.dependent-grid {
  display: grid;
  grid-template-columns: minmax(260px, 560px);
  gap: 10px;
  padding: 8px 0;
}

.dependent-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111722;
}

.dependent-card span {
  color: var(--blue);
  font-weight: 800;
}

.dependent-card small {
  color: var(--muted);
}

@media (max-width: 1050px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .topbar, .cycle-box { flex-direction: column; align-items: stretch; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-6 { grid-column: span 1; }
}

.link-button {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, .55);
}

.modal-panel {
  width: min(1120px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-table {
  max-height: 62vh;
}

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

.cadastro-metrics { margin-bottom: 16px; }

.cadastro-header .state-pill { white-space: nowrap; }

.cadastro-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.cadastro-source { margin-top: 4px; }

.cadastro-table { min-width: 1900px; }

.cadastro-table .name-cell { min-width: 220px; }

.cadastro-table td { height: 56px; }

.cadastro-table td input,
.cadastro-table td select { min-width: 86px; }

.cadastro-table .num-input { max-width: 110px; }

.cadastro-table .uf-input { max-width: 74px; }

.small-btn {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.actions-cell {
  min-width: 132px;
  white-space: nowrap;
}

.actions-cell .small-btn + .small-btn { margin-left: 6px; }

@media (max-width: 1050px) {
  .cols-5 { grid-template-columns: 1fr; }
  .cadastro-toolbar { grid-template-columns: 1fr; }
}

.swile-table { min-width: 1650px; }
.swile-table td input.num-input { max-width: 82px; min-width: 72px; }
.swile-table td:nth-child(1) { min-width: 260px; }

.layout-final-table { min-width: 1650px; }
.layout-final-table td:nth-child(2) { min-width: 240px; }
