/* ── Reset & variáveis ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-h:  #1d4ed8;
  --green:      #16a34a;
  --red:        #dc2626;
  --orange:     #ea580c;
  --yellow:     #ca8a04;
  --sb-bg:      #0f172a;
  --sb-w:       240px;
  --tb-h:       60px;
  --text:       #1e293b;
  --text-m:     #64748b;
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --border:     #e2e8f0;
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --radius:     10px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.main-wrap { flex: 1; margin-left: var(--sb-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin .3s; }
.content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-w);
  background: var(--sb-bg); color: #cbd5e1; display: flex; flex-direction: column;
  z-index: 200; overflow-y: auto; transition: transform .3s;
}
.sb-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sb-logo { width: 38px; height: 38px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; overflow: hidden; }
.sb-logo img { width: 100%; height: 100%; object-fit: cover; }
.sb-name { font-size: 13px; font-weight: 700; color: #f1f5f9; line-height: 1.3; }
.sb-nav { flex: 1; padding: .75rem 0; }
.sb-sec { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #475569; padding: 1rem 1rem .35rem; }
.sb-link {
  display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; color: #94a3b8; font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent; transition: all .18s; cursor: pointer; text-decoration: none;
}
.sb-link:hover { color: #f1f5f9; background: rgba(255,255,255,.06); text-decoration: none; }
.sb-link.active { color: #fff; background: rgba(37,99,235,.25); border-left-color: var(--primary); }
.sb-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sb-foot { border-top: 1px solid rgba(255,255,255,.08); padding: .75rem 1rem; }
.sb-user { display: flex; align-items: center; gap: .6rem; }
.sb-av { width: 34px; height: 34px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0; }
.sb-uinfo { flex: 1; min-width: 0; }
.sb-uname { font-size: 13px; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-urole { font-size: 11px; color: #64748b; }
.sb-logout { color: #64748b; padding: .3rem; border-radius: 6px; transition: color .2s; }
.sb-logout:hover { color: #f87171; }
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--tb-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
}
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: .4rem; border-radius: 6px; }
.hamburger:hover { background: var(--bg); }
.topbar-title { font-size: 16px; font-weight: 700; flex: 1; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.hide-sm {}

/* ── Cards ───────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 1.25rem; }

/* ── Stats ───────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow); }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.red    { background: #fee2e2; }
.stat-val { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-lbl { font-size: 12px; color: var(--text-m); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: all .18s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost     { background: #f8fafc; color: var(--text); border-color: var(--border); font-weight: 500; }
.btn-ghost:hover { background: var(--border); }
.btn-sm  { padding: .35rem .75rem; font-size: 12px; }
.btn-xs  { padding: .2rem .5rem; font-size: 11px; border-radius: 6px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12px; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-m); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
  width: 100%; padding: .55rem .85rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text); background: #fff;
  transition: border-color .18s, box-shadow .18s; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 72px; }
.req { color: var(--red); }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--text-m); margin: 1.25rem 0 .75rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-m); background: #f8fafc; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pendente     { background: #fef3c7; color: #92400e; }
.badge-em_andamento { background: #dbeafe; color: #1e40af; }
.badge-concluido    { background: #dcfce7; color: #166534; }
.badge-cancelado    { background: #fee2e2; color: #991b1b; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert { padding: .75rem 1.1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 13px; font-weight: 500; animation: fadein .3s ease; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
@keyframes fadein { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.page-sub { font-size: 15px; font-weight: 500; color: var(--text-m); }

/* ── Grid / helpers ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mt-1 { margin-top: .75rem; }
.mt-2 { margin-top: 1.25rem; }
.mb-2 { margin-bottom: 1.25rem; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-m); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-m); }

/* ── Placa tag ───────────────────────────────────────────────────── */
.placa-tag { background: #1e293b; color: #f1f5f9; padding: .15rem .55rem; border-radius: 6px; font-size: 12px; letter-spacing: .08em; font-family: monospace; }

/* ── Action buttons (tabela) ─────────────────────────────────────── */
.action-btns { display: flex; gap: .3rem; flex-wrap: wrap; }

/* ── Item row (form serviços) ────────────────────────────────────── */
.item-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.quick-add { margin-top: .75rem; border-top: 1px dashed var(--border); padding-top: .75rem; }
.total-row { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; margin-top: 1rem; padding-top: .75rem; border-top: 2px solid var(--border); font-weight: 600; font-size: 15px; }
.total-val { font-size: 20px; font-weight: 800; color: var(--primary); }

/* ── Notificações ────────────────────────────────────────────────── */
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-m); position: relative; padding: .4rem; border-radius: 8px; transition: background .18s; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.notif-wrap { position: relative; }
.notif-badge { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: 9px; font-weight: 800; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.notif-panel { display: none; position: absolute; right: 0; top: calc(100% + 8px); width: 310px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.15); z-index: 500; }
.notif-panel.open { display: block; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.notif-item { padding: .65rem 1rem; border-bottom: 1px solid var(--border); font-size: 12px; display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--bg); }
.notif-item:last-child { border-bottom: none; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-m); font-size: 13px; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 1.75rem; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: .5rem; }

/* ── Calendário ─────────────────────────────────────────────────── */
.cal-table { table-layout: fixed; }
.cal-table th { text-align: center; padding: .6rem; background: #f8fafc; font-size: 11px; }
.cal-table td { vertical-align: top; height: 100px; padding: .4rem; border: 1px solid var(--border); font-size: 11px; }
.cal-table td.cal-empty { background: #fafafa; }
.cal-table td.cal-today { background: #eff6ff; }
.cal-num { font-weight: 700; font-size: 13px; margin-bottom: .25rem; color: var(--text); }
.cal-ev { display: block; background: #dbeafe; color: #1e40af; border-radius: 4px; padding: 1px 4px; margin-bottom: 2px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.cal-ev:hover { background: var(--primary); color: #fff; text-decoration: none; }
.cal-ev.status-concluido { background: #dcfce7; color: #166534; }
.cal-ev.status-cancelado { background: #fee2e2; color: #991b1b; opacity: .6; }
.cal-ev.status-em_andamento { background: #e0f2fe; color: #0369a1; }
.cal-tot { font-size: 9px; color: var(--green); font-weight: 700; margin-top: 2px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sb-overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  .hamburger { display: flex; }
  .hide-sm { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .item-row { flex-direction: column; }
  .item-row .form-control { width: 100% !important; flex: unset !important; }
  .cal-table td { height: 65px; }
  .notif-panel { width: 260px; right: -60px; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
}
