:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --secondary: #0f172a;
  --accent: #059669;
  --accent-hover: #047857;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --bg-light: #f8fafc;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 80px; /* Espacio para barra de navegación móvil */
}

/* Layout General */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Desktop */
.sidebar {
  display: none;
  width: 260px;
  background-color: var(--secondary);
  color: #fff;
  flex-shrink: 0;
  padding: 24px 16px;
  flex-direction: column;
}

.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link:hover, .sidebar-link.active {
  background-color: var(--primary);
  color: #ffffff;
}

/* Main Content */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Top Header */
.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-light);
  padding: 4px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.lang-btn {
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 16px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Contenido Principal */
.content-area {
  padding: 20px 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* Barra de Navegación Inferior (Móvil) */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  gap: 4px;
  flex: 1;
  padding: 6px 0;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

/* Tarjetas y Componentes */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Botones de Acción Rápida (Estilo App Móvil) */
.quick-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s, box-shadow 0.2s;
}

.quick-btn:active {
  transform: scale(0.98);
}

.quick-btn-primary {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: #fff;
}

.quick-btn-accent {
  background: linear-gradient(135deg, #065f46 0%, #10b981 100%);
  color: #fff;
}

.quick-btn svg {
  width: 32px;
  height: 32px;
}

/* Badges de Estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  background: #fff;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  width: 100%;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-danger { background: var(--danger); color: #fff; }

/* Contenedor de Cámara y Escaneo */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 20px auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-overlay {
  position: absolute;
  top: 15%;
  left: 10%;
  right: 10%;
  bottom: 15%;
  border: 3px dashed rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Área de Firma Táctil */
.signature-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fff;
  position: relative;
  width: 100%;
  height: 180px;
  margin-bottom: 10px;
  touch-action: none;
}

.signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tablas Responsivas */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th, .table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-muted);
}

/* Media Queries para Pantallas Grandes (Desktop / Tablet) */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
  .sidebar {
    display: flex;
  }
  .mobile-bottom-nav {
    display: none;
  }
  .quick-action-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .btn {
    width: auto;
  }
  .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
  }
}

/* Tarjetas KPI / Métricas Financieras y Dashboard */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 105px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Placas japonesas siempre en una sola línea horizontal */
.japan-plate {
  white-space: nowrap !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", monospace, sans-serif;
  font-weight: 700;
  background: #f8fafc;
  border: 1.5px solid #0f172a;
  border-radius: 4px;
  padding: 3px 8px;
  display: inline-block;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  color: #0f172a;
}

/* Grupo de botones de acción sin recortes */
.btn-action-group {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap !important;
}

.btn-action-sm {
  padding: 6px 12px !important;
  font-size: 0.82rem !important;
  width: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
}

.table th {
  white-space: nowrap;
}


/* ==========================================================================
   COMPONENTES REALISTAS DE PLACAS JAPONESAS (BRANCA, AMARELA, PRETA, VERDE)
   ========================================================================== */
.jp-plate {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 5px;
    position: relative;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
    font-weight: 800;
    line-height: 1;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.18), inset 0 0 0 1px rgba(255,255,255,0.4);
    vertical-align: middle;
    text-align: center;
    overflow: hidden;
}

/* Tamanho Normal / Ficha de Detalhes (Proporção oficial Japão 2:1) */
.jp-plate-normal {
    width: 144px;
    height: 72px;
    padding: 6px 10px 5px 10px;
    border-width: 3px;
    border-style: solid;
}
.jp-plate-normal .jp-plate-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    letter-spacing: 1px;
}
.jp-plate-normal .jp-plate-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 4px;
}
.jp-plate-normal .jp-kana {
    font-size: 18px;
    font-weight: 900;
}
.jp-plate-normal .jp-num {
    font-size: 27px;
    font-weight: 900;
    letter-spacing: 2px;
}

/* Tamanho Miniatura / Tabela de Estoque */
.jp-plate-sm {
    width: 98px;
    height: 48px;
    padding: 3px 6px 3px 6px;
    border-width: 2px;
    border-style: solid;
    border-radius: 4px;
}
.jp-plate-sm .jp-plate-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    letter-spacing: 0.5px;
}
.jp-plate-sm .jp-plate-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 2px;
}
.jp-plate-sm .jp-kana {
    font-size: 12px;
    font-weight: 900;
}
.jp-plate-sm .jp-num {
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 1px;
}

/* Parafusos nos cantos superiores */
.jp-plate::before, .jp-plate::after {
    content: '';
    position: absolute;
    top: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 1px solid #94a3b8;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
}
.jp-plate-sm::before, .jp-plate-sm::after {
    top: 3px;
    width: 4px;
    height: 4px;
}
.jp-plate::before { left: 14px; }
.jp-plate::after { right: 14px; }
.jp-plate-sm::before { left: 9px; }
.jp-plate-sm::after { right: 9px; }

/* 1. Placa Branca (Shiro-nambā - 普通車): Fundo Branco, Letras Verdes */
.jp-plate-white {
    background: #ffffff;
    border-color: #1e5631;
    color: #1e5631;
}
.jp-plate-white::before {
    background: #94a3b8;
    border-color: #64748b; /* Lacre Fūin no parafuso esquerdo */
}

/* 2. Placa Amarela (Ki-nambā - 軽自動車): Fundo Amarelo, Letras Pretas */
.jp-plate-yellow {
    background: #fedd00;
    border-color: #18181b;
    color: #18181b;
}
.jp-plate-yellow::before, .jp-plate-yellow::after {
    background: #3f3f46;
    border-color: #18181b;
}

/* 3. Placa Preta (Kuro-nambā - 軽貨物・事業用): Fundo Preto, Letras Amarelas */
.jp-plate-black {
    background: #18181b;
    border-color: #fedd00;
    color: #fedd00;
}
.jp-plate-black::before, .jp-plate-black::after {
    background: #52525b;
    border-color: #27272a;
}

/* 4. Placa Verde (Midori-nambā - 普通車事業用): Fundo Verde, Letras Brancas */
.jp-plate-green {
    background: #1e5631;
    border-color: #ffffff;
    color: #ffffff;
}

/* ==========================================================================
   OTIMIZAÇÕES DE ALTA DENSIDADE (ERP COMPACTO) E CELULAR (MOBILE)
   ========================================================================== */
body {
    font-size: 13.5px;
}
.table td, .table th {
    padding: 8px 10px;
    font-size: 0.85rem;
}
.card {
    padding: 16px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 1.05rem;
}

/* Botões de Ação no Mobile: transformam em ícones quadrados touch perfeitos */
@media (max-width: 768px) {
    .btn-action-group {
        display: inline-flex !important;
        gap: 6px !important;
        align-items: center !important;
    }
    .btn-action-sm {
        min-width: 36px !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.05rem !important;
        border-radius: 6px !important;
    }
    .btn-action-sm .btn-text-full {
        display: none !important;
    }
    .mobile-bottom-nav .nav-item span {
        font-size: 0.68rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Coluna de Ações Congelada / Sticky */
.col-actions-sticky {
    position: sticky;
    right: 0;
    background: #ffffff;
    z-index: 4;
    box-shadow: -3px 0 6px rgba(0,0,0,0.05);
}
th.col-actions-sticky {
    background: #f8fafc;
}
