@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Serif:wght@500;600;700&display=swap');

:root {
  --primary: #1E3A5F;
  --primary-hover: #0B1E3F;
  --secondary: #9A6A2F;
  --secondary-hover: #6E4A1E;
  --accent: #9A6A2F;
  --accent-soft: #F3EAD7;
  --success: #2D5F4C;
  --success-hover: #244C3D;
  --danger: #8B1F2F;
  --warning: #8B6914;
  --text-main: #1A2233;
  --text-muted: #5B6470;
  --bg-color: #EEEAE1;
  --card-bg: #ffffff;
  --border-color: #E3DCCE;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  margin: 20px auto 40px auto;
  max-width: 1440px;
  padding: 0 28px;
}

/* Novo layout de Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--primary-hover);
}
.page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

/* Estatísticas do Topo */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.stat-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-sub {
  font-size: 14px;
  font-weight: 500;
}
.stat-sub.positive { color: var(--success); }
.stat-sub.neutral { color: var(--secondary); }
.stat-sub.warning { color: var(--danger); }

h1 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--primary-hover);
  display: inline-block;
}

h2 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  color: var(--primary-hover);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(154, 106, 47, 0.16);
  background: #fff;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; align-items: center;}

button {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

.btn { background: var(--primary); color: #fff; box-shadow: 0 4px 14px 0 rgba(11, 30, 63, 0.22); }
.btn:hover { background: var(--primary-hover); box-shadow: 0 6px 20px rgba(11, 30, 63, 0.26); }

.btn2 { background: var(--secondary); color: #fff; box-shadow: 0 4px 14px 0 rgba(14, 165, 233, 0.39); }
.btn2:hover { background: var(--secondary-hover); }

.btn3 { background: var(--text-muted); color: #fff; box-shadow: 0 4px 14px 0 rgba(100, 116, 139, 0.39); }
.btn3:hover { background: #475569; }

.btn4 { background: var(--success); color: #fff; box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39); }
.btn4:hover { background: var(--success-hover); }

.msg { margin-top: 12px; font-size: 14px; font-weight: 500; animation: fadeIn 0.3s ease; }
.ok { color: var(--success); background: #dcfce7; padding: 10px 14px; border-radius: var(--radius-md); border-left: 4px solid var(--success); }
.err { color: var(--danger); background: #fee2e2; padding: 10px 14px; border-radius: var(--radius-md); border-left: 4px solid var(--danger); }

.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); box-shadow: none; }
.btn-outline:hover { background: rgba(154, 106, 47, 0.08); }

.form-group { margin-bottom: 12px; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: block; }
.hint a { color: var(--primary); text-decoration: none; font-weight: 500;}
.hint a:hover { text-decoration: underline; }

/* Tabela */
.eventos-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 16px; font-size: 13px; background: #fff; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-color); }
.eventos-table th, .eventos-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-color); }
.eventos-table th { background: #f8fafc; font-weight: 600; color: var(--text-main); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; }
.eventos-table tr:last-child td { border-bottom: none; }
.eventos-table tbody tr { transition: background 0.15s ease; }
.eventos-table tbody tr:hover { background: #f8fafc; }
.eventos-table .secao-row { background: #f1f5f9; font-weight: 600; color: var(--text-main); }
.eventos-table .btn-del { background: #fee2e2; color: #dc2626; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; border: 0; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.eventos-table .btn-del:hover { background: #fecaca; }
.btn-edit { background: #fef3c7; color: #d97706; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; border: 0; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.btn-edit:hover { background: #fde68a; }
.td-acoes { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }

/* Modal */
#modalModelos { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
#modalModelos.open { display: flex; opacity: 1; }
.modal-box { background: #fff; border-radius: var(--radius-lg); width: 90%; max-width: 600px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
#modalModelos.open .modal-box { transform: scale(1); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; border: none; padding: 0; }
.modal-close { background: #f1f5f9; color: var(--text-muted); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; transition: background 0.2s; }
.modal-close:hover { background: #e2e8f0; color: var(--text-main); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 20px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; background: #f8fafc; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Autocomplete localidade */
.ac-wrap{position:relative}
.ac-list{position:absolute;top:100%;left:0;right:0;background:#fff;border:1px solid var(--border-color);border-top:0;border-radius:0 0 var(--radius-md) var(--radius-md);max-height:220px;overflow-y:auto;z-index:10;display:none;box-shadow:var(--shadow-md)}
.ac-list.open{display:block}
.ac-item{padding:10px 14px;font-size:13px;cursor:pointer;border-bottom:1px solid #f1f5f9;transition: background 0.2s;}
.ac-item:hover,.ac-item.active{background:#f0fdf4}
.ac-item:last-child{border-bottom:none;}
.ac-item .ac-code{font-size:11px;color:#94a3b8;margin-left:6px; background: #f1f5f9; padding: 2px 6px; border-radius: 4px;}
.ac-item .ac-city{font-size:11px;color:#64748b; display: block; margin-top: 2px;}

/* Utils */
.check-label{display:inline-flex;align-items:center;gap:8px;font-size:14px;cursor:pointer; background: #fff; padding: 8px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-color);}
.check-label input[type=checkbox]{width:18px;height:18px;accent-color:var(--warning); margin: 0; box-shadow: none;}
.check-flag{color:var(--warning);font-weight:600}
.badge-verificar{display:inline-block;background:#fef3c7;color:#92400e;font-size:10px;font-weight:700;padding:2px 8px;border-radius:12px;margin-left:6px}
.preview-local{color:var(--primary);font-size:12px;font-style:italic; font-weight: 500;}

/* Fila */
.fila-table{width:100%;border-collapse:separate;border-spacing:0;margin-top:12px;font-size:13px; border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden;}
.fila-table th,.fila-table td{padding:10px 12px;text-align:left; border-bottom: 1px solid var(--border-color); background: #fff;}
.fila-table th{background:#f8fafc;font-weight:600; color:var(--text-muted); font-size:12px;}
.fila-table input { padding: 6px 8px; font-size: 13px; margin: 0; }
.fila-table .btn-rm{background:#fee2e2;color:#dc2626;padding:4px 8px;border-radius:var(--radius-sm);font-size:12px;cursor:pointer;border:0; transition: background 0.2s;}
.fila-table .btn-rm:hover { background: #fecaca; }
.fila-header{display:flex;align-items:center;gap:12px;margin-top:16px; margin-bottom: 8px;}
.fila-header span{font-size:15px;font-weight:600;color:var(--text-main)}
.fila-badge{background:var(--primary);color:#fff;font-size:12px;padding:2px 10px;border-radius:12px; font-weight: 600;}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==== SaaS Table ==== */
.saas-table { width: 100%; border-collapse: collapse; text-align: left; }
.saas-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 16px 12px; border-bottom: 2px solid var(--border-color); }
.saas-table td { padding: 16px 12px; border-bottom: 1px solid var(--border-color); font-size: 14px; vertical-align: middle; }
.saas-table tbody tr { transition: background 0.15s ease; cursor: pointer; }
.saas-table tbody tr:hover { background: #f8fafc; }

/* Avatares e Textos Principais na Tabela */
.av-wrapper { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.avatar { background: #f1f5f9; color: #475569; font-size: 11px; font-weight: 600; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; text-transform: uppercase; border: 1px solid #e2e8f0; flex-shrink: 0; }
.av-title-wrap { display: flex; flex-direction: column; }
.av-title { font-weight: 500; color: var(--text-main); font-size: 14px; }
.av-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Status Pills */
.status-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-pill.approved { background: #dcfce7; color: #166534; }
.status-pill.pending { background: #e0f2fe; color: #0284c7; }
.status-pill.incomplete { background: #fee2e2; color: #dc2626; }

/* Modal HTML <dialog> modernizado */
dialog.modal {
  border: none;
  background: transparent;
  padding: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  max-width: none;
  max-height: none;
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
}
.modal-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
}
.modal-container {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-heading h2 { margin: 0; padding: 0; border: none; font-size: 18px; }
.modal-main {
  padding: 24px;
  overflow-y: auto;
}

/* ==================== RESPONSIVIDADE MOBILE ==================== */
@media(max-width:768px){
  .grid,.grid3{grid-template-columns:1fr}
  .wrap { padding: 0 10px; margin: 12px auto; max-width: 100% !important; }
  .card { padding: 12px; margin-bottom: 12px; }
  h1 { font-size: 18px; }
  h2 { font-size: 15px; margin-bottom: 10px; padding-bottom: 6px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .page-tab { padding: 6px 12px; font-size: 12px; }
  button { padding: 8px 12px; font-size: 13px; }
  .btn, .btn2, .btn3, .btn4, .btn-outline { padding: 8px 12px; font-size: 13px; }
  input, select, textarea { padding: 10px 12px; font-size: 14px; }
  label { font-size: 12px; margin: 8px 0 4px; }
  .row { gap: 8px; margin-top: 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 24px; }
  .stat-title { font-size: 10px; }
  .eventos-table th, .eventos-table td { padding: 8px 6px; font-size: 12px; }
  .fila-table th, .fila-table td { padding: 6px 4px; font-size: 11px; }
  .modal-box { width: 95%; max-height: 90vh; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 14px 16px; }
  .saas-table td, .saas-table th { padding: 10px 8px; font-size: 13px; }
  .av-wrapper { min-width: auto; }

  /* Sidebar mobile */
  #appContent { margin-left: 0 !important; }
}

@media(max-width:480px){
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 20px; }
  h1 { font-size: 16px; }
  .card { padding: 10px; border-radius: 10px; }
  button { font-size: 12px; padding: 7px 10px; }
}
