/* ══ RESET & VARS ══════════════════════════════════════ */
:root {
  --cream:        #fdf6ef;
  --warm-white:   #faf4ee;
  --caramel:      #b5692a;
  --caramel-dark: #8f4e1c;
  --caramel-light:#d4844a;
  --caramel-pale: #f0d5be;
  --blush:        #f5e6d8;
  --sand:         #e8d5c0;
  --sidebar:      #3d2b1a;
  --sidebar-hover:#5a3f28;
  --sidebar-act:  #b5692a;
  --text:         #3d2b1a;
  --text-mid:     #7a5035;
  --text-muted:   #b8896a;
  --border:       #f0d5be;
  --green:        #5a9e6f;
  --red:          #c0392b;
  --sidebar-w:    240px;
  --radius:       10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', sans-serif; font-size: .875rem; background: var(--cream); color: var(--text); display: flex; }

/* ══ SIDEBAR ═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid #5a3f28;
  min-height: 72px;
  flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px;
  background: var(--caramel);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  flex-shrink: 0;
  font-family: Georgia, serif;
  letter-spacing: 1px;
}
.brand-name { font-size: .72rem; font-weight: 600; color: var(--caramel-pale); line-height: 1.4; }
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.sidebar-footer { padding: 8px; border-top: 1px solid #5a3f28; flex-shrink: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #c8a882;
  text-decoration: none;
  font-size: .8rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--caramel-pale); }
.nav-item.active { background: var(--caramel); color: #fff; }
.nav-icon { flex-shrink: 0; width: 18px; display: flex; align-items: center; }

/* ══ MAIN ═══════════════════════════════════════════════ */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s;
}
.topbar {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 99;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(181,105,42,.07);
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-mid);
  padding: 4px;
  line-height: 1;
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; color: var(--text); }
.topbar-user { font-size: .8rem; color: var(--text-muted); }
.content { padding: 24px; flex: 1; }

/* ══ CARDS ══════════════════════════════════════════════ */
.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(181,105,42,.06);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
  background: var(--warm-white);
}
.card-header h2 { font-size: .9rem; font-weight: 600; color: var(--text); }

/* ══ STAT CARDS ═════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 2px 12px rgba(181,105,42,.06);
}
.stat-card.accent { border-color: var(--caramel); background: #fdf0e4; }
.stat-card.green  { border-color: #a8d5b5; background: #f0f7f3; }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card.accent .stat-value { color: var(--caramel); }
.stat-card.green  .stat-value { color: #3d7a52; }
.stat-label {
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ══ TABLE ══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--blush);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fdf3ea; }

/* ══ BADGES ═════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.badge-novo       { background: #fde8d0; color: #8f4e1c; }
.badge-confirmado { background: #fef3c7; color: #92400e; }
.badge-enviado    { background: #e8e4f5; color: #4c3a8a; }
.badge-entregue   { background: #d4edda; color: #2d6a4f; }
.badge-cancelado  { background: #fde8e8; color: #9b2335; }

/* ══ BUTTONS ════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, filter .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--caramel); color: #fff; }
.btn-primary:hover { background: var(--caramel-dark); }
.btn-ghost { background: transparent; color: var(--text-mid); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--blush); }
.btn-outline { background: transparent; color: var(--caramel); border: 1px solid var(--caramel); }
.btn-outline:hover { background: #fde8d0; }
.btn-danger { background: #fde8e8; color: var(--red); }
.btn-danger:hover { background: #facaca; }
.btn-sm { padding: 5px 10px; font-size: .75rem; }
.btn-block { width: 100%; justify-content: center; }

/* ══ FORMS ══════════════════════════════════════════════ */
.form-group { margin-bottom: 14px; }
.form-group.mb-0 { margin-bottom: 0; }
.form-group label {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-ctrl {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--cream);
  transition: border-color .15s;
  outline: none;
}
.form-ctrl:focus { border-color: var(--caramel); box-shadow: 0 0 0 3px rgba(181,105,42,.12); }
.form-ctrl[readonly] { background: var(--blush); color: var(--text-muted); cursor: default; }
textarea.form-ctrl { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }

/* ══ ALERTS ═════════════════════════════════════════════ */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .85rem; margin-bottom: 16px; }
.alert-success { background: #d4edda; color: #2d6a4f; border: 1px solid #a8d5b5; }
.alert-danger  { background: #fde8e8; color: #9b2335; border: 1px solid #f5b8b8; }

/* ══ DETAIL VIEW ════════════════════════════════════════ */
.detail-grid { padding: 4px 0; }
.detail-row {
  display: flex;
  gap: 16px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.detail-row:last-child { border-bottom: none; }
.detail-row > span {
  width: 130px;
  flex-shrink: 0;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}

/* ══ MODAL ══════════════════════════════════════════════ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(61,43,26,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--warm-white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(61,43,26,.2);
  overflow: hidden;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box .card-header { border-bottom: 1px solid var(--border); padding: 14px 20px; }
.modal-box form { padding: 20px; }

/* ══ SIDEBAR OVERLAY (mobile) ═══════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61,43,26,.4);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* ══ UTILITIES ══════════════════════════════════════════ */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.gap-16 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--caramel); font-weight: 600; }
.code-tag {
  background: var(--blush);
  border: 1px solid var(--caramel-pale);
  border-radius: 5px;
  padding: 2px 9px;
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--caramel-dark);
}
a { color: var(--caramel); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }

/* ══ LOGIN ══════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  background-image: linear-gradient(135deg, var(--blush) 0%, var(--cream) 60%);
  min-height: 100vh;
  margin: 0;
}
.login-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(181,105,42,.15);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--caramel), var(--caramel-light));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; color: #fff;
  margin: 0 auto 14px;
  font-family: Georgia, serif;
  letter-spacing: 1px;
}
.login-brand h1 { font-size: 1rem; font-weight: 700; color: var(--text); }
.login-brand p  { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }

/* ══ SCROLLBAR ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--cream); }
::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--caramel-pale); }

/* ══ RESPONSIVE ═════════════════════════════════════════ */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar-toggle { display: block; }
  .main-wrap { margin-left: 0; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 16px; }
  .content { padding: 12px; }
}