:root {
  --red: #d92b2b;
  --red-dark: #b01f1f;
  --red-light: #fdecec;
  --yellow: #f5b301;
  --yellow-light: #fff7d6;
  --ink: #1c1c1e;
  --muted: #6b7280;
  --line: #e8e8ea;
  --bg: #f6f6f7;
  --card: #ffffff;
  --green: #15803d;
  --green-bg: #e8f7ee;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 15px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; color: #333; }

/* ---------- Botões ---------- */
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; background: #eee; color: var(--ink);
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-yellow { background: var(--yellow); color: #1c1c1e; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #fff 0%, var(--red-light) 55%, #fff 100%);
}
.login-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px 28px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { margin-bottom: 8px; }
.logo-badge {
  display: inline-block; background: var(--red); color: #fff; font-weight: 800;
  letter-spacing: 1px; padding: 10px 18px; border-radius: 10px; font-size: 22px;
}
.login-card h1 { margin: 10px 0 2px; font-size: 24px; }
.login-sub { color: var(--muted); margin: 0 0 10px; }
.login-card form { text-align: left; }
.login-foot { color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ---------- Toast / erro inline ---------- */
#toast-wrap { position: fixed; top: 14px; right: 14px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 420px); }
.toast {
  background: #1c1c1e; color: #fff; padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: 14px; border-left: 4px solid var(--red);
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.inline-error {
  background: var(--red-light); color: var(--red-dark); border: 1px solid #f5c2c2;
  border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 14px;
}
.inline-info { background: #eef4ff; color: #1d4ed8; border: 1px solid #c7dbff; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.sidebar-brand .logo-badge { font-size: 16px; padding: 7px 12px; }
.brand-text { font-weight: 800; font-size: 17px; }
.brand-text small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.sidebar-nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: #333;
  font-weight: 600; font-size: 14px; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--red-light); text-decoration: none; }
.sidebar-nav a.active { background: var(--red); color: #fff; }
.sidebar-foot { padding: 12px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
}
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; font-size: 17px; }
.top-search { flex: 1; max-width: 520px; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.content { padding: 22px 22px 30px; flex: 1; }
.app-footer { padding: 14px 22px; color: var(--muted); font-size: 12px; text-align: center; border-top: 1px solid var(--line); background: #fff; }
.loading { color: var(--muted); padding: 30px; text-align: center; }

/* ---------- Painel ---------- */
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.card .big { font-size: 26px; font-weight: 800; }
.card .sub { color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.panel h4 { margin: 16px 0 8px; font-size: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; flex: 1; min-width: 140px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 13px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--red); border-color: var(--red); color: #fff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: #fafafa; }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: #eee; color: #333; white-space: nowrap;
}
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-yellow { background: var(--yellow-light); color: #7a5b00; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-gray { background: #f0f0f0; color: #555; }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 14px; }
.bar-row .lbl { width: 130px; flex-shrink: 0; }
.bar-track { flex: 1; height: 12px; background: #f0f0f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--red); border-radius: 999px; }
.bar-fill.yellow { background: var(--yellow); }
.bar-row .val { width: 70px; text-align: right; font-weight: 700; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.chat-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 300px; overflow-y: auto; background: #fafafa; margin-bottom: 10px; }
.chat-msg { margin-bottom: 10px; }
.chat-msg .who { font-size: 12px; color: var(--muted); font-weight: 700; }
.chat-msg .txt { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; margin-top: 3px; }
.chat-row { display: flex; gap: 8px; }
.chat-row input { flex: 1; }
.accordion { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; background: #fff; }
.accordion > summary { padding: 14px 16px; cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.accordion > summary::-webkit-details-marker { display: none; }
.accordion-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.price-input { width: 110px; display: inline-block; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.muted { color: var(--muted); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.right { text-align: right; }
.count { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 200; transform: translateX(-105%);
    transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-block; }
  .content { padding: 16px 14px 24px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
}
