/* ============================================================
   ITERBE — Sistema de Fluxo Interno
   Paleta: #582836 (vinho) | #D9AF7B (dourado)
   ============================================================ */

:root {
  --primary:       #582836;
  --primary-dark:  #3e1b25;
  --primary-light: #7a3a4a;
  --gold:          #D9AF7B;
  --gold-dark:     #b8904f;
  --gold-light:    #eedbb2;
  --bg:            #f7f3ef;
  --surface:       #ffffff;
  --surface-2:     #faf7f4;
  --border:        #e5ddd7;
  --text:          #2c1a20;
  --text-muted:    #7a6570;
  --success:       #2e7d32;
  --warning:       #e65100;
  --danger:        #b71c1c;
  --info:          #01579b;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 2px 12px rgba(88,40,54,.08);
  --shadow-lg:     0 8px 32px rgba(88,40,54,.15);
  --sidebar-w:     260px;
  --header-h:      64px;
  --transition:    .2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-dark); }

img { max-width: 100%; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ── Layout Shell ──────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,.18);
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo .logo-mark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  line-height: 1.1;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
}
.sidebar-user .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.sidebar-user .user-info { min-width: 0; }
.sidebar-user .user-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff;
}
.sidebar-user .user-role {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--gold-light); opacity: .7;
}

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

.nav-section-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.75);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--gold);
}
.sidebar-nav a .nav-icon {
  width: 18px; height: 18px;
  opacity: .8; flex-shrink: 0;
}
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.5);
  font-size: 12px;
  transition: color var(--transition);
}
.sidebar-footer a:hover { color: #fff; }

/* ── Main ──────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}
.topbar-title small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  display: block;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  color: var(--text-muted);
}
.notif-btn:hover { background: var(--border); color: var(--primary); }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px;
  max-width: 1300px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}
.page-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}
.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--gold-light);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.stat-card.urgent .stat-value { color: var(--danger); }
.stat-card.urgent .stat-icon { background: #ffebee; }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.success .stat-icon { background: #e8f5e9; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
}
.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
.card-body { padding: 22px; }
.card-body.no-pad { padding: 0; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tbl th {
  background: var(--surface-2);
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--surface-2); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(88,40,54,.25);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 16px rgba(88,40,54,.35); }

.btn-gold {
  background: var(--gold);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(217,175,123,.3);
}
.btn-gold:hover { background: var(--gold-dark); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b0000; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1b5e20; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88,40,54,.12);
}
.form-control::placeholder { color: #bbb; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-primary   { background: #f5eaed; color: var(--primary); }
.badge-gold      { background: var(--gold-light); color: var(--gold-dark); }
.badge-success   { background: #e8f5e9; color: var(--success); }
.badge-warning   { background: #fff3e0; color: #e65100; }
.badge-danger    { background: #ffebee; color: var(--danger); }
.badge-info      { background: #e3f2fd; color: var(--info); }
.badge-neutral   { background: var(--border); color: var(--text-muted); }

/* Status badges */
.status-em_andamento { background: #e3f2fd; color: #01579b; }
.status-concluido    { background: #e8f5e9; color: #2e7d32; }
.status-devolvido    { background: #fff3e0; color: #e65100; }
.status-arquivado    { background: var(--border); color: var(--text-muted); }
.status-suspenso     { background: #ffebee; color: #b71c1c; }

/* Priority badges */
.priority-normal  { background: var(--border); color: var(--text-muted); }
.priority-alta    { background: #fff3e0; color: #e65100; }
.priority-urgente { background: #ffebee; color: #b71c1c; font-weight: 800; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 4px solid;
}
.alert-success { background: #e8f5e9; border-color: var(--success); color: #1b5e20; }
.alert-error   { background: #ffebee; border-color: var(--danger);  color: #7f0000; }
.alert-warning { background: #fff8e1; border-color: #f9a825;        color: #5c4000; }
.alert-info    { background: #e3f2fd; border-color: var(--info);    color: #0d3c61; }

/* ── Timeline (histórico) ──────────────────────────────────── */
.timeline { position: relative; padding: 0; }
.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 24px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--text-muted);
  z-index: 1;
}
.timeline-icon.action-criado      { background: #e3f2fd; border-color: #1565c0; color: #1565c0; }
.timeline-icon.action-encaminhado { background: #f3e5f5; border-color: #6a1b9a; color: #6a1b9a; }
.timeline-icon.action-concluido   { background: #e8f5e9; border-color: #2e7d32; color: #2e7d32; }
.timeline-icon.action-devolvido   { background: #fff3e0; border-color: #e65100; color: #e65100; }
.timeline-body { flex: 1; padding-top: 6px; }
.timeline-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.timeline-text { font-size: 13.5px; color: var(--text); }

/* ── Flow Steps ────────────────────────────────────────────── */
.flow-track {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0 12px;
}
.flow-step {
  display: flex;
  align-items: center;
}
.flow-node {
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--border);
  color: var(--text-muted);
  border: 2px solid transparent;
}
.flow-node.done    { background: #e8f5e9; color: var(--success); border-color: var(--success); }
.flow-node.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.flow-node.pending { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.flow-arrow {
  color: var(--border);
  font-size: 16px;
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Auth Pages ────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d9af7b' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.auth-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 32px 36px 24px;
  text-align: center;
}
.auth-header .auth-logo {
  font-size: 28px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 2px;
  line-height: 1;
}
.auth-header .auth-subtitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,.55);
  margin-top: 4px;
}
.auth-header .auth-inst {
  font-size: 13px;
  color: rgba(255,255,255,.75);
  margin-top: 10px;
}
.auth-body { padding: 32px 36px; }
.auth-footer {
  padding: 16px 36px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ── QR Code Setup ─────────────────────────────────────────── */
.qr-box {
  text-align: center;
  padding: 24px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  margin-bottom: 20px;
}
.qr-box #qrcode {
  display: inline-block;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.secret-code {
  font-family: 'Courier New', monospace;
  font-size: 16px;
  letter-spacing: 3px;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface-2);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  margin: 12px 0;
  user-select: all;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--primary); color: #fff; }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ── OTP Input ─────────────────────────────────────────────── */
.otp-input {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 12px;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  font-family: 'Courier New', monospace;
  color: var(--primary);
  background: var(--surface-2);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.otp-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88,40,54,.12);
  background: #fff;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-primary{ color: var(--primary); }
.text-gold   { color: var(--gold-dark); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.fw-bold     { font-weight: 700; }
.fw-900      { font-weight: 900; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.d-flex   { display: flex; }
.d-none   { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .4;
}
.empty-state p { font-size: 14px; }

/* Print */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main-wrap { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
