/* Define o tema responsivo e os componentes visuais do painel 2N Gestão. */

/* Tema e base */
:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #24313d;
  background: #f4f6f8;
  line-height: 1.45;
  color-scheme: light;
  --color-primary: #1f4e79;
  --color-primary-dark: #173f64;
  --color-background: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #d9e0e6;
  --color-muted: #647382;
  --color-danger: #a32626;
  --color-danger-soft: #fff0f0;
  --color-gold: #fff7dc;
  --color-silver: #f0f3f5;
  --color-bronze: #f8ece2;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius-small: 0.45rem;
  --radius-medium: 0.65rem;
  --radius-large: 1rem;
  --shadow-card: 0 12px 36px #17334d22;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-background);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: linear-gradient(145deg, #eef3f7, #dce7f0);
}

.login-card {
  width: min(100%, 25rem);
  padding: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-card);
}

.logo-login {
  display: block;
  max-width: 11rem;
  max-height: 5rem;
  margin: 0 auto var(--space-4);
  object-fit: contain;
}

.login-card h1 {
  margin: var(--space-2) 0;
  color: var(--color-primary);
  text-align: center;
}

.login-card p {
  color: var(--color-muted);
  text-align: center;
}

.form-stack {
  display: grid;
  gap: var(--space-4);
}

/* Formulários e botões */
label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.55rem 0.7rem;
  color: #24313d;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #8db6d9;
  outline-offset: 2px;
}

.btn {
  padding: 0.7rem var(--space-4);
  font-weight: 700;
  border: 0;
  border-radius: var(--radius-small);
}

.btn-primary {
  color: var(--color-surface);
  background: var(--color-primary);
}

.btn-light {
  color: var(--color-primary);
  background: #edf2f6;
}

.filters {
  display: grid;
  gap: 0.8rem;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
}

.search-row {
  display: grid;
  gap: 0.8rem;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.check input {
  width: auto;
  min-height: auto;
}

.check span {
  font-weight: 600;
}

/* Estrutura principal */
.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  height: 4rem;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.logo-header {
  width: 5.5rem;
  height: 2.7rem;
  object-fit: contain;
}

.topbar-spacer {
  flex: 1;
}

.user-name {
  font-size: 0.86rem;
  font-weight: 700;
}

.menu-toggle {
  padding: 0.55rem 0.75rem;
  color: var(--color-primary);
  font-weight: 700;
  background: #edf2f6;
  border: 0;
  border-radius: var(--radius-small);
}

.sidebar {
  display: none;
  padding: var(--space-4);
  color: var(--color-surface);
  background: var(--color-primary-dark);
}

.sidebar.open {
  display: block;
}

.nav {
  display: grid;
  gap: 0.3rem;
}

.nav a {
  padding: 0.7rem;
  color: #dbe9f4;
  text-decoration: none;
  border-radius: 0.4rem;
}

.nav a:hover,
.nav a.active {
  color: var(--color-primary);
  background: var(--color-surface);
}

main {
  max-width: 90rem;
  padding: var(--space-4);
  margin: auto;
}

.view-head h1 {
  margin: 0.2rem 0;
  color: var(--color-primary-dark);
  font-size: 1.55rem;
}

.view-head p {
  margin: 0.2rem 0 var(--space-4);
  color: var(--color-muted);
}

/* Cartões e painéis */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card,
.panel {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
}

.card-label {
  color: var(--color-muted);
  font-size: 0.82rem;
}

.card-value {
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
  color: var(--color-primary-dark);
  font-size: 1.25rem;
  font-weight: 700;
}

.panel {
  margin-bottom: var(--space-4);
}

.panel h2 {
  margin: 0 0 0.8rem;
  color: var(--color-primary-dark);
  font-size: 1.05rem;
}

.note {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Tabelas */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.65rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid #e8edf1;
}

.table th {
  color: #52606d;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.ranking-position-1 {
  background: var(--color-gold);
}

.ranking-position-2 {
  background: var(--color-silver);
}

.ranking-position-3 {
  background: var(--color-bronze);
}

.ranking-position-1 td:first-child,
.ranking-position-2 td:first-child,
.ranking-position-3 td:first-child {
  color: var(--color-primary-dark);
  font-weight: 800;
}

/* Barras de comparação */
.bars {
  display: grid;
  gap: var(--space-3);
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-1);
  font-size: 0.86rem;
}

.bar-label strong {
  text-align: right;
}

.bar-track {
  height: 0.55rem;
  overflow: hidden;
  background: #e8edf1;
  border-radius: 2rem;
}

.bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2rem;
}

/* Demonstrativo de resultado */
.dre-statement {
  display: grid;
}

.dre-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0.65rem var(--space-2);
  border-bottom: 1px solid #e8edf1;
}

.dre-value {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dre-total,
.dre-final {
  font-weight: 800;
}

.dre-total {
  background: #f4f7fa;
}

.dre-final {
  color: var(--color-surface);
  background: var(--color-primary-dark);
}

.dre-negative {
  color: var(--color-danger);
}

.dre-group {
  font-weight: 700;
}

.dre-detail,
.dre-row.detail {
  padding-left: var(--space-6);
  color: var(--color-muted);
  font-size: 0.9rem;
}

.dre-detail.dre-negative,
.dre-row.detail.dre-negative {
  color: var(--color-danger);
}

/* Estados */
.message {
  padding: var(--space-3);
  margin: var(--space-4) 0;
  border-radius: var(--radius-small);
}

.message-error {
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border: 1px solid #efc4c4;
}

.loading,
.empty {
  padding: var(--space-6);
  color: var(--color-muted);
  text-align: center;
}

/* Tablets e computadores */
@media (min-width: 700px) {
  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
  }

  .filters .btn {
    min-height: 2.7rem;
  }

  .search-row {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
  }

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

  .shell {
    display: grid;
    grid-template-rows: 4rem 1fr;
    grid-template-columns: 15rem 1fr;
  }

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

  .sidebar {
    display: block;
    grid-row: 2;
    padding-top: var(--space-5);
  }

  .menu-toggle {
    display: none;
  }

  main {
    width: 100%;
    padding: var(--space-5) var(--space-6);
  }

  .user-name {
    font-size: 0.95rem;
  }
}

/* Telefones estreitos */
@media (max-width: 430px) {
  .user-name {
    max-width: 6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar .btn {
    padding: 0.55rem;
  }

  .logo-header {
    width: 4.5rem;
  }

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

  .bar-label {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

  .bar-label strong {
    text-align: left;
  }
}
