:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--primary); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* ---------- App shell ---------- */
header.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}
header.topbar .brand { font-weight: 600; }
header.topbar .who { color: var(--muted); font-size: 13px; }
header.topbar .who b { color: var(--text); }

.container { max-width: 1000px; margin: 0 auto; padding: 20px; }

nav.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
nav.tabs button {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
nav.tabs button.active { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow); }

section.panel { display: none; }
section.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { font-size: 16px; margin: 0 0 14px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
input, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(37, 99, 235, 0.25); border-color: var(--primary); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

button.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
button.btn:hover { background: var(--primary-d); }
button.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
button.btn.sm { padding: 5px 10px; font-size: 13px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.on { background: #dcfce7; color: var(--ok); }
.badge.off { background: #fee2e2; color: var(--danger); }
.badge.role { background: #e0e7ff; color: #3730a3; }

.msg { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.msg.err { background: #fee2e2; color: var(--danger); }
.msg.ok { background: #dcfce7; color: var(--ok); }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.25);
  padding: 22px;
  width: 100%;
  max-width: 440px;
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Kit de abertura (cedulas) ---------- */
.kit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.kit-grid .kit-item label { margin-bottom: 2px; }
.kit-total { margin-top: 10px; font-size: 14px; }
.kit-total b { font-size: 16px; }
