/* ============================================================
   Portal MIG Logistica - Stelle & Lauton
   Layout: topbar branca + sidebar escura + main claro
   Acento: vermelho #E30613
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; background: #F5F5F5; color: #201E1E; line-height: 1.5; }
a { color: #c20510; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- SHELL ---------- */
.app-shell { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; grid-template-areas: "topbar topbar" "sidebar main"; min-height: 100vh; }
.app-topbar { grid-area: topbar; }
.app-sidebar { grid-area: sidebar; }
.app-main { grid-area: main; padding: 24px 32px 40px; background: #F5F5F5; min-width: 0; }

/* ---------- TOPBAR ---------- */
.app-topbar { background: #FFFFFF; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid #E30613; }
.topbar-left { display: flex; align-items: center; gap: 14px; }
.brand-badge { background: #E30613; color: #FFFFFF; padding: 6px 14px; border-radius: 4px; font-weight: 600; font-size: 14px; letter-spacing: .3px; }
.breadcrumb { color: #5f5e5a; font-size: 12px; padding-left: 14px; border-left: 1px solid #E5E5E5; }
.breadcrumb .muted { color: #888780; }

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.user-card { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid #E5E5E5; }
.user-card .avatar { width: 34px; height: 34px; border-radius: 50%; background: #201E1E; color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.user-card .user-name { color: #201E1E; font-size: 13px; font-weight: 600; }
.user-card .user-role { color: #888780; font-size: 11px; }

/* ---------- SIDEBAR ---------- */
.app-sidebar { background: #201E1E; padding: 20px 0; display: flex; flex-direction: column; }
.sidebar-section { padding: 0 20px 8px; font-size: 10px; color: #6a6660; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600; }
.sidebar-item { display: flex; align-items: center; gap: 11px; padding: 10px 20px; color: #C7C0B0; font-size: 13px; border-left: 3px solid transparent; transition: all .15s; text-decoration: none; }
.sidebar-item:hover { color: #FFFFFF; background: rgba(255,255,255,.04); text-decoration: none; }
.sidebar-item.ativo { color: #FFFFFF; background: #E30613; border-left-color: #FFFFFF; font-weight: 600; }
.sidebar-item.subitem { font-size: 12px; padding-left: 40px; color: #888780; }
.sidebar-item.subitem:hover { color: #FFFFFF; }
.sidebar-item.small { font-size: 12px; color: #888780; }
.sidebar-item i { font-size: 16px; }

.sidebar-bottom { margin-top: auto; padding: 16px 20px; border-top: 1px solid #2c2828; }
.sidebar-bottom .sidebar-item { padding: 0 0 12px 0; border-left: none; }
.sidebar-escritorio { text-align: center; padding-top: 8px; border-top: 1px solid #2c2828; margin-top: 4px; }
.sidebar-mini { font-size: 10px; color: #6a6660; letter-spacing: .5px; line-height: 1.3; margin-top: 4px; }

/* ---------- TITULOS / CARDS ---------- */
.app-main h1 { font-size: 22px; font-weight: 600; color: #201E1E; margin: 0 0 16px; letter-spacing: -0.3px; }
.app-main h2 { font-size: 15px; font-weight: 600; color: #201E1E; margin: 22px 0 12px; }
.card { background: #FFFFFF; border-radius: 8px; padding: 18px 20px; margin-bottom: 14px; border: 0.5px solid #E5E5E5; }

/* ---------- SAUDACAO ---------- */
.saudacao { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.saudacao .data { font-size: 11px; color: #888780; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 4px; }
.saudacao .ola { font-size: 22px; font-weight: 500; color: #201E1E; letter-spacing: -.3px; }
.saudacao .sub { font-size: 13px; color: #5f5e5a; margin-top: 4px; }
.saudacao .sub strong { color: #E30613; font-weight: 600; }

/* ---------- KPI CARDS ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { background: #FFFFFF; border-radius: 8px; padding: 14px 16px; border: 0.5px solid #E5E5E5; }
.kpi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kpi-titulo { font-size: 10px; color: #888780; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.kpi-icon { font-size: 16px; color: #E30613; }
.kpi-valor { font-size: 26px; font-weight: 600; color: #201E1E; line-height: 1; }
.kpi-sub { font-size: 11px; color: #888780; margin-top: 4px; }
.kpi-sub.alerta { color: #A32D2D; }
.kpi-sub.ok { color: #3B6D11; }

/* ---------- KANBAN ---------- */
.kanban-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; flex-wrap: wrap; gap: 10px; }
.kanban-titulo { font-size: 15px; font-weight: 600; color: #201E1E; }
.kanban-dica { font-size: 11px; color: #888780; margin-left: 8px; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kanban-col { background: #EDEDED; border-radius: 8px; padding: 12px 10px; border-top: 3px solid #888780; min-height: 80px; }
.kanban-col.col-abertas { border-top-color: #888780; }
.kanban-col.col-andamento { border-top-color: #185FA5; }
.kanban-col.col-aguardando { border-top-color: #EF9F27; }
.kanban-col.col-concluidas { border-top-color: #3B6D11; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 4px; }
.kanban-col-titulo { font-size: 11px; font-weight: 700; color: #444; text-transform: uppercase; letter-spacing: .6px; }
.col-andamento .kanban-col-titulo { color: #185FA5; }
.col-aguardando .kanban-col-titulo { color: #854F0B; }
.col-concluidas .kanban-col-titulo { color: #3B6D11; }
.kanban-col-count { font-size: 10px; color: #888780; background: #FFFFFF; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.col-andamento .kanban-col-count { color: #185FA5; }
.col-aguardando .kanban-col-count { color: #854F0B; }
.col-concluidas .kanban-col-count { color: #3B6D11; }

.kanban-card { background: #FFFFFF; border-radius: 6px; padding: 10px 11px; margin-bottom: 6px; border-left: 3px solid #888780; display: block; color: inherit; transition: box-shadow .12s, transform .12s; }
.kanban-card:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); transform: translateY(-1px); color: inherit; }
.col-andamento .kanban-card { border-left-color: #185FA5; }
.col-aguardando .kanban-card { border-left-color: #EF9F27; }
.col-aguardando .kanban-card.urgente { border-left-color: #E30613; }
.col-concluidas .kanban-card { border-left-color: #3B6D11; opacity: .92; }
.kanban-card-id { font-size: 11px; color: #888780; margin-bottom: 3px; }
.kanban-card-titulo { font-size: 12.5px; color: #201E1E; font-weight: 600; line-height: 1.3; margin-bottom: 6px; }
.kanban-card-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }
.kanban-card-info { font-size: 10px; color: #888780; display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.kanban-card-info.urgente { color: #E30613; font-weight: 600; }
.kanban-card-info i { font-size: 11px; }
.kanban-empty { font-size: 11px; color: #888780; padding: 8px 4px; text-align: center; font-style: italic; }

/* ---------- BADGES (chips) ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 11px; font-size: 11px; font-weight: 600; }
.badge-aberta { background: #FCEBEB; color: #A32D2D; }
.badge-em_analise { background: #FAEEDA; color: #854F0B; }
.badge-em_andamento { background: #E6F1FB; color: #185FA5; }
.badge-aguardando_cliente { background: #FAEEDA; color: #854F0B; }
.badge-concluida { background: #E3EFD9; color: #3B6D11; }
.badge-cancelada { background: #EDEDED; color: #5f5e5a; }

/* Processos */
.badge.proc-ativo      { background: #E3EFD9; color: #3B6D11; }
.badge.proc-suspenso   { background: #FAEEDA; color: #854F0B; }
.badge.proc-arquivado  { background: #EDEDED; color: #5f5e5a; }
.badge.proc-encerrado  { background: #D1D3D8; color: #383d41; }

/* Financeiro */
.badge.fin-pendente   { background: #FAEEDA; color: #854F0B; }
.badge.fin-pago       { background: #E3EFD9; color: #3B6D11; }
.badge.fin-atrasado   { background: #FCEBEB; color: #A32D2D; }
.badge.fin-cancelado  { background: #EDEDED; color: #5f5e5a; }

/* Agenda */
.badge.ag-agendado    { background: #E6F1FB; color: #185FA5; }
.badge.ag-realizado   { background: #E3EFD9; color: #3B6D11; }
.badge.ag-cancelado   { background: #FCEBEB; color: #A32D2D; }
.badge.ag-adiado      { background: #FAEEDA; color: #854F0B; }

/* Contratos */
.badge.ctr-vigente    { background: #E3EFD9; color: #3B6D11; }
.badge.ctr-vencido    { background: #FCEBEB; color: #A32D2D; }
.badge.ctr-rescindido { background: #EDEDED; color: #5f5e5a; }
.badge.ctr-arquivado  { background: #D1D3D8; color: #383d41; }

.prio { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.prio-baixa { background: #EDEDED; color: #5f5e5a; }
.prio-normal { background: #E6F1FB; color: #185FA5; }
.prio-alta { background: #FAEEDA; color: #854F0B; }
.prio-urgente { background: #E30613; color: #FFFFFF; }

.empresa-chip { display: inline-block; padding: 2px 9px; border-radius: 3px; font-size: 10px; font-weight: 700; background: #201E1E; color: #FFFFFF; letter-spacing: .4px; text-transform: uppercase; }
.empresa-chip.otimize { background: #E36A0D; color: #FFFFFF; }

/* ---------- FORMS ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: #444; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password], .form-row input[type=file], .form-row select, .form-row textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #D9D9D9; border-radius: 5px; font-size: 13.5px; font-family: inherit; background: #FFFFFF; color: #201E1E;
}
.form-row textarea { resize: vertical; min-height: 110px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: #E30613; box-shadow: 0 0 0 3px rgba(227,6,19,.12); }

button, .btn { display: inline-block; padding: 9px 18px; background: #E30613; color: #FFFFFF; border: none; border-radius: 5px; font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 600; }
button:hover, .btn:hover { background: #b80511; text-decoration: none; color: #FFFFFF; }
.btn-secundario { background: #888780; }
.btn-secundario:hover { background: #5f5e5a; }
.btn-escuro { background: #201E1E; }
.btn-escuro:hover { background: #000; }
.btn-pequeno { padding: 5px 11px; font-size: 12px; }
.btn-ghost { background: #FFFFFF; border: 1px solid #D9D9D9; color: #5f5e5a; font-weight: 500; }
.btn-ghost:hover { background: #F5F5F5; color: #201E1E; }

/* ---------- TABELAS ---------- */
table.listagem { width: 100%; border-collapse: collapse; background: #FFFFFF; border: 0.5px solid #E5E5E5; border-radius: 8px; overflow: hidden; }
table.listagem th, table.listagem td { padding: 11px 14px; text-align: left; border-bottom: 1px solid #F0F0F0; font-size: 13px; vertical-align: middle; }
table.listagem th { background: #FAFAFA; font-weight: 600; color: #888780; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
table.listagem tr:last-child td { border-bottom: none; }
table.listagem tr:hover { background: #FFF8F8; }

/* ---------- ALERTAS ---------- */
.alerta { padding: 12px 16px; border-radius: 5px; margin-bottom: 16px; font-size: 13px; border-left: 3px solid transparent; }
.alerta-erro { background: #FCEBEB; color: #A32D2D; border-left-color: #E30613; }
.alerta-ok { background: #E3EFD9; color: #3B6D11; border-left-color: #3B6D11; }
.alerta-info { background: #E6F1FB; color: #185FA5; border-left-color: #185FA5; }

/* ---------- LOGIN (fora do shell) ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.login-box { max-width: 380px; margin: 60px auto; background: #FFFFFF; border-radius: 10px; padding: 30px; border: 0.5px solid #E5E5E5; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.login-box .login-brand { text-align: center; margin-bottom: 24px; }
.login-box .login-brand .brand-badge { display: inline-block; font-size: 16px; padding: 8px 18px; }
.login-box h1 { text-align: center; font-size: 18px; margin: 12px 0 20px; color: #201E1E; }

/* ---------- TIMELINE ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid #E5E5E5; padding: 6px 0 16px 16px; margin-left: 8px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: #FFFFFF; border: 3px solid #E30613; }
.timeline li.interno::before { border-color: #b08000; }
.timeline li .meta { font-size: 11px; color: #888780; margin-bottom: 4px; }
.timeline li .meta .autor { color: #444; font-weight: 600; }
.timeline li .conteudo { white-space: pre-wrap; font-size: 13.5px; }
.timeline li.interno { background: #FFF9E0; padding: 8px 12px 12px; border-radius: 4px; margin-left: 0; padding-left: 26px; }
.timeline li.interno .meta::after { content: ' \2022 nota interna'; color: #b08000; font-weight: 600; }

/* ---------- ANEXOS ---------- */
.anexos { list-style: none; padding: 0; margin: 8px 0 0; }
.anexos li { font-size: 12.5px; padding: 4px 0; }
.anexos li .tam { color: #888780; font-size: 11px; }
.anexos li::before { content: '\01F4CE\00A0'; color: #888780; font-size: 12px; }

/* ---------- PAINEL DE ACOES ---------- */
.painel-acoes { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.painel-acoes form { margin: 0; }
.painel-acoes label { display: inline; margin: 0 6px 0 0; font-size: 12px; }

/* ---------- DETAILS / SUMMARY ---------- */
details.card summary { cursor: pointer; font-size: 14px; padding: 4px 0; user-select: none; }
details.card summary:hover { color: #E30613; }
details.card[open] summary { margin-bottom: 12px; border-bottom: 1px solid #F0F0F0; padding-bottom: 8px; }

/* ---------- EMPRESAS DO GRUPO ---------- */
.empresas-grupo { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.empresa-card { background: #FFFFFF; border: 0.5px solid #E5E5E5; border-radius: 8px; padding: 12px 16px; min-width: 140px; display: flex; align-items: center; gap: 10px; }
.empresa-card .emp-logo { width: 40px; height: 40px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #FFFFFF; flex-shrink: 0; overflow: hidden; }
.empresa-card .emp-logo img { width: 100%; height: 100%; object-fit: contain; }
.empresa-card .emp-logo.mig { background: #E30613; }
.empresa-card .emp-logo.mfc { background: #201E1E; }
.empresa-card .emp-logo.otimize { background: #E36A0D; padding: 4px; }
.empresa-card .emp-logo.pessoal { background: #5f5e5a; }
.empresa-card .emp-info .emp-nome { font-size: 13px; font-weight: 600; color: #201E1E; }
.empresa-card .emp-info .emp-tipo { font-size: 10px; color: #888780; text-transform: uppercase; letter-spacing: .4px; }

/* ---------- RESPONSIVO ---------- */
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "sidebar" "main"; }
  .app-sidebar { min-height: auto; padding: 12px 0; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
  .app-main { padding: 16px; }
}
