/* =========================================================
   Honest ERP — App Layout Base (Clean)
   - One design system
   - One table system
   - Responsive shell (sidebar/topbar/bottom-nav)
========================================================= */

/* =======================
   1) TOKENS / THEME
======================= */
:root{
  /* layout */
  --sidebar-w: 92px;
  --topbar-h: 64px;
  --bottombar-h: 76px;

  /* colors */
  --bg:#f6f7f9;
  --card:#ffffff;
  --hover:#f0f2f5;
  --text:#1f2937;
  --muted:#6b7280;
  --border:#e5e7eb;

  --primary:#ff7a00;
  --primary-soft: rgba(255,122,0,.12);
  --danger:#ef4444;
  --success:#16a34a;
  --info:#0d6efd;

  /* surfaces */
  --radius: 14px;
  --shadow: 0 1px 1px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.06);

  /* motion */
  --t: .18s ease;

  /* typography */
  --font: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* light-only (force) */
  color-scheme: light;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
}

/* optional: better tap highlight */
a,button{ -webkit-tap-highlight-color: transparent; }

/* =======================
   2) UTILITIES
======================= */
.muted{ color:var(--muted) !important; }
.text-right{ text-align:right !important; }
.text-center{ text-align:center !important; }
.text-left{ text-align:left !important; }

.t-ok{ color:var(--success) !important; }
.t-bad{ color:#dc2626 !important; }
.t-info{ color:var(--info) !important; }

.td-ellipsis{
  max-width: 420px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* =======================
   3) INPUTS / BUTTONS
======================= */
.form-control,.form-select{
  min-height:44px;
  border-radius:12px;
}

.btn-soft{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:9px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  text-decoration:none;
  box-shadow: var(--shadow);
  transition:var(--t);
  font-size:.88rem;
}
.btn-soft:hover{ background:var(--hover); }
.btn-soft i{ font-size:1.05rem; }

/* icon-only button (consistent everywhere) */
.btn-icon{
  width:34px;
  height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border-radius:12px;
}

/* Fix double-arrow select across browsers */
.form-select{
  -webkit-appearance:none;
  -moz-appearance:none;
  appearance:none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right .85rem center;
  background-size:18px 18px;
  padding-right:2.5rem;
}

/* =======================
   4) CARDS / SECTIONS
======================= */
.card-soft,
.section{
  background:var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section{ overflow:hidden; }
.section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom:1px solid var(--border);
  background:#fafafa;
}
.section-head .h{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:900;
}
.section-head .h i{ color: var(--primary); font-size: 1.1rem; }
.section-body{ padding: 12px 14px; }

/* =======================
   5) APP SHELL
======================= */
.app-shell{ min-height:100vh; display:block; }

/* Sidebar (desktop) */
.app-sidebar{
  position:fixed;
  top:0; left:0;
  width:var(--sidebar-w);
  height:100vh;
  background:var(--card);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding:10px 8px;
  z-index:1030;
}

.sidebar-top,
.sidebar-footer{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
}

.sidebar-mid{
  margin:14px 0;
  display:grid;
  gap:10px;
  justify-items:center;
  flex:1;
  align-content:start;
}

.sb-divider{
  width:78%;
  border-top:2px solid var(--border);
  margin:6px auto;
}

.sb-item{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  text-decoration:none;
  color:var(--muted);
  border-radius:14px;
  padding:8px 6px;
  transition:var(--t);
  position:relative;
  background:transparent;
  border:0;
  cursor:pointer;
}

.sb-item:hover{ background:var(--hover); color:var(--text); }
.sb-item.active{ background:var(--primary-soft); color:var(--primary); }

.sb-ico{
  width:44px; height:44px;
  border-radius:14px;
  display:grid;
  place-items:center;
  background: rgba(17,24,39,.04);
  border:1px solid rgba(17,24,39,.06);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.sb-item.active .sb-ico{
  background:#fff;
  border-color: rgba(255,122,0,.30);
}
.sb-item i{ font-size:1.35rem; line-height:1; }

.sb-lbl{
  font-size:.70rem;
  line-height:1;
  text-align:center;
  max-width: 82px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.sb-badge{
  position:absolute;
  top:4px;
  right:14px;
  background:var(--danger);
  color:#fff;
  font-size:.62rem;
  padding:2px 6px;
  border-radius:999px;
  border:2px solid var(--card);
}

.sb-avatar{
  width:46px;height:46px;
  border-radius:50%;
  background:var(--primary);
  color:#fff;
  display:grid;
  place-items:center;
  font-weight:900;
  letter-spacing:.5px;
}

.sb-logout:hover{
  background: rgba(239,68,68,.08);
  color:var(--danger);
}

/* Content area */
.app-content{
  margin-left: var(--sidebar-w);
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

/* Topbar fixed */
.app-topbar{
  position:fixed;
  left:var(--sidebar-w);
  top:0; right:0;
  height:var(--topbar-h);
  background:var(--card);
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 16px;
  z-index:1020;
}

.topbar-left,
.topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
}

.topbar-user{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:.88rem;
}

/* Main */
.app-main{
  padding: calc(var(--topbar-h) + 16px) 16px 22px;
}

/* Page wrap (responsive width)
   OBS: mantive sua lógica original (base maior, depois ajusta).
   Se quiser “crescer” com a tela, eu te passo a versão alternativa.
*/
.page-wrap{
  width:100%;
  max-width: 1500px;
  margin:0 auto;
}
@media (min-width:1200px){ .page-wrap{ max-width: 1280px; } }
@media (min-width:1600px){ .page-wrap{ max-width: 1500px; } }
@media (min-width:1900px){ .page-wrap{ max-width: 1700px; } }

/* Bottom nav (mobile/tablet) */
.bottom-nav{
  position:fixed;
  left:0; right:0; bottom:0;
  height:var(--bottombar-h);
  background:var(--card);
  border-top:1px solid var(--border);
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  padding:8px 10px;
  z-index:1500;
}
.bn-item{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-decoration:none;
  color:var(--muted);
  border-radius:12px;
  padding:6px 4px;
  transition: var(--t);
  border:0;
  background:transparent;
}
.bn-item.active{ color:var(--primary); background: var(--primary-soft); }
.bn-item i{ font-size:1.35rem; }
.bn-item span{ font-size:.70rem; line-height:1; }

@media (max-width: 991.98px){
  .app-content{ margin-left:0; }
  .app-topbar{ left:0; }
  .app-main{ padding-bottom: calc(var(--bottombar-h) + 16px); }
}

/* =======================
   6) PAGE HEADER (standard)
======================= */
.page-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 14px;
}
.page-title{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.page-title h1{
  font-size:1.15rem;
  margin:0;
  font-weight:900;
}
.page-title .muted{ font-size:.88rem; }

.page-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:nowrap;
}
@media (max-width: 768px){
  .page-header{ flex-direction:column; align-items:stretch; }
  .page-actions{ flex-direction:column; align-items:stretch; width:100%; }
  .page-actions .btn, .page-actions .btn-soft, .page-actions .form-select, .page-actions .form-control{ width:100%; }
}

/* =======================
   7) TABLE SYSTEM (ONE BASE)
======================= */
.table-scroll{
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

/* base table */
.table-app{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size: .90rem;
}

/* header */
.table-app thead th{
  background:#fff;
  position: sticky;
  top:0;
  z-index:2;
  border-bottom:1px solid var(--border);
  white-space:nowrap;
  padding: 8px 8px;
  color: var(--muted);
  font-size:.72rem;
  letter-spacing:.2px;
  text-transform: uppercase;
  text-align: center;
}

/* cells */
.table-app td{
  border-bottom:1px solid #f1f2f4;
  padding: 8px 8px;
  vertical-align: middle;
  white-space:nowrap;
  text-align: center;
}
.table-app tr:hover td{ background: var(--hover); }

/* align helpers */
.col-right{ text-align:right !important; }
.col-center{ text-align:center !important; }
.col-left{ text-align:left !important; }

/* wide table */
.table-wide{ min-width: 1120px; }

/* compact inputs inside table */
.table-app .form-control,
.table-app .form-select{
  min-height: 34px;
  border-radius: 10px;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* consistent money style */
.money{ font-weight:900; }
.money.ok{ color: var(--success); }
.money.bad{ color: var(--danger); }

/* Pagination bar */
.pagination-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-top:1px solid var(--border);
  background:#fafafa;
}

/* Mobile responsive table -> card mode (opt-in) */
@media (max-width: 768px){
  .table-app.table-responsive-cards{
    border-collapse: separate;
    border-spacing: 0 10px;
  }
  .table-app.table-responsive-cards thead{ display:none; }
  .table-app.table-responsive-cards tbody,
  .table-app.table-responsive-cards tr,
  .table-app.table-responsive-cards td{
    display:block;
    width:100%;
  }
  .table-app.table-responsive-cards tr{
    background:#fff;
    border:1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow:hidden;
  }
  .table-app.table-responsive-cards td{
    white-space: normal;
    border-bottom: 1px solid #f1f2f4;
    padding: 10px 12px;
    text-align: left;
  }
  .table-app.table-responsive-cards td:last-child{ border-bottom:0; }
  .table-app.table-responsive-cards td::before{
    content: attr(data-label);
    display:block;
    font-size:.72rem;
    color: var(--muted);
    font-weight: 900;
    letter-spacing:.2px;
    text-transform: uppercase;
    margin-bottom: 3px;
  }
  .td-ellipsis{
    max-width:none;
    overflow:visible;
    text-overflow:clip;
    white-space:normal;
  }
}

/* =======================
   8) OVERLAY MENU (full screen)
======================= */
.overlay{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 3000;
  display: none;
}
.overlay.show{ display:block; }

.overlay-panel{
  position:absolute;
  inset: 0;
  background: var(--card);
  display:flex;
  flex-direction:column;
}

.overlay-header{
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.overlay-title{
  display:flex;
  align-items:center;
  gap: 10px;
  font-weight: 900;
}

.overlay-close{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor:pointer;
  display:grid;
  place-items:center;
  transition: var(--t);
}
.overlay-close:hover{ background: var(--hover); }

.overlay-body{
  padding: 16px;
  overflow:auto;
}

/* menu groups */
.menu-groups{
  display:grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
}
@media (max-width: 991.98px){
  .menu-groups{ grid-template-columns: 1fr; }
}
.menu-group{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.menu-group-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 14px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
  font-weight: 900;
}
.menu-group-head .left{
  display:flex;
  align-items:center;
  gap: 10px;
}
.menu-group-head i{
  font-size: 1.15rem;
  color: var(--primary);
}
.menu-items{
  padding: 10px;
  display:grid;
  gap: 8px;
}
.menu-link{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration:none;
  color: var(--text);
  border: 1px solid var(--border);
  background:#fff;
  transition: var(--t);
}
.menu-link:hover{ background: var(--hover); }
.menu-link .lbl{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width:0;
}
.menu-link .lbl i{ font-size: 1.15rem; color: #0f172a; }
.menu-link .lbl span{
  font-weight: 700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.menu-link.active{
  border-color: rgba(255,122,0,.45);
  background: var(--primary-soft);
}

/* =======================
   9) DASHBOARD
======================= */
.chart-box{ height: 320px; }
@media (max-width: 768px){ .chart-box{ height: 250px; } }

/* ✅ KPI grid: vira “pacote” e centraliza */
.kpi-grid{
  display: grid;
  gap: 12px;
  margin-bottom: 14px;

  /* o segredo: colunas com largura fixa (não 1fr) */
  grid-template-columns: repeat(6, minmax(240px, 240px));

  /* centraliza o conjunto */
  justify-content: center;
}

@media (max-width: 1400px){
  .kpi-grid{
    grid-template-columns: repeat(3, minmax(240px, 240px));
  }
}

@media (max-width: 768px){
  .kpi-grid{
    grid-template-columns: 1fr;
  }
}

.kpi{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  min-height: 92px;
  transition: var(--t);
}
.kpi:hover{
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(16,24,40,.08);
}

.kpi .left{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap: 6px;
}
.kpi .label{
  display:flex;
  align-items:center;
  gap: 8px;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .2px;
  text-transform: uppercase;
}
.kpi .value{
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.05;
  color: var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.kpi .sub{
  font-size: .86rem;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.kpi .ico{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display:grid;
  place-items:center;
  border:1px solid rgba(17,24,39,.06);
  background: rgba(17,24,39,.04);
}
.kpi .ico i{ font-size: 1.25rem; }

.kpi.primary{
  border-color: rgba(255,122,0,.28);
  background: linear-gradient(180deg, #fff 0%, rgba(255,122,0,.06) 100%);
}
.kpi.primary .ico{ background: var(--primary-soft); border-color: rgba(255,122,0,.25); }
.kpi.primary .ico i{ color: var(--primary); }

.kpi.danger .ico{ background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.25); }
.kpi.danger .ico i{ color: var(--danger); }

.kpi.warning .ico{
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.28);
}
.kpi.warning .ico i{ color: #b45309; }

@media (max-width: 768px){
  .kpi{ padding: 12px; min-height: unset; }
  .kpi .value{
    font-size: 1.25rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.15;
  }
  .kpi .sub{
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.25;
  }
}

.dash-grid{
  display:grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 991.98px){
  .dash-grid{ grid-template-columns: 1fr !important; }
}

/* rank pill */
.rank-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-weight: 900;
  font-size: .78rem;
  border:1px solid var(--border);
  background:#fff;
}
.rank-pill.top{
  border-color: rgba(255,122,0,.35);
  background: var(--primary-soft);
  color: var(--primary);
}

/* =======================
   10) TERMINAIS
======================= */
.clients-wrap{ display:flex; flex-direction:column; gap:14px; }

.client-card{
  border:1px solid var(--border);
  border-radius: 12px;
  overflow:hidden;
  background:#fff;
  box-shadow: var(--shadow);
}
.client-header{
  background:#8d8d8d;
  color:#fff;
  font-weight:900;
  padding:10px 14px;
  letter-spacing:.2px;
}
.client-body{ background:#f4f5f6; padding:12px; }

.terminal-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius: 12px;
  overflow:hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.terminal-head{
  background:#efefef;
  padding:10px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom:1px solid var(--border);
}
.terminal-title{
  font-weight:900;
  color: var(--info);
  text-decoration:none;
  line-height:1.15;
}
.terminal-title:hover{ text-decoration: underline; }
.terminal-sub{
  margin-top:2px;
  font-size:.82rem;
  color:#64748b;
}
.terminal-status{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-weight:900;
  font-size:.82rem;
  white-space:nowrap;
}

.terminal-body{
  padding:12px;
  display:flex;
  gap:12px;
  align-items:stretch;
}
.terminal-meta{
  flex:1;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}
.meta-line{
  font-size:.92rem;
  color:#0f172a;
  display:flex;
  gap:6px;
  align-items:baseline;
  min-width:0;
}
.meta-label{
  color:#64748b;
  font-weight:900;
  font-size:.82rem;
  min-width: 140px;
}
.meta-value{
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.terminal-foot{
  padding:10px 12px;
  border-top:1px solid var(--border);
  background:#fafafa;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  font-size:.85rem;
  color:#64748b;
}

/* terminal actions */
.terminal-actions{
  display:flex;
  gap:10px;
  align-items:flex-end;
  justify-content:flex-start;
  min-width:64px;
  flex-direction:column;
}
.terminal-actions form{ display: contents; }

.action-btn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--border);
  background:#111827;
  color:#fff;
  text-decoration:none;
  cursor:pointer;
  padding:0;
  line-height:1;
  transition: var(--t);
}
.action-btn i{ font-size:18px; line-height:1; display:block; }
.action-btn:hover{ filter: brightness(1.08); }
.action-btn.secondary{ background:#0f172a; }
.action-btn.danger{ background:#991b1b; }

@media (max-width: 768px){
  .client-body{ padding:10px; }
  .terminal-body{ flex-direction:column; }
  .terminal-meta{ grid-template-columns: 1fr; gap: 8px; }
  .meta-line{
    flex-direction:column;
    align-items:flex-start;
    gap:2px;
    padding-bottom:6px;
    border-bottom:1px dashed #e5e7eb;
  }
  .meta-label{ min-width:0; }
  .meta-value{ white-space: normal; }

  .terminal-actions{
    width:100%;
    min-width:0;
    flex-direction:row;
    flex-wrap:wrap;
    align-items:center;
    justify-content:flex-start;
    margin-top:10px;
    padding-top:10px;
    border-top:1px solid var(--border);
  }
  .action-btn{ width:36px; height:36px; }
  .action-btn i{ font-size:16px; }
}

/* =======================
   11) FORCE LIGHT THEME
======================= */
html, body{
  background: var(--bg) !important;
  color: var(--text) !important;
}
@media (prefers-color-scheme: dark){
  :root{ color-scheme: light; }
  html, body{
    background: var(--bg) !important;
    color: var(--text) !important;
  }
  .form-control,
  .form-select,
  .btn,
  .btn-soft,
  .overlay-panel,
  .section,
  .kpi,
  .app-topbar,
  .app-sidebar,
  .bottom-nav{
    background: var(--card) !important;
    color: var(--text) !important;
  }
  .table-app thead th{
    background:#fff !important;
    color: var(--muted) !important;
  }
}

/* =========================================================
   FILTER BAR (padrão do sistema)
========================================================= */
.filters-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.filters-meta{
  color:var(--muted);
  font-size:.90rem;
}
.filters-meta strong{ color:var(--text); }

.filters-actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  align-items:stretch;
}
.filters-actions .btn{ min-height:44px; }

@media (max-width: 768px){
  .filters-actions{ flex-direction:column; width:100%; }
  .filters-actions .btn{ width:100%; }
}

/* =========================================================
   CARD FOOTER (padrão)
========================================================= */
.card-footer-soft{
  border-top:1px solid var(--border);
  background:#fafafa;
}

/* =========================================================
   BADGES (unificado)
========================================================= */
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-weight:800;
  border-radius:999px;
  padding:.38em .60em;
}

/* =========================================================
   TABLE WRAPPER alias (legado)
========================================================= */
.table-wrapper{
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

/* =========================================
   FIXES: tables/buttons inside table cells
========================================= */
.table-app td .btn,
.table-app td form{
  vertical-align: middle;
}
.table-app td form.d-inline{
  margin-left: 6px;
}

/* =========================================================
   PEDIDOS / TIMELINE (polish)
========================================================= */
.section-head .right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

/* ✅ CHIP (unificado) */
.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  font-size:.82rem;
  font-weight:800;
  color:var(--muted);
  box-shadow: var(--shadow);
  min-width: 32px;
}
.chip i{ color: var(--primary); }

.timeline{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-left: 14px;
  border-left: 2px solid #eef0f3;
}
.timeline-item{
  position:relative;
  background:#fff;
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:10px 12px;
}
.timeline-item::before{
  content:"";
  position:absolute;
  left:-22px;
  top:14px;
  width:10px;height:10px;
  border-radius:999px;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(255,122,0,.18);
}
.timeline-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.timeline-evt{
  font-weight:900;
  font-size:.86rem;
}
.timeline-meta{
  font-size:.78rem;
  color:var(--muted);
  white-space:nowrap;
}
.timeline-msg{ margin-top:6px; }
.timeline-user{
  margin-top:6px;
  font-size:.78rem;
  color:var(--muted);
}
.empty-state{
  padding:14px;
  border:1px dashed var(--border);
  border-radius: var(--radius);
  color:var(--muted);
  background:#fafafa;
  text-align:center;
}

/* =========================================================
   DDA (UI polish + FIX overflow)
========================================================= */
.dda-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width:100%;
  max-width:100%;
}
@media (max-width: 991.98px){
  .dda-grid{ grid-template-columns: 1fr; }
}

.dda-panel,
.dda-panel .section,
.dda-panel .section-body{
  max-width:100%;
}

.dda-panel .table-scroll{
  max-width:100%;
  overflow-x:auto;
}

.dda-panel .section-body{
  min-height: 220px;
}

.dda-grid .table-app{
  min-width: 0 !important;
}

/* checkbox */
.chk{
  width:18px;
  height:18px;
  border-radius:6px;
  accent-color: var(--primary);
  cursor:pointer;
}

/* ações */
.th-actions{ text-align:right !important; width:110px; }
.td-actions{ text-align:right !important; }

/* empty state */
.table-empty{
  padding: 18px 10px;
  text-align:center;
  color: var(--muted);
  font-weight:800;
}

/* “colunas seguras” */
.dda-grid .col-code{ width: 170px; }
.dda-grid .col-paid{ width: 70px; }
.dda-grid .col-value{ width: 150px; }
.dda-grid .col-status{ width: 150px; }
.dda-grid .col-paidat{ width: 210px; }

/* Tables densas (operações) */
.table-app.table-dense th,
.table-app.table-dense td{
  padding: .35rem .5rem;
  vertical-align: middle;
}

.table-app .btn.btn-sm{
  padding: .18rem .45rem;
  line-height: 1.1;
}

.table-app .mono{ font-variant-numeric: tabular-nums; }
.table-app .muted{ opacity:.75; }

/* Linha de lotes recolhida */
.row-lotes.is-hidden{ display:none; }

/* Evita quebra e mantém compacto */
.nowrap{ white-space:nowrap; }

/* helpers compactos */
.btn-xs{
  padding:.18rem .45rem !important;
  font-size:.75rem !important;
  line-height:1.1 !important;
  border-radius:10px !important;
}
.badge-xs{
  font-size:.70rem !important;
  padding:.20em .48em !important;
  border-radius:999px !important;
  font-weight:900 !important;
}
.small-muted{ font-size:.82rem; color:var(--muted); }
.trunc{
  max-width:520px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* =========================================================
   DASHBOARD polish (cards + header + filters)
========================================================= */
.dash-wrap .dash-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom: 12px;
}
.dash-wrap .dash-title h1{
  margin:0;
  font-size:1.25rem;
  font-weight: 950;
  letter-spacing: -.2px;
}
.dash-wrap .dash-title .muted{
  font-size:.90rem;
  margin-top: 2px;
}

/* ✅ não usamos mais .dash-filters no header */
.dash-wrap .dash-filters{ display:none; }

/* ✅ filtro do dashboard (abaixo dos KPIs): 1 linha no desktop */
.dash-filter-card{
  padding: 12px;
  margin-bottom: 14px;
}
.dash-filter-card .filters-bar{
  flex-wrap: nowrap;
  gap: 10px;
}
.dash-filter-card .filters-actions{
  gap: 10px;
}
.dash-filter-card .filters-actions .form-select,
.dash-filter-card .filters-actions .btn-soft{
  min-height: 44px;
  margin: 0;
}

@media (max-width: 768px){
  .dash-filter-card .filters-bar{
    flex-wrap: wrap;
  }
  .dash-filter-card .filters-actions{
    width: 100%;
  }
  .dash-filter-card .filters-actions .form-select,
  .dash-filter-card .filters-actions .btn-soft{
    width: 100%;
  }
}

/* Relatórios: permitir nome completo (quebra linha) */
.table-app td.td-wrap{
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  word-break: break-word;
  line-height: 1.25;
}

/* garante que o texto não quebre */
.term-name{
  white-space: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  text-overflow: clip !important;
  -webkit-overflow-scrolling: touch;
}
.term-name::-webkit-scrollbar{ height: 0; }

/* importante: impedir o summary/head de “forçar quebra” */
details > summary.section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

details > summary.section-head .h{
  min-width:0;           /* permite encolher */
  flex:1 1 auto;         /* ocupa o espaço possível */
}

details > summary.section-head .h > div{
  min-width:0;
}

/* badge não pode encolher */
details > summary.section-head .right{
  flex:0 0 auto;
  white-space: nowrap;
}

@media (max-width:576px){
  .term-name{ font-size: .82rem; }
}

/* =========================================================
   ROTAS (Modal + FAB)
========================================================= */
.modal-soft{
  border:1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(15,23,42,.12), var(--shadow);
  overflow:hidden;
  background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
}

.rotas-toolbar{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
  padding: 16px 18px;
  border-bottom:1px solid var(--border);
  background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  flex-wrap:wrap;
}
.rotas-toolbar > *{
  min-width:0;
}
.rotas-toolbar .btn,
.rotas-toolbar .btn-soft,
.rotas-toolbar .form-control,
.rotas-toolbar .form-select{
  min-height:42px;
}

.rotas-wrap{
  background: linear-gradient(180deg, #fcfcfd 0%, #f6f7f9 100%);
  padding: 16px;
}

.rotas-cars{
  display:grid;
  gap: 16px;
}

/* um carro = um bloco com grid */
.rota-car{
  overflow:hidden;
  border:1px solid rgba(15,23,42,.08);
  border-radius: 20px;
  background:#fff;
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}
.rota-car-head{
  padding: 16px 18px 14px;
  border-bottom:1px solid var(--border);
  background:linear-gradient(180deg, #ffffff 0%, #fbfbfc 100%);
}
.rota-car-title{
  font-weight: 950;
  display:flex;
  align-items:center;
  gap:10px;
  font-size: 1rem;
  line-height: 1.2;
}
.rota-car-title i{
  color: var(--primary);
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  display:grid;
  place-items:center;
  border-radius: 12px;
  background: var(--primary-soft);
  flex: 0 0 auto;
}

/* grid seg-sex */
.rota-grid{
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 18px;
  align-items:start;
}

.rota-col{
  border:1px solid rgba(148,163,184,.18);
  border-radius: 16px;
  background:linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
  overflow:hidden;
  min-height: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}
.rota-col-head{
  padding: 12px 14px;
  font-weight: 950;
  color: #0f172a;
  border-bottom:1px solid var(--border);
  background:#f8fafc;
  text-align:center;
  letter-spacing:.3px;
  font-size:.82rem;
}

.rota-slot{
  padding: 12px;
  border-bottom:1px dashed #e8ecf3;
}
.rota-slot + .rota-slot{
  background: linear-gradient(180deg, rgba(248,250,252,.78) 0%, #ffffff 100%);
}
.rota-slot:last-child{ border-bottom:0; }

.rota-slot-title{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 6px 10px;
  border-radius: 999px;
  border:1px solid #e8ecf3;
  background:#f8fafc;
  font-size:.72rem;
  font-weight: 950;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing:.2px;
}

.rota-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.rota-item{
  position:relative;
  width:100%;
  text-align:left;
  border:1px solid #e8ecf3;
  background:#fff;
  border-radius: 14px;
  padding: 12px 12px 11px;
  box-shadow: 0 6px 16px rgba(15,23,42,.06);
  cursor:pointer;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t), background var(--t);
}
.rota-item:hover{
  background:#fff;
  border-color: rgba(255,122,0,.28);
  box-shadow: 0 10px 22px rgba(15,23,42,.10);
  transform: translateY(-1px);
}
.rota-item:focus-visible{
  outline:none;
  border-color: rgba(255,122,0,.42);
  box-shadow: 0 0 0 4px rgba(255,122,0,.14);
}
.rota-item.is-ok{
  border-color: rgba(22,163,74,.30);
  background: linear-gradient(180deg, rgba(22,163,74,.08) 0%, rgba(22,163,74,.03) 100%);
}
.rota-item.is-ok::before{
  content:"";
  position:absolute;
  left:0;
  top:10px;
  bottom:10px;
  width:4px;
  border-radius:999px;
  background: var(--success);
}
.rota-item.is-loading{
  opacity:.65;
  pointer-events:none;
  filter:saturate(.85);
}

.rota-name{
  display:block;
  font-weight: 900;
  line-height: 1.3;
  color:#0f172a;
}
.rota-meta{
  display:flex;
  flex-wrap:wrap;
  gap:4px 8px;
  align-items:center;
  margin-top:6px;
  font-size:.80rem;
  color:#334155;
  line-height:1.35;
}
.rota-meta.muted{ color: var(--muted); }

.rota-empty{
  padding: 14px 12px;
  border:1px dashed #d7dde7;
  border-radius: 14px;
  color: var(--muted);
  text-align:center;
  background: linear-gradient(180deg, #fafafa 0%, #f8fafc 100%);
  font-size:.88rem;
}

/* FAB só no mobile/tablet */
.fab-routes{
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(var(--bottombar-h) + max(14px, env(safe-area-inset-bottom)));
  z-index: 1600;
  display:none; /* ativa via media query */
  gap:10px;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,122,0,.26);
  background: rgba(255,255,255,.96);
  color: var(--text);
  box-shadow: 0 18px 36px rgba(16,24,40,.16);
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 900;
  backdrop-filter: blur(14px);
  transition: transform var(--t), box-shadow var(--t), background var(--t);
}
.fab-routes:hover{
  transform: translateY(-1px);
  box-shadow: 0 22px 38px rgba(16,24,40,.18);
}
.fab-routes:focus-visible{
  outline:none;
  box-shadow: 0 0 0 4px rgba(255,122,0,.16), 0 18px 36px rgba(16,24,40,.16);
}
.fab-routes i{ color: var(--primary); font-size: 1.25rem; }
.fab-routes span{
  font-size:.92rem;
  white-space:nowrap;
}

@media (max-width: 1199.98px){
  .rota-grid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px){
  .modal-soft{
    border-radius: 18px;
  }
  .rotas-toolbar{
    padding: 14px;
  }
  .rotas-toolbar > *{
    flex: 1 1 220px;
  }
  .rotas-wrap{
    padding: 14px;
  }
  .rota-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 14px;
  }
  .fab-routes{ display:inline-flex; }
}

@media (max-width: 767.98px){
  .modal-soft{
    border-radius: 16px;
  }
  .rotas-toolbar{
    flex-direction:column;
    align-items:stretch;
    gap:10px;
  }
  .rotas-toolbar .btn,
  .rotas-toolbar .btn-soft,
  .rotas-toolbar .form-control,
  .rotas-toolbar .form-select{
    width:100%;
  }
  .rotas-wrap{
    padding: 12px;
  }
  .rotas-cars{
    gap: 12px;
  }
  .rota-car{
    border-radius: 18px;
  }
  .rota-car-head{
    padding: 14px;
  }
  .rota-car-title{
    font-size:.98rem;
  }
  .rota-car-title i{
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 1.05rem;
  }
  .rota-grid{
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .rota-col{
    min-height: 0;
  }
  .rota-slot{
    padding: 10px;
  }
  .rota-item{
    padding: 11px 11px 10px;
  }
  .rota-name{
    font-size:.92rem;
  }
  .rota-meta{
    font-size:.78rem;
  }
  .fab-routes{
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottombar-h) + max(10px, env(safe-area-inset-bottom)));
    padding: 13px 16px;
  }
  .fab-routes span{
    font-size:.90rem;
  }
}

@media (max-width: 479.98px){
  .rota-slot-title{
    width:100%;
    justify-content:center;
  }
  .fab-routes{
    border-radius: 18px;
  }
}

tr.is-saving { opacity: .75; }
