:root{
  --navy-950:#06231a;
  --navy-900:#0a3324;
  --navy-800:#0f4630;
  --navy-700:#155c3c;
  --navy-600:#1c7449;
  --orange-500:#f2c230;
  --orange-600:#d9a913;
  --orange-100:#fdf3d0;
  --text-light:#eef7f1;
  --text-muted:#a9c4b3;
  --green:#00a54f;
  --red:#e5484d;
  --yellow:#fff100;
  --border:#1d4432;
  --radius:10px;
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:'Segoe UI',Roboto,Arial,sans-serif;
  background:#eef1f5;
  color:#1c2733;
}
a{color:inherit;text-decoration:none;}

/* ---------- Login ---------- */
.login-wrap{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(135deg,var(--navy-950),var(--navy-700));
}
.login-card{
  background:var(--navy-900);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:36px 40px;
  width:360px;
  color:var(--text-light);
  box-shadow:0 20px 50px rgba(0,0,0,.35);
}
.login-card h1{
  font-size:20px;
  margin:0 0 4px;
  color:#fff;
}
.login-card p.sub{
  color:var(--text-muted);
  margin:0 0 24px;
  font-size:13px;
}
.login-logo{
  display:flex; align-items:center; gap:10px; margin-bottom:18px;
}
.login-logo-img{max-width:100%;max-height:110px;object-fit:contain;}
.login-logo .badge{
  width:38px;height:38px;border-radius:8px;
  background:var(--orange-500);
  display:flex;align-items:center;justify-content:center;
  font-weight:700;color:var(--navy-950);font-size:16px;
}

/* ---------- Form elements ---------- */
label{display:block;font-size:13px;margin:14px 0 6px;color:var(--text-muted);}
.login-card label{color:var(--text-muted);}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],select,textarea{
  width:100%;
  padding:10px 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#0d1929;
  color:var(--text-light);
  font-size:14px;
}
.page input[type=text],.page input[type=email],.page input[type=password],.page input[type=number],.page input[type=date],.page select,.page textarea{
  background:#fff;
  color:#1c2733;
  border:1px solid #d5dce4;
}
button, .btn{
  cursor:pointer;
  border:none;
  border-radius:8px;
  padding:10px 18px;
  font-size:14px;
  font-weight:600;
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.btn-primary{background:var(--orange-500);color:var(--navy-950);}
.btn-primary:hover{background:var(--orange-600);}
.btn-secondary{background:#e3e8ef;color:#1c2733;}
.btn-danger{background:var(--red);color:#fff;}
.btn-block{width:100%;justify-content:center;margin-top:20px;}
.error-msg{
  background:rgba(229,72,77,.15);
  border:1px solid var(--red);
  color:#ffb3b5;
  padding:10px 12px;
  border-radius:8px;
  font-size:13px;
  margin-bottom:10px;
}
.success-msg{
  background:rgba(47,182,115,.12);
  border:1px solid var(--green);
  color:#1f7a4d;
  padding:10px 14px;
  border-radius:8px;
  font-size:13px;
  margin-bottom:16px;
}
.page .error-msg{color:#a3161a;}

/* ---------- App shell ---------- */
.app{display:flex;min-height:100vh;}
.sidebar{
  width:230px;
  background:var(--navy-950);
  color:var(--text-light);
  flex-shrink:0;
  padding:18px 14px;
}
.sidebar .brand{display:flex;align-items:center;gap:10px;padding:6px 8px 20px;}
.sidebar .brand .badge{
  width:34px;height:34px;border-radius:8px;background:var(--orange-500);
  display:flex;align-items:center;justify-content:center;font-weight:700;color:var(--navy-950);
}
.sidebar .brand span{font-weight:700;font-size:15px;color:#fff;}
.sidebar .brand-logo{max-width:100%;max-height:56px;object-fit:contain;}
.sidebar nav a{
  display:flex;
  align-items:center;
  min-height:34px;
  padding:7px 10px;
  border-radius:7px;
  font-size:13px;
  line-height:1.2;
  color:var(--text-muted);
  margin-bottom:1px;
  transition:background .15s ease,color .15s ease,transform .15s ease;
}
.sidebar nav a:hover{background:var(--navy-800);color:#fff;transform:translateX(2px);}
.sidebar nav a.active{background:var(--orange-500);color:var(--navy-950);font-weight:700;box-shadow:0 3px 10px rgba(0,0,0,.12);}
.sidebar nav a.small{
  padding-left:18px!important;
  font-size:12.5px;
  color:#b9cec1;
}
.sidebar .grupo{
  position:relative;
  font-size:10px;
  font-weight:700;
  text-transform:uppercase;
  color:#789584;
  margin:14px 8px 5px;
  padding-top:10px;
  letter-spacing:.09em;
  border-top:1px solid rgba(255,255,255,.09);
}
.sidebar .grupo.grupo-cadastros{border-top:0;margin-top:8px;padding-top:0;}
.sidebar .grupo.grupo-rh{color:#a8cdb5;}
.sidebar .grupo.grupo-operacao{color:#a8cdb5;}
.sidebar nav{padding-bottom:18px;}

.main{flex:1;display:flex;flex-direction:column;min-width:0;}
.topbar{
  height:60px;background:#fff;border-bottom:1px solid #dde3ea;
  display:flex;align-items:center;justify-content:space-between;padding:0 24px;
}
.topbar .user{display:flex;align-items:center;gap:12px;font-size:14px;}
.topbar .user .avatar{
  width:32px;height:32px;border-radius:50%;background:var(--navy-700);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;
}
.page{padding:24px;flex:1;}
.page h1{font-size:20px;margin:0 0 4px;color:var(--navy-950);}
.page .subtitle{color:#66758a;font-size:13px;margin-bottom:20px;}

/* ---------- Cards / tables ---------- */
.card{background:#fff;border-radius:var(--radius);border:1px solid #e2e7ee;padding:20px;margin-bottom:20px;}
.card h2{font-size:15px;margin:0 0 14px;color:var(--navy-900);}
.grid-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px;margin-bottom:20px;}
.stat-card{background:var(--navy-950);color:#fff;border-radius:var(--radius);padding:18px 20px;}
.stat-card .value{font-size:24px;font-weight:700;color:var(--orange-500);}
.stat-card .label{font-size:12px;color:var(--text-muted);margin-top:4px;}

table{width:100%;border-collapse:collapse;font-size:13.5px;}
table th{
  text-align:left;background:#f4f6f9;color:#51617a;padding:10px 12px;
  font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.03em;
  border-bottom:1px solid #e2e7ee;
}
table td{padding:10px 12px;border-bottom:1px solid #eef1f5;}
table tr:hover td{background:#fafbfd;}
.text-right{text-align:right;}
.text-center{text-align:center;}
.tag{display:inline-block;padding:3px 10px;border-radius:20px;font-size:11.5px;font-weight:600;}
.tag-green{background:#e3f8ee;color:#1f7a4d;}
.tag-red{background:#fde8e8;color:#a3161a;}
.tag-yellow{background:#fdf3d9;color:#8a6100;}
.tag-navy{background:#e3e9f2;color:var(--navy-800);}

.data-nowrap,.valor-nowrap,.badge-nowrap{white-space:nowrap!important;word-break:keep-all!important;overflow-wrap:normal!important;}
.valor-nowrap{text-align:right;}

.toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;gap:12px;flex-wrap:wrap;}
.toolbar .search{max-width:280px;}
.form-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;}
.form-actions{margin-top:20px;display:flex;gap:10px;}
.link-action{color:var(--orange-600);font-weight:600;font-size:13px;}
.link-action.danger{color:var(--red);}
hr.sep{border:none;border-top:1px solid #e2e7ee;margin:20px 0;}
.small{font-size:12px;color:#66758a;}

/* ---------- Melhorias Cooperativa ---------- */
.cards-resumo{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px;margin-bottom:20px;}
.cards-resumo .card{text-decoration:none;color:inherit;margin-bottom:0;transition:.15s ease;}
.cards-resumo .card:hover{transform:translateY(-1px);box-shadow:0 8px 18px rgba(12,33,54,.08);}
.card-alerta{border-color:#e5484d!important;background:#fff8f8;}
.card-atencao{border-color:#d9a913!important;background:#fffaf0;}
.filtros-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;align-items:end;}
.filtros-grid label{color:#51617a;margin-top:0;}
.filtros-acoes{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
.btn-light{background:#fff;color:#1c2733;border:1px solid #d5dce4;}
.table-responsive{overflow-x:auto;}
.table-responsive table{min-width:850px;}
@media(max-width:760px){
  .page{padding:16px;}
  .cards-resumo{grid-template-columns:1fr 1fr;}
  .filtros-grid{grid-template-columns:1fr;}
  .toolbar{align-items:stretch;}
  .toolbar .btn{justify-content:center;}
}

/* ---------- Equipamentos - layout gerencial limpo ---------- */
.page-head.clean-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px;}
.head-actions{display:flex;gap:12px;flex-wrap:wrap;align-items:center;}
.btn-success{background:#0f7a3d;color:#fff;box-shadow:0 4px 10px rgba(15,122,61,.14);}
.btn-success:hover{background:#0b6331;}
.btn-outline{border:1px solid #cfd8e3;background:#fff;color:#1c2733;}
.filtros-equipamentos{display:grid;grid-template-columns:1.6fr 1fr 1.25fr .9fr auto;gap:14px;align-items:end;margin-bottom:20px;}
.filtros-equipamentos label{color:#51617a;margin-top:0;}
.equipamentos-stats{grid-template-columns:repeat(4,minmax(160px,1fr));}
.stat-white{display:flex;align-items:center;gap:16px;margin-bottom:0;color:inherit;}
.stat-icon{width:54px;height:54px;border-radius:16px;background:#e4f7ec;color:#0f7a3d;display:flex;align-items:center;justify-content:center;font-size:25px;flex:0 0 auto;}
.stat-icon.warn{background:#fff3d9;color:#a46400;}
.stat-icon.muted{background:#f1f3f6;color:#66758a;}
.stat-number{font-size:26px;font-weight:800;line-height:1.15;color:#162335;}
.equipment-list-card{padding:0;overflow:hidden;}
.equipment-list-card .card-title-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 20px;border-bottom:1px solid #eef1f5;}
.equipment-list-card h3{margin:0;font-size:16px;color:#162335;}
.acoes-nowrap{white-space:nowrap;}
@media(max-width:1100px){.filtros-equipamentos{grid-template-columns:1fr 1fr;}.equipamentos-stats{grid-template-columns:repeat(2,1fr);}}
@media(max-width:760px){.page-head.clean-head{flex-direction:column;}.head-actions{width:100%;}.head-actions .btn{flex:1;justify-content:center;}.filtros-equipamentos{grid-template-columns:1fr;}.equipamentos-stats{grid-template-columns:1fr;}}


/* ---------- Ajustes desktop para listagens largas ---------- */
@media(min-width:901px){
  .table-responsive{
    width:100%;
    max-width:100%;
    overflow-x:auto;
    display:block;
  }
  .table-responsive table{
    width:100%;
  }
  .rh-list-card{
    padding:0;
  }
  .rh-list-card table{
    min-width:1100px;
    width:100%;
    table-layout:fixed;
    font-size:12px;
  }
  .rh-list-card th,
  .rh-list-card td{
    padding:8px 8px;
    vertical-align:middle;
    word-break:break-word;
  }
  .rh-list-card th:nth-child(1), .rh-list-card td:nth-child(1){width:68px;}
  .rh-list-card th:nth-child(2), .rh-list-card td:nth-child(2){width:128px;}
  .rh-list-card th:nth-child(3), .rh-list-card td:nth-child(3){width:112px;}
  .rh-list-card th:nth-child(4), .rh-list-card td:nth-child(4){width:138px;}
  .rh-list-card th:nth-child(5), .rh-list-card td:nth-child(5){width:106px;}
  .rh-list-card th:nth-child(6), .rh-list-card td:nth-child(6){width:106px;}
  .rh-list-card th:nth-child(7), .rh-list-card td:nth-child(7){width:112px;}
  .rh-list-card th:nth-child(8), .rh-list-card td:nth-child(8){width:106px;}
  .rh-list-card th:nth-child(9), .rh-list-card td:nth-child(9){width:78px;}
  .rh-list-card th:last-child,
  .rh-list-card td:last-child{
    width:122px;
    min-width:122px;
  }

  /* Datas e badges: nunca quebrar no meio (CNH, ASO, toxicológico, contrato etc.) */
  .rh-list-card th:nth-child(5), .rh-list-card td:nth-child(5),
  .rh-list-card th:nth-child(6), .rh-list-card td:nth-child(6),
  .rh-list-card th:nth-child(7), .rh-list-card td:nth-child(7),
  .rh-list-card th:nth-child(8), .rh-list-card td:nth-child(8){
    text-align:center;
    white-space:nowrap;
    word-break:keep-all;
    overflow-wrap:normal;
  }
  .rh-list-card td:nth-child(5) span,
  .rh-list-card td:nth-child(6) span,
  .rh-list-card td:nth-child(7) span,
  .rh-list-card td:nth-child(8) span{
    white-space:nowrap;
    word-break:keep-all;
    overflow-wrap:normal;
  }
  .rh-list-card td:nth-child(5) .tag,
  .rh-list-card td:nth-child(6) .tag,
  .rh-list-card td:nth-child(7) .tag,
  .rh-list-card td:nth-child(8) .tag{
    min-width:92px;
    text-align:center;
    display:inline-flex;
    justify-content:center;
  }

  .rh-actions{
    display:flex;
    align-items:stretch;
    gap:5px;
    flex-direction:column;
    width:100%;
  }
  .rh-actions .btn, .rh-actions a.btn{
    width:100%;
    justify-content:center;
    text-align:center;
    white-space:nowrap;
  }
  .btn-mini{
    min-height:auto;
    padding:6px 7px;
    border-radius:7px;
    font-size:11.5px;
    line-height:1.1;
  }
}

/* ---------- Responsivo global mobile ---------- */
.menu-toggle{display:none;background:#fff;border:1px solid #d5dce4;color:#122033;border-radius:10px;padding:9px 12px;font-size:20px;line-height:1;box-shadow:none;}
.mobile-backdrop{display:none;}

@media(max-width:900px){
  body{background:#eef1f5;}
  .app{display:block;min-height:100vh;}
  .sidebar{
    position:fixed;left:0;top:0;bottom:0;z-index:1001;
    width:82vw;max-width:320px;min-width:260px;
    transform:translateX(-105%);transition:transform .22s ease;
    overflow-y:auto;padding:18px 14px 28px;
    box-shadow:18px 0 40px rgba(0,0,0,.22);
  }
  body.menu-open .sidebar{transform:translateX(0);}
  body.menu-open .mobile-backdrop{display:block;position:fixed;inset:0;background:rgba(6,35,26,.46);z-index:1000;}
  .sidebar .brand{position:sticky;top:0;background:var(--navy-950);z-index:2;padding-top:6px;}
  .sidebar .brand-logo{max-height:62px;}
  .sidebar nav a{font-size:15px;padding:13px 14px;margin-bottom:4px;border-radius:12px;}
  .sidebar .grupo{font-size:11px;margin-top:18px;}

  .main{min-height:100vh;width:100%;}
  .topbar{height:58px;padding:0 12px;position:sticky;top:0;z-index:500;box-shadow:0 2px 10px rgba(12,33,54,.05);}
  .menu-toggle{display:inline-flex;align-items:center;justify-content:center;}
  .topbar .user{gap:8px;font-size:12px;min-width:0;}
  .topbar .user > span{display:none;}
  .topbar .user .avatar{width:34px;height:34px;}
  .topbar .link-action{font-size:12px;}
  .page{padding:14px;}
  .page h1{font-size:21px;line-height:1.25;}
  .page .subtitle{font-size:13px;margin-bottom:14px;}
  .card{padding:14px;border-radius:14px;margin-bottom:14px;}
  .toolbar{display:grid;grid-template-columns:1fr;gap:10px;align-items:stretch;}
  .toolbar .search{max-width:none;width:100%;}
  .toolbar .btn,.toolbar a.btn{width:100%;justify-content:center;}
  .form-row{grid-template-columns:1fr;gap:10px;}
  .form-actions{position:sticky;bottom:0;background:rgba(238,241,245,.96);padding:10px 0;margin-top:12px;z-index:50;display:grid;grid-template-columns:1fr;}
  .form-actions .btn,.form-actions button{width:100%;justify-content:center;}
  input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],select,textarea{min-height:44px;font-size:16px;}
  button,.btn{min-height:44px;justify-content:center;}
  .cards-resumo,.grid-cards,.equipamentos-stats{grid-template-columns:1fr!important;gap:10px;}
  .stat-card,.stat-white{border-radius:14px;}
  .stat-number,.stat-card .value{font-size:24px;}
  .filtros-grid,.filtros-equipamentos{grid-template-columns:1fr!important;gap:10px;}
  .filtros-acoes{display:grid;grid-template-columns:1fr 1fr;width:100%;}
  .filtros-acoes .btn{width:100%;}
  .page-head.clean-head{gap:12px;margin-bottom:14px;}
  .head-actions{display:grid;grid-template-columns:1fr;width:100%;gap:8px;}
  .head-actions .btn{width:100%;}

  /* Listas viram cards no celular */
  .table-responsive{overflow:visible;}
  .table-responsive table{min-width:0;}
  table{border-collapse:separate;border-spacing:0;width:100%;}
  table tbody, table tr, table td{display:block;width:100%;}
  table thead, table th{display:none!important;}
  table tr:first-child:has(th){display:none!important;}
  table tr{background:#fff;border:1px solid #e0e6ee;border-radius:14px;margin:0 0 12px;padding:10px 12px;box-shadow:0 4px 12px rgba(12,33,54,.04);}
  table td{border-bottom:1px solid #eef1f5;padding:9px 0;display:flex;gap:12px;justify-content:space-between;align-items:flex-start;text-align:right!important;}
  table td:last-child{border-bottom:0;}
  table td::before{content:attr(data-label);font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:#66758a;font-weight:700;min-width:38%;text-align:left;}
  table td[colspan]::before{content:'';display:none;}
  table td[colspan]{text-align:center!important;justify-content:center;color:#66758a;}
  table tr:hover td{background:transparent;}
  .acoes-nowrap{white-space:normal;}
  .link-action{display:inline-flex;align-items:center;justify-content:center;padding:6px 2px;}

  /* Telas de rateio e serviços */
  .rateio-resumo,.service-summary,.resumo-rateio{grid-template-columns:1fr!important;}
  .rateio-actions,.acao-rateio{display:grid!important;grid-template-columns:1fr!important;gap:8px;}
  .rateio-actions .btn,.acao-rateio .btn{width:100%;}
}

@media(max-width:420px){
  .page{padding:10px;}
  .card{padding:12px;}
  .login-card{width:calc(100vw - 28px);padding:28px 22px;}
  table td{display:block;text-align:left!important;}
  table td::before{display:block;margin-bottom:4px;min-width:0;}
}

@media print{
  .menu-toggle,.mobile-backdrop,.sidebar,.topbar{display:none!important;}
  .app,.main,.page{display:block!important;padding:0!important;margin:0!important;}
  .card{box-shadow:none;}
}
