:root {
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --blue-light: #eff6ff;
  --bg: #f5f6f8;
  --border: #e2e5ea;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#app { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--blue-dark), var(--blue)); }
.login-card { background: #fff; padding: 40px; border-radius: 12px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.login-card .login-logo { display: block; height: 56px; width: auto; margin: 0 auto 16px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--blue); color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.btn:hover { background: var(--blue-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f3f4f6; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; justify-content: center; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }
.ok-msg { color: var(--success); font-size: 13px; margin-top: 10px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--blue-dark); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.sidebar .brand-logo-box { background: #fff; border-radius: 8px; padding: 5px 7px; display: flex; align-items: center; flex-shrink: 0; }
.sidebar .brand-logo-box img { height: 26px; width: auto; display: block; }
.sidebar .brand-title { font-weight: 700; font-size: 13px; line-height: 1.25; }
.sidebar .brand-sub { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 1px; }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a { display: block; padding: 10px 18px; font-size: 14px; color: rgba(255,255,255,0.75); border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,0.1); color: #fff; border-left-color: #fff; font-weight: 600; }
.sidebar .userbox { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 12px; }
.sidebar .userbox .name { font-weight: 600; margin-bottom: 2px; }
.sidebar .userbox .role { color: rgba(255,255,255,0.6); text-transform: uppercase; font-size: 10px; letter-spacing: .04em; }
.sidebar .userbox button { margin-top: 8px; background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #fff; padding: 5px 10px; border-radius: 5px; font-size: 12px; }

.main { flex: 1; padding: 24px 28px; overflow-x: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { margin: 0; font-size: 20px; }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--blue-dark); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th { text-align: left; padding: 8px 10px; background: #f8f9fb; border-bottom: 2px solid var(--border); font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.admin { background: #fee2e2; color: #991b1b; }
.pill.vendedor { background: #dbeafe; color: #1e40af; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.off { background: #f3f4f6; color: #6b7280; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.toolbar input[type=text] { min-width: 240px; }

.search-results { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; margin-top: 8px; }
.search-results .row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.search-results .row:last-child { border-bottom: none; }
.search-results .row:hover { background: var(--blue-light); }
.search-results .meta { color: var(--muted); font-size: 11px; }

.cart-item { display: grid; grid-template-columns: 90px 1fr 90px 100px 100px 34px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cart-item input[type=number] { width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 5px; }
.cart-item .rm { color: var(--danger); background: none; border: none; font-size: 16px; }

.totals-box { margin-left: auto; width: 280px; }
.totals-box .line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.totals-box .line.total { font-weight: 700; font-size: 16px; color: var(--blue-dark); border-top: 2px solid var(--blue); padding-top: 8px; margin-top: 4px; }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; }
.pagination button { padding: 5px 10px; border: 1px solid var(--border); background: #fff; border-radius: 5px; }
.pagination button:disabled { opacity: 0.4; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.loading { text-align: center; padding: 30px; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 10px; padding: 24px; width: 420px; max-width: 92vw; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag { background: var(--blue-light); color: var(--blue-dark); padding: 3px 10px; border-radius: 20px; font-size: 12px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--blue-dark); }

.actions-inline { display: flex; gap: 6px; }
.actions-inline button { padding: 5px 10px; font-size: 12px; border-radius: 5px; border: 1px solid var(--border); background: #fff; }
.actions-inline button:hover { background: #f3f4f6; }
