/* ═══════════════════════════════════════════════════════
   Datalog Portal — Design System Claro
   Cores: Amarelo #F5C200, Cinza, Branco, Preto
   ═══════════════════════════════════════════════════════ */

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

:root {
  --y:      #F5C200;
  --yd:     #C9980A;
  --ylt:    #FFFBE8;
  --yborder:#FDE68A;
  --dark:   #1A2035;
  --dark2:  #243044;
  --text:   #111827;
  --text2:  #374151;
  --muted:  #6B7280;
  --muted2: #9CA3AF;
  --border: #E5E7EB;
  --border2:#D1D5DB;
  --bg:     #F3F4F6;
  --white:  #FFFFFF;
  --panel:  #F9FAFB;
  --green:  #059669;
  --greenlt:#ECFDF5;
  --greenborder:#A7F3D0;
  --amber:  #D97706;
  --amberlt:#FFFBEB;
  --amberborder:#FCD34D;
  --red:    #DC2626;
  --redlt:  #FEF2F2;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 240px;
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }
.mono { font-family: 'Space Mono', monospace; font-size: .88rem; font-weight: 700; color: var(--dark); }

/* ═══════════════════════════════════════
   Layout: DESKTOP (≥ 901px) — side-by-side
   ═══════════════════════════════════════ */
@media (min-width: 901px) {
  body.has-sidebar   { display: flex; height: 100vh; overflow: hidden; }
  .sidebar           { height: 100vh; overflow-y: auto; flex-shrink: 0; }
  .main-wrapper      { flex: 1; display: flex; flex-direction: column; overflow: hidden; height: 100vh; }
  .main-content      { flex: 1; overflow-y: auto; }

  /* Elementos exclusivos do mobile — invisíveis no desktop */
  .hamburger         { display: none !important; }
  .mobile-search-bar { display: none !important; }
  .mobile-topbar     { display: none !important; }
  #mbDrop            { display: none !important; }
  .desktop-only      { display: flex; }
}

/* ═══════════════════════════════════════
   Layout: MOBILE / TABLET (≤ 900px)
   Sidebar vira topbar escura no topo
   ═══════════════════════════════════════ */
@media (max-width: 900px) {

  /* Body: bloco normal, scroll livre */
  body.has-sidebar { display: block; min-height: 100vh; }

  /* ── Sidebar: vira topbar ── */
  .sidebar {
    width: 100%  !important;
    height: auto !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 200 !important;
    flex-direction: column !important;  /* empilha os filhos */
    padding: 0 !important;
    border-right: none !important;
    overflow: visible !important;
  }

  /* Linha 1: logo + nome app + hamburguer */
  .sidebar-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: .7rem 1rem !important;
    border-bottom: 1px solid rgba(255,255,255,.08) !important;
    width: 100%;
  }
  .sb-logo-row { flex: 1; }

  /* Linha 2: avatar + nome + cod do cliente — visível no mobile */
  .sidebar-user {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: .55rem 1rem !important;
    border-bottom: 1px solid rgba(255,255,255,.1) !important;
    background: rgba(255,255,255,.04);
    width: 100%;
    gap: .65rem;
  }

  /* Nav e footer da sidebar ficam no dropdown, não na topbar */
  .sidebar-nav    { display: none !important; }
  .sidebar-footer { display: none !important; }

  /* Hamburguer visível no mobile */
  .hamburger { display: flex !important; }

  /* Main wrapper: sem margem lateral */
  .main-wrapper { margin-left: 0 !important; }

  /* Topbar desktop some */
  .topbar       { display: none !important; }
  .desktop-only { display: none !important; }

  /* Conteúdo com padding menor */
  .main-content { padding: 1rem !important; }

  /* ── Tabela responsiva ── */
  .col-hide { display: none !important; }

  /* ── Busca mobile ── */
  .mobile-search-bar { display: flex !important; }

  /* ── Stats: 2 colunas ── */
  .stats-bar { grid-template-columns: 1fr 1fr !important; }
  .stat-card:last-child { display: none !important; }

  /* ── Card header empilha ── */
  .card-header  { flex-direction: column !important; align-items: flex-start !important; gap: .65rem !important; }
  .filter-tabs  { width: 100%; }
  .filter-tabs .ftab { flex: 1; text-align: center; }

  /* ── Grids ── */
  .detail-grid   { grid-template-columns: 1fr !important; }
  .footer-grid-2 { grid-template-columns: 1fr !important; }

  /* ── Login: esconde lado decorativo ── */
  .login-side      { display: none !important; }
  .login-form-side { padding: 1.5rem; }
}

/* ── Mobile pequeno (≤ 480px) ── */
@media (max-width: 480px) {
  .pag-info    { min-width: 100%; margin-bottom: .35rem; }
  .stats-bar   { gap: .65rem; }
  .stat-card   { padding: .75rem 1rem; }
  .stat-val    { font-size: 1.2rem; }
  .sb-uname    { font-size: .72rem !important; }
}

/* ═══ Sidebar ═══ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar-header {
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sb-logo-row {
  display: flex; align-items: center; gap: .65rem;
}

.logo-box {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--y); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
}

.lg-name { font-size: .95rem; font-weight: 700; color: #fff; line-height: 1; }
.lg-sub  { font-size: .58rem; color: rgba(255,255,255,.38); letter-spacing: .12em; text-transform: uppercase; margin-top: 1px; }

.sidebar-user {
  padding: .9rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: .6rem;
}

.sb-avatar {
  width: 35px; height: 35px; border-radius: 8px;
  background: var(--y); color: var(--dark);
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.sb-uname {
  font-size: .78rem; font-weight: 600; color: #fff; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-ucod  {
  font-family: 'Space Mono', monospace; font-size: .62rem;
  color: rgba(255,255,255,.45); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-nav   { flex: 1; padding: .5rem 0; }
.sidebar-footer{ padding: .8rem 1.1rem; border-top: 1px solid rgba(255,255,255,.07); margin-top: auto; }

.nav-label {
  font-size: .58rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.28); padding: .6rem 1.1rem .2rem;
}

.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1.1rem;
  font-size: .82rem; font-weight: 500;
  color: rgba(255,255,255,.55);
  border-left: 2px solid transparent;
  transition: all .12s; text-decoration: none;
}
.nav-link:hover  { color: #fff; background: rgba(255,255,255,.05); }
.nav-link.active { color: var(--y); background: rgba(245,194,0,.08); border-left-color: var(--y); }
.nav-logout:hover { color: #FCA5A5; background: rgba(239,68,68,.08); }

/* Hamburguer — oculto por padrão, aparece no mobile via @media */
.hamburger {
  background: rgba(255,255,255,.1); border: none; border-radius: 6px;
  color: #fff; padding: .42rem .55rem; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  margin-left: .75rem; flex-shrink: 0; transition: opacity .15s;
}

/* ═══ Topbar (desktop) ═══ */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 1.75rem; height: 58px; flex-shrink: 0;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: .92rem; font-weight: 600; flex: 1; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

/* ═══ Content / Footer ═══ */
.main-content { padding: 1.5rem 1.75rem; }
.main-foot    { padding: .7rem 1.75rem; border-top: 1px solid var(--border); background: var(--white); font-size: .72rem; color: var(--muted); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }

/* ═══ Stats ═══ */
.stats-bar { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; display: flex; align-items: center; gap: .85rem; box-shadow: var(--shadow); }
.stat-icon { width: 42px; height: 42px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-icon.total   { background: var(--ylt);    color: var(--yd); }
.stat-icon.ok      { background: var(--greenlt); color: var(--green); }
.stat-icon.transit { background: var(--amberlt); color: var(--amber); }
.stat-val   { font-family: 'Space Mono', monospace; font-size: 1.45rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* ═══ Card ═══ */
.card         { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-header  { display: flex; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.card-title   { font-size: .88rem; font-weight: 600; flex: 1; color: var(--text); }
.card-body    { padding: 1.25rem; }

/* ═══ Busca ═══ */
.search-bar    { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.search-select { background: var(--panel); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text2); font-family: inherit; font-size: .8rem; padding: .42rem .7rem; outline: none; cursor: pointer; }
.search-input  { background: var(--panel); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: .82rem; padding: .42rem .9rem; outline: none; transition: border-color .15s, box-shadow .15s; }
.search-input:focus { border-color: var(--y); box-shadow: 0 0 0 3px rgba(245,194,0,.12); }
.search-input::placeholder { color: var(--muted2); }

/* Busca mobile */
.mobile-search-bar { display: none; flex-wrap: wrap; gap: .4rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--panel); }

/* ═══ Filtros ═══ */
.filter-tabs { display: flex; gap: .35rem; }
.ftab { background: transparent; border: 1.5px solid var(--border2); border-radius: 6px; color: var(--muted); font-family: inherit; font-size: .75rem; font-weight: 500; padding: .28rem .7rem; cursor: pointer; transition: all .12s; }
.ftab:hover { border-color: var(--yd); color: var(--yd); }
.ftab.on    { background: var(--y); color: var(--dark); border-color: var(--y); font-weight: 700; }

/* ═══ Botões ═══ */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .52rem 1rem; border-radius: var(--radius-sm); font-family: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; border: none; transition: all .12s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--y); color: var(--dark); }
.btn-primary:hover { background: var(--yd); }
.btn-outline { background: transparent; border: 1.5px solid var(--border2); color: var(--text2); }
.btn-outline:hover { border-color: var(--dark); color: var(--dark); }
.btn-dark    { background: var(--dark); color: #fff; }
.btn-dark:hover { background: var(--dark2); }
.btn-sm      { padding: .34rem .8rem; font-size: .78rem; }

.btn-det { display: inline-flex; align-items: center; gap: .35rem; background: var(--dark); color: #fff; border: none; border-radius: 6px; font-family: inherit; font-size: .76rem; font-weight: 600; padding: .34rem .8rem; cursor: pointer; transition: all .12s; text-decoration: none; white-space: nowrap; }
.btn-det:hover { background: var(--dark2); }

/* ═══ Tabela ═══ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table       { width: 100%; border-collapse: collapse; font-size: .83rem; }
thead th    { background: var(--panel); padding: .7rem 1rem; text-align: left; font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; border-bottom: 2px solid var(--border); }
tbody tr    { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--ylt); }
tbody td    { padding: .82rem 1rem; vertical-align: middle; color: var(--text2); }
tfoot td    { padding: .75rem 1rem; background: var(--panel); border-top: 2px solid var(--border); font-size: .83rem; }

/* ═══ Badges ═══ */
.badge        { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem; border-radius: 20px; font-size: .69rem; font-weight: 600; white-space: nowrap; }
.b-green      { background: var(--greenlt); color: var(--green); border: 1px solid var(--greenborder); }
.b-amber      { background: var(--amberlt); color: var(--amber); border: 1px solid var(--amberborder); }
.b-gray       { background: var(--panel);   color: var(--muted2); border: 1px solid var(--border2); }
.badge-yellow { background: var(--ylt);     color: var(--yd); border: 1px solid var(--yborder); }

/* ═══ Paginação ═══ */
.pag       { display: flex; align-items: center; gap: .35rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pag-info  { font-size: .75rem; color: var(--muted); flex: 1; }
.pag-btn   { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 600; border: 1.5px solid var(--border2); background: var(--white); color: var(--text2); cursor: pointer; transition: all .12s; font-family: 'Space Mono', monospace; text-decoration: none; }
.pag-btn:hover { border-color: var(--yd); color: var(--yd); }
.pag-btn.on    { background: var(--y); color: var(--dark); border-color: var(--y); font-weight: 700; }
.pag-btn.dis   { opacity: .35; pointer-events: none; }

/* ═══ Alertas ═══ */
.alert       { display: flex; align-items: flex-start; gap: .6rem; padding: .9rem 1.1rem; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: 1.25rem; }
.alert-error { background: var(--redlt); border: 1px solid #FECACA; color: var(--red); }
.alert-warn  { background: var(--amberlt); border: 1px solid var(--amberborder); color: #92400e; }

/* ═══ Detail grid ═══ */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; }
.di-item     { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; }
.di-label    { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .3rem; }
.di-val      { font-size: .9rem; font-weight: 500; color: var(--text); }

/* ═══ Timeline ═══ */
.timeline    { display: flex; align-items: flex-start; }
.tl-step     { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; }
.tl-step:not(:last-child)::after { content: ''; position: absolute; top: 17px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.tl-step.done:not(:last-child)::after { background: var(--y); }
.tl-step.curr:not(:last-child)::after { background: linear-gradient(90deg, var(--y), var(--border)); }
.tl-icon     { width: 36px; height: 36px; border-radius: 50%; background: var(--panel); border: 2px solid var(--border2); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: .85rem; z-index: 1; position: relative; margin-bottom: .55rem; }
.tl-step.done .tl-icon { background: var(--y); border-color: var(--y); color: var(--dark); }
.tl-step.curr .tl-icon { background: var(--amberlt); border-color: var(--amber); color: var(--amber); }
.tl-label    { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tl-date     { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.tl-step.done .tl-label { color: var(--text); }
.tl-step.done .tl-date  { color: var(--text2); }
.tl-step.curr .tl-label, .tl-step.curr .tl-date { color: var(--amber); }




/* ═══ Login ═══ */
.login-wrap      { min-height: 100vh; display: flex; align-items: stretch; }
.login-side      { width: 400px; flex-shrink: 0; background: var(--dark); display: flex; flex-direction: column; justify-content: space-between; padding: 2.5rem; position: relative; overflow: hidden; }
.login-side::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(245,194,0,.05) 1px,transparent 1px), linear-gradient(90deg,rgba(245,194,0,.05) 1px,transparent 1px); background-size: 40px 40px; pointer-events: none; }
.login-side::after  { content: ''; position: absolute; bottom: -80px; left: -60px; width: 360px; height: 360px; background: radial-gradient(circle, rgba(245,194,0,.18) 0%, transparent 70%); pointer-events: none; }
.ls-logo         { position: relative; z-index: 1; display: flex; align-items: center; gap: .75rem; }
.ls-body         { position: relative; z-index: 1; }
.ls-body h1      { font-size: clamp(1.8rem,3vw,2.6rem); font-weight: 700; line-height: 1.15; color: #fff; letter-spacing: -.02em; }
.ls-body h1 em   { color: var(--y); font-style: normal; }
.ls-body p       { font-size: .9rem; color: rgba(255,255,255,.5); margin-top: .9rem; line-height: 1.7; }
.ls-feats        { position: relative; z-index: 1; display: flex; flex-direction: column; gap: .5rem; }
.ls-feat         { display: flex; align-items: center; gap: .55rem; font-size: .82rem; color: rgba(255,255,255,.45); }
.ls-feat-dot     { width: 5px; height: 5px; border-radius: 50%; background: var(--y); flex-shrink: 0; }
.ls-foot         { position: relative; z-index: 1; font-size: .7rem; color: rgba(255,255,255,.28); }
.login-form-side { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--white); padding: 2.5rem; }
.login-box       { width: 100%; max-width: 400px; }
.login-form-icon {  display: flex; justify-content: center; align-items: center; width: 100%; height: auto;}
.login-title     { font-size: 1.65rem; font-weight: 700; color: var(--text); margin-bottom: .3rem; }
.login-sub       { font-size: .88rem; color: var(--muted); margin-bottom: 2rem; line-height: 1.6; }
.field           { margin-bottom: 1.1rem; }
.field label     { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .45rem; }
.field input     { width: 100%; background: var(--panel); border: 1.5px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: .95rem; padding: .72rem 1rem; outline: none; transition: border-color .2s, box-shadow .2s; }
.field input:focus { border-color: var(--y); background: var(--white); box-shadow: 0 0 0 3px rgba(245,194,0,.15); }
.field input::placeholder { color: var(--muted2); }
.field-hint      { font-size: .74rem; color: var(--muted); margin-top: .4rem; display: flex; align-items: center; gap: .35rem; }
.btn-login       { width: 100%; background: var(--y); color: var(--dark); border: none; border-radius: var(--radius-sm); font-family: inherit; font-size: 1rem; font-weight: 700; padding: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .75rem; transition: background .15s, box-shadow .15s; }
.btn-login:hover { background: var(--yd); box-shadow: 0 4px 16px rgba(245,194,0,.35); }
.login-divider   { margin: 1.75rem 0; display: flex; align-items: center; gap: .75rem; }
.div-line        { flex: 1; height: 1px; background: var(--border); }
.div-txt         { font-size: .72rem; color: var(--muted2); white-space: nowrap; }
.login-contact   { font-size: .78rem; color: var(--muted); line-height: 1.9; text-align: center; }
.login-contact a { color: var(--yd); font-weight: 500; }



/* ═══ Empty / Misc ═══ */
.empty-state   { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .6rem; opacity: .3; }
.breadcrumb    { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a  { color: var(--yd); }
.no-print      {}

/* ═══ Impressão ═══ */
@media print {
  .sidebar, .topbar, .main-foot, .no-print { display: none !important; }
  body.has-sidebar .main-wrapper { margin: 0 !important; }
  .main-content { padding: 1rem !important; overflow: visible !important; }
  body { background: white; }
  .card { box-shadow: none; }
}
