:root {
  --azul:    #005D9F;
  --azul-2:  #2029C2;
  --verde:   #297A30;
  --verde-2: #02BF4F;
  --amarelo: #FFC306;
  --vermelho:#dc2626;
  --laranja: #f97316;
  --cinza-1: #f4f6f8;
  --cinza-2: #e3e7eb;
  --cinza-3: #cbd5e0;
  --texto:   #1a2332;
  --muted:   #6b7280;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  background: var(--cinza-1);
  color: var(--texto);
  line-height: 1.45;
}

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout shell */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) { .app { grid-template-columns: 1fr; } }

aside.sidebar {
  background: linear-gradient(180deg, var(--azul) 0%, var(--azul-2) 100%);
  color: #fff;
  padding: 1.25rem 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
@media (max-width: 900px) { aside.sidebar { position: static; height: auto; } }

.sidebar .brand {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar .brand .logo-D {
  width: 38px; height: 38px;
  background: var(--amarelo); color: var(--azul);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
}
.sidebar .brand .name { font-weight: 600; font-size: 0.95rem; }
.sidebar .brand .sub { font-size: 0.72rem; opacity: 0.75; }

.sidebar nav { padding: 1rem 0; }
.sidebar nav .group { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 0.5rem 1.25rem; opacity: 0.6; margin-top: 0.5rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.92);
  font-size: 0.92rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.sidebar nav a.active { background: rgba(0,0,0,0.18); border-left-color: var(--amarelo); font-weight: 600; }
.sidebar nav .icon { width: 18px; text-align: center; opacity: 0.85; }

.sidebar .user-block {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.85rem;
  background: rgba(0,0,0,0.12);
}
.sidebar .user-block .nm { font-weight: 600; }
.sidebar .user-block .role { font-size: 0.72rem; opacity: 0.75; }
.sidebar .user-block a { color: var(--amarelo); font-size: 0.78rem; }

main.content { padding: 1.5rem 2rem; min-width: 0; }
@media (max-width: 700px) { main.content { padding: 1rem; } }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--texto); }
.page-head .crumb { font-size: 0.85rem; color: var(--muted); }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.card {
  background: #fff; border-radius: 10px; padding: 1.25rem 1.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 4px solid var(--azul);
}
.card.green  { border-left-color: var(--verde); }
.card.yellow { border-left-color: var(--amarelo); }
.card.red    { border-left-color: var(--vermelho); }
.card .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; }
.card .value { font-size: 1.65rem; font-weight: 700; margin-top: 0.25rem; line-height: 1.1; }
.card .sub   { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }

.panel {
  background: #fff; border-radius: 10px; padding: 1.4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); margin-bottom: 1rem;
}
.panel h3 {
  margin: 0 0 1rem 0; font-size: 0.95rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--texto);
}

/* Forms */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.form-grid.full { grid-template-columns: 1fr; }
label.field { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 0.3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: 0.55rem 0.75rem;
  border: 1px solid var(--cinza-2); border-radius: 6px;
  font-family: inherit; font-size: 0.95rem; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); border-color: var(--azul); }
textarea { min-height: 90px; resize: vertical; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border-radius: 6px;
  font-weight: 600; font-size: 0.9rem; text-decoration: none;
  border: none; cursor: pointer; font-family: inherit;
  background: var(--azul); color: #fff;
  transition: background 0.1s;
}
.btn:hover { background: var(--azul-2); text-decoration: none; color: #fff; }
.btn.green { background: var(--verde); }
.btn.green:hover { background: var(--verde-2); color: var(--texto); }
.btn.yellow { background: var(--amarelo); color: var(--azul); }
.btn.yellow:hover { background: #e0a800; }
.btn.red { background: var(--vermelho); }
.btn.red:hover { background: #b91c1c; }
.btn.ghost { background: transparent; color: var(--texto); border: 1px solid var(--cinza-2); }
.btn.ghost:hover { background: var(--cinza-1); color: var(--texto); }
.btn.sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.actions-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Tables */
.table-wrap { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
table.dt { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.dt thead { background: var(--cinza-1); }
table.dt th, table.dt td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--cinza-2); }
table.dt th { font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px; color: #4a5568; }
table.dt th a { color: inherit; }
table.dt th a:hover { color: var(--azul); text-decoration: none; }
table.dt tbody tr:hover { background: var(--cinza-1); }
table.dt td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
table.dt td.tomb { font-family: 'Courier New', monospace; font-weight: 600; color: var(--azul); }
table.dt td.actions { white-space: nowrap; }
table.dt td.actions a, table.dt td.actions form { display: inline-block; margin-right: 0.5rem; font-size: 0.84rem; }
table.dt td.actions .delete { color: var(--vermelho); background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; font-size: 0.84rem; }

.empty { padding: 3rem; text-align: center; color: var(--muted); }

/* Badges */
.badge {
  display: inline-block; padding: 0.16rem 0.55rem;
  border-radius: 4px; font-size: 0.74rem; font-weight: 600;
  color: #fff; text-transform: lowercase; line-height: 1.4;
}
.badge.azul { background: var(--azul); }
.badge.verde { background: var(--verde); }
.badge.verde-2 { background: var(--verde-2); color: var(--texto); }
.badge.amarelo { background: var(--amarelo); color: var(--azul); }
.badge.vermelho { background: var(--vermelho); }
.badge.laranja { background: var(--laranja); }
.badge.cinza { background: var(--cinza-3); color: var(--texto); }

/* Pagination */
.paginator { padding: 1rem 1.25rem; background: #fff; border-top: 1px solid var(--cinza-2); }
.pagination { display: flex; gap: 0.4rem; align-items: center; list-style: none; padding: 0; margin: 0 0 0.5rem; flex-wrap: wrap; }
.pagination li a, .pagination li span {
  display: inline-block; padding: 0.4rem 0.7rem; border-radius: 4px;
  text-decoration: none; color: var(--azul); font-size: 0.9rem;
}
.pagination li.active a, .pagination li.active span { background: var(--azul); color: #fff; }
.pagination li:not(.active) a:hover { background: var(--cinza-1); }
.pagination li.disabled a, .pagination li.disabled span { color: var(--cinza-3); cursor: not-allowed; }
.paginator p { font-size: 0.82rem; color: var(--muted); margin: 0; }

/* Flash messages */
.flash {
  padding: 0.85rem 1.1rem;
  border-radius: 6px; margin-bottom: 1rem;
  font-size: 0.92rem; font-weight: 500;
}
.flash.success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--verde-2); }
.flash.error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--vermelho); }
.flash.info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--azul); }
.flash.warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--amarelo); }

/* Filters bar */
.filters {
  background: #fff; border-radius: 10px; padding: 1rem 1.25rem;
  margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.filters form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto auto; gap: 0.75rem; align-items: end; }
@media (max-width: 1100px) { .filters form { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 700px)  { .filters form { grid-template-columns: 1fr 1fr; } }

/* View detail layout */
.detail { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.detail dl { margin: 0; }
.detail dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; margin-top: 0.85rem; }
.detail dt:first-child { margin-top: 0; }
.detail dd { margin: 0.2rem 0 0 0; font-size: 0.95rem; }
