:root {
  --bg: #f4f6fb;
  --sidebar: #1a1a2e;
  --sidebar-hover: #16213e;
  --card: #ffffff;
  --accent: #2563eb;
  --accent2: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── SIDEBAR ────────────────────────────────────── */
.sidebar {
  width: 230px;
  min-height: 100vh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand h2 {
  color: var(--accent-color, #60a5fa);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
}

.sidebar-brand small {
  color: rgba(255,255,255,.4);
  font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  transition: all .15s;
}

.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: rgba(37,99,235,.25); color: #fff; border-right: 3px solid var(--accent); }
.nav-link .icon { font-size: 16px; width: 20px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.35);
  font-size: 11px;
}

/* ── MAIN ────────────────────────────────────────── */
.main {
  margin-left: 230px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 18px; font-weight: 600; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}

.content { padding: 28px; flex: 1; }

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

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

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-icon  { font-size: 22px; margin-bottom: 8px; }

/* ── TABELAS ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* ── BOTÕES ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--accent2); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ── FORMS ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], select, textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
  transition: border .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ── BUSCA ───────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search-bar input { max-width: 320px; }

/* ── MODAL ───────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h4 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.btn-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); line-height: 1;
}
.btn-close:hover { color: var(--text); }

/* ── ALERTAS ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #78350f; }
.alert-danger  { background: #fef2f2; border-color: var(--danger); color: #7f1d1d; }
.alert-success { background: #f0fdf4; border-color: var(--accent2); color: #14532d; }

/* ── LINHA ITENS (orçamento/venda) ───────────────── */
.itens-table input {
  padding: 6px 8px;
  font-size: 13px;
}

.row-item td { padding: 6px 4px; }

/* ── FINANCEIRO RESUMO ───────────────────────────── */
.fin-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.fin-card {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}
.fin-card .label { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.fin-card .value { font-size: 22px; font-weight: 700; }
.fin-card.receber .value { color: #16a34a; }
.fin-card.pagar   .value { color: #dc2626; }

/* ── LOGIN ───────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}
.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p  { color: var(--muted); margin-bottom: 28px; font-size: 13px; }

/* ── UTILITÁRIOS ─────────────────────────────────── */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.text-green { color: #16a34a; }
.text-red   { color: #dc2626; }
.fw-bold    { font-weight: 700; }
.text-right { text-align: right; }
.empty-state { text-align: center; padding: 48px; color: var(--muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
