:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --ink: #1c2430;
  --ink-muted: #5b6472;
  --line: #dedad0;
  --navy: #16233b;
  --navy-light: #24365a;
  --gold: #b8873a;
  --gold-light: #e9d9b8;
  --danger: #a6402f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

header.topbar {
  background: var(--navy);
  color: #f4f1ea;
  padding: 18px 32px;
  display: flex;
  align-items: baseline;
  gap: 28px;
}

header.topbar .brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

header.topbar nav {
  display: flex;
  gap: 20px;
}

header.topbar nav a {
  color: #cfd6e4;
  text-decoration: none;
  font-size: 14px;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}

header.topbar nav a:hover,
header.topbar nav a.active {
  color: #ffffff;
  border-bottom-color: var(--gold);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

p.subtitle {
  color: var(--ink-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px;
}

.card .label {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.card .value {
  font-size: 24px;
  font-weight: 600;
  color: var(--navy);
}

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  padding: 9px 16px;
  border-radius: 5px;
  text-decoration: none;
  font-size: 14px;
  border: none;
  cursor: pointer;
}

.btn:hover { background: var(--navy-light); }

.btn.secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
  padding: 7px 12px;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

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

th {
  background: #efece3;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: none;
}

tr:last-child td { border-bottom: none; }

td.num { text-align: right; font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions form { display: inline; }
.row-actions a {
  color: var(--navy);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 5px;
}
.row-actions a:hover { border-color: var(--navy); }

form.stack { max-width: 440px; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}

.field input:focus, .field select:focus {
  outline: 2px solid var(--gold-light);
  border-color: var(--gold);
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.badge {
  display: inline-block;
  background: var(--gold-light);
  color: #6b4f18;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 100px;
}

/* ---------- Topbar: usuário logado ---------- */
header.topbar .user-info {
  margin-left: auto;
  font-size: 13px;
  color: #cfd6e4;
}
header.topbar .user-info a {
  color: var(--gold-light);
  text-decoration: none;
}
header.topbar .user-info a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(15,26,46,0.15), rgba(15,26,46,0.15)),
              url('login-bg.svg') center/cover no-repeat;
}
.login-card {
  background: var(--surface);
  padding: 36px 32px;
  border-radius: 8px;
  width: 100%;
  max-width: 340px;
}
.login-card h1 {
  font-size: 20px;
  margin-bottom: 4px;
}
.flash {
  background: #f6e4e0;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Barra de filtros ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}
.filter-bar .field {
  margin-bottom: 0;
  min-width: 160px;
  flex: 1;
}
.filter-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- Dashboard ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}
.dash-grid .panel:first-child { grid-row: span 2; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px;
}
.panel h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  margin: 0 0 14px;
}
@media (max-width: 720px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .panel:first-child { grid-row: auto; }
}

/* ---------- Badge de papel (role) ---------- */
.role-badge {
  text-transform: capitalize;
  background: var(--navy-light);
  color: #e8e6dd;
}

/* ---------- Link do carrinho ---------- */
.cart-link {
  color: #cfd6e4;
  text-decoration: none;
}
.cart-link:hover { color: #fff; }
.cart-link .badge {
  background: var(--gold);
  color: #1c1200;
  font-weight: 700;
}

/* ---------- Grid de produtos (loja) ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.product-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.product-card h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
}
.product-price {
  font-weight: 700;
  color: var(--navy);
}
.product-stock {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}
