:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21253a;
    --accent: #4f8ef7;
    --accent-hover: #3a7ae8;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #e8ecf4;
    --text-secondary: #8b92a9;
    --border: #2d3350;
    --radius: 12px;
    --sidebar-width: 260px;
    --header-height: 60px;
}

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

html, body {
    width: 100%;
    overflow-x: hidden;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Overlay for mobile nav */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,.5);
  z-index: 999;
  display: none;
}

.overlay.open {
  display: block;
}

/* Responsive mobile behavior: collapse sidebar and show menu button */
@media (max-width: 1024px) {
  .btn-menu { display: inline-flex; }
  .sidebar {
    transform: translateX(-100%);
    left: 0;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100%;
  }
  html, body { overflow-x: hidden; }
}

/* Ensure charts resize nicely on small screens */
.chart-container canvas { width: 100% !important; height: auto !important; }

/* Limit chart container width to improve layout on wider screens */
.chart-container { max-width: 420px; margin: 0 auto; }

/* Prevent horizontal overflow on cards and ensure wrapping on mobile */ 
@media (max-width: 768px) {
  .card { width: 100%; max-width: 100%; box-sizing: border-box; }
  .card-header h3 { white-space: normal; word-break: break-word; }
}

/* Ensure long OS related texts wrap gracefully if used in any element */
.os-id, .os-number, .os-text, [class*="os-"] {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.app { 
    display: flex; 
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Sidebar Desktop */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-header {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo { max-height: 32px; max-width: 100%; border-radius: 6px; }
.sidebar-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { 
    flex: 1; 
    padding: 12px 0; 
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover { color: var(--text-primary); background: rgba(79,142,247,0.08); }
.nav-link.active { color: var(--accent); background: rgba(79,142,247,0.12); border-right: 3px solid var(--accent); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-secondary); text-transform: capitalize; }

.btn-logout {
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    text-decoration: none;
    display: flex;
    flex-shrink: 0;
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

.topbar {
    padding: 12px 28px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
    min-height: var(--header-height);
}

.btn-menu { 
    display: none; 
    background: none; 
    border: none; 
    color: var(--text-primary); 
    cursor: pointer; 
    padding: 8px;
    flex-shrink: 0;
}

.topbar-title { 
    font-size: 1.1rem; 
    font-weight: 600; 
    flex: 1; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions { 
    display: flex; 
    gap: 8px; 
    flex-wrap: wrap;
    flex-shrink: 0;
}

.content { 
    padding: 28px; 
    flex: 1; 
    width: 100%;
    overflow-x: hidden;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.card form {
  width: 100%;
}

.card > form {
  padding: 8px 24px 24px;
}

.card > form > .form-actions {
  padding-top: 8px;
}

.card > form > .section-title:first-child {
  margin-top: 8px;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-header form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.card-header > form:not(:last-child) {
  margin-right: auto;
}

.card-header input[type="text"] {
  min-height: 40px;
  flex: 1;
}

.card-header .btn {
  flex-shrink: 0;
}

.card-header h3 { 
  font-size: 1rem; 
  font-weight: 600; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-header h3:not(:last-child) {
  margin-right: 8px;
}

/* Stats Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
}

.card-stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(79,142,247,0.15); color: var(--accent); }
.stat-icon.green { background: rgba(34,197,94,0.15); color: var(--success); }
.stat-icon.yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.stat-icon.red { background: rgba(239,68,68,0.15); color: var(--danger); }

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 1.4rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--text-primary); }
a.card-stat { color: inherit; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 16px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.page-link:hover {
    background: var(--hover);
    border-color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Tables */
.table-responsive { 
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 0;
    width: 100%;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
}

th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

th {
    background: rgba(0,0,0,0.2);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    white-space: normal;
    padding: 10px 8px;
}

/* Responsive Table Typography */
@media (max-width: 1280px) {
    th, td { font-size: 0.82rem; padding: 8px 6px; }
    th { font-size: 0.70rem; }
}
@media (max-width: 768px) {
    th, td { font-size: 0.8rem; padding: 8px 6px; }
    th { font-size: 0.68rem; }
}
@media (max-width: 480px) {
    th, td { font-size: 0.75rem; padding: 6px 4px; }
    th { font-size: 0.60rem; }
}

tr:hover { background: rgba(79,142,247,0.04); }

.order-input {
    width: 40px;
    text-align: center;
    padding: 4px;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text);
    -moz-appearance: textfield;
}
.order-input::-webkit-inner-spin-button,
.order-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.order-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(79,142,247,0.2);
}

/* Prevent overflow on non-action cells on larger screens */
@media (min-width: 769px) {
  td:not(.actions-cell):not(.col-check) {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Center empty/dash values in tables */
td.text-center {
  text-align: center;
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

/* Ensure table cells have proper spacing */
td {
  vertical-align: middle;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 40px;
}

.btn-sm { padding: 8px 12px; font-size: 0.8rem; min-height: 32px; gap: 6px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #3a4060; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-icon {
  padding: 6px;
  min-width: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 6px;
  color: var(--text-primary);
  border: 0;
  flex-shrink: 0;
  gap: 4px;
}

.btn-icon svg, .btn-icon i {
  display: block;
  margin: auto;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--accent); }
.btn-icon.btn-danger { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.3); border-radius: 6px; }
.btn-icon.btn-danger:hover { background: rgba(239,68,68,0.22); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
}

/* Form grid com 3 colunas para register */
.form-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Ensure spacing after horizontal rules in forms */
.form-grid + hr,
hr + .form-grid {
  margin-top: 8px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.form-group { 
  display: flex; 
  flex-direction: column; 
  gap: 6px; 
  min-width: 0; 
  width: 100%;
}

/* Spacing between form sections */
.form-grid + hr {
  margin-top: 8px;
}

hr + h6 {
  margin-top: 8px;
}

h6 + .form-grid {
  margin-top: 4px;
}

/* Form grid column spans - makes field span full width */
.form-group[style*="grid-column:span 2"],
.form-group[style*="grid-column: span 2"] {
  grid-column: 1 / -1 !important;
}

/* Ensure form-grid items stretch properly */
.form-grid {
  align-items: stretch;
}

.form-grid > .form-group {
  min-width: 0;
}

/* Section titles inside forms */
h6 {
  margin-top: 20px;
  margin-bottom: 14px;
  padding-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.card-body h6:first-child,
.form-grid + h6 {
  margin-top: 20px;
}

/* Small helper text */
small {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.4;
}

.form-group small {
  margin-top: 2px;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-danger {
  color: var(--danger);
}

/* Ensure form elements don't overflow */
.form-grid > * {
  min-width: 0;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
  width: 100%;
}

input, select, textarea {
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  min-height: 44px;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

/* Ensure password inputs have same styling */
input[type="password"] {
  letter-spacing: 0.1em;
}

input::placeholder, textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Input with icon or button inside */
.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
}

textarea { resize: vertical; min-height: 80px; }

.form-actions { 
  display: flex; 
  gap: 16px; 
  margin-top: 24px; 
  flex-wrap: wrap; 
  width: 100%;
}

.form-actions .btn {
  flex: 1 1 auto;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-pendente { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-aprovada { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-reprovada { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-em_andamento { background: rgba(79,142,247,0.15); color: var(--accent); }
.badge-concluida { background: rgba(16,185,129,0.15); color: #10b981; }
.badge-entregue { background: rgba(139,92,246,0.15); color: #8b5cf6; }

/* Footer */
.footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.overlay.active { display: block; }

/* ========== RESPONSIVIDADE ========== */

/* --- Mobile (< 768px): sidebar oculta, conteúdo full-width --- */
@media (max-width: 767px) {
    :root {
        --sidebar-width: 260px;
        --header-height: 56px;
    }

    html { font-size: 15px; }

    .sidebar {
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        z-index: 1000;
    }
    .sidebar.open { transform: translateX(0); }
    .btn-menu { display: block; }
    .main-content { margin-left: 0; width: 100%; }

    /* Layout */
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; gap: 10px; }
    .topbar-title { font-size: 1rem; }
    .card-header { padding: 12px 16px; gap: 8px; flex-wrap: wrap; }
    .card-header h3 { font-size: 0.9rem; }
    .card-body { padding: 16px; }

    /* Stats grid: 2 colunas no mobile */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .card-stat { padding: 14px 12px; gap: 10px; }
    .stat-icon { width: 38px; height: 38px; }
    .stat-value { font-size: 1.2rem; }
    .stat-label { font-size: 0.75rem; }

    /* Forms */
    .form-grid,
    .form-grid.cols-3 {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }
    .form-actions { gap: 10px; }
    .form-actions .btn { flex: 1 1 calc(50% - 5px); min-width: 120px; }

    /* Detail grid */
    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        padding: 16px;
    }
    .valores-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        padding: 16px;
    }

    /* Tabelas: sem min-width forçado, células compactas */
    table { width: 100%; }
    th, td { padding: 10px 8px; font-size: 0.82rem; }
    th { font-size: 0.7rem; padding: 10px 8px; }
    .actions-cell { gap: 4px; padding: 6px 4px; }
    .btn-icon { min-width: 30px; min-height: 30px; padding: 6px; }
    .col-actions { width: auto; }

    /* Sidebar footer */
    .sidebar-header { padding: 14px; }
    .nav-link { padding: 12px 14px; font-size: 0.85rem; }
    .user-info { display: none; }
    .sidebar-footer { padding: 8px 12px; }

    /* Misc */
    .pagination { flex-wrap: wrap; gap: 4px; padding: 12px 16px; }
    .tabs { gap: 4px; }
    .tabs .tab { padding: 8px 12px; font-size: 0.82rem; }
    .modal-content { width: 95vw !important; left: 2.5vw !important; }

    /* Prevenir card de vazar para fora */
    body, html { overflow-x: hidden; max-width: 100vw; }
}

/* --- Mobile pequeno (< 480px): ajustes extras --- */
@media (max-width: 480px) {
    html { font-size: 14px; }

    .cards-grid { grid-template-columns: 1fr; gap: 8px; }
    .card-stat { padding: 12px; gap: 10px; }

    .detail-grid,
    .valores-grid { grid-template-columns: 1fr; gap: 12px; padding: 12px; }

    .form-actions .btn { flex: 1 1 100%; }

    th, td { padding: 8px 6px; font-size: 0.78rem; }
    th { font-size: 0.65rem; }
}

/* --- Tablet Portrait (768px - 1023px) --- */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; }
    .btn-menu { display: block; }
    .content { padding: 20px; }
    .cards-grid { grid-template-columns: repeat(3, 1fr); }
    .form-grid.cols-3 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* --- Tablet Landscape / Small Laptop (1024px - 1279px) --- */
@media (min-width: 1024px) and (max-width: 1279px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; width: calc(100% - 220px); }
    .cards-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Desktop HD (1280px - 1535px) --- */
@media (min-width: 1280px) and (max-width: 1535px) {
    .cards-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Full HD (1536px+) --- */
@media (min-width: 1536px) {
    :root { --sidebar-width: 280px; }
    .sidebar { width: 280px; }
    .main-content { margin-left: 280px; width: calc(100% - 280px); }
    .cards-grid { grid-template-columns: repeat(4, 1fr); }
    .card-stat { padding: 20px; }
    .stat-value { font-size: 1.6rem; }
}

/* Wide / QHD - 1920px - 2559px */
@media (min-width: 1920px) and (max-width: 2559px) {
    :root {
        --sidebar-width: 300px;
    }
    
    .sidebar { width: 300px; }
    .main-content { margin-left: 300px; width: calc(100% - 300px); }
    
    .content { padding: 36px 48px; }
    
    .cards-grid { grid-template-columns: repeat(4, 1fr); }
    
    .stat-icon { width: 52px; height: 52px; }
    .stat-value { font-size: 1.75rem; }
    
    .sidebar-title { font-size: 1.1rem; }
    .nav-link { padding: 14px 20px; font-size: 1rem; }
}

/* 4K / Ultra Wide - 2560px+ */
@media (min-width: 2560px) {
    :root {
        --sidebar-width: 340px;
    }
    
    .sidebar { width: 340px; }
    .main-content { margin-left: 340px; width: calc(100% - 340px); }
    
    .content { padding: 40px 64px; }
    
    .cards-grid { grid-template-columns: repeat(5, 1fr); }
    
    body { font-size: 14px; }
    .stat-value { font-size: 2rem; }
    
    .sidebar-title { font-size: 1.2rem; }
    .nav-link { padding: 16px 24px; font-size: 1.1rem; }
    th, td { font-size: 0.9rem; }
}

/* Safe Area Support (notched phones) */
@supports (padding: max(0px)) {
    .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
    .content { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .sidebar-header { padding-top: max(16px, env(safe-area-inset-top)); }
}

/* Landscape mobile */
@media (orientation: landscape) and (max-height: 500px) {
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 8px; display: flex; justify-content: center; }
    .nav-link { padding: 8px 12px; font-size: 0.7rem; }
    .sidebar-header { display: none; }
    .sidebar-footer { padding: 8px; }
}

/* Ultra-wide */
@media (min-width: 2560px) {
    :root { --sidebar-width: 320px; }
    .sidebar { width: 320px; }
    .main-content { margin-left: 320px; width: calc(100% - 320px); }
    .content { padding: 40px 64px; }
    .cards-grid { grid-template-columns: repeat(5, 1fr); }
    .stat-value { font-size: 1.8rem; }
}


/* Print styles */
@media print {
    .sidebar, .topbar, .btn, .form-actions { display: none !important; }
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .content { padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
}

/* Config Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    flex-wrap: wrap;
}

.tabs .tab {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.tabs .tab:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
}

.tabs .tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Checkbox styling */
input[type="checkbox"] {
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  cursor: pointer;
  flex-shrink: 0;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background: var(--bg-secondary);
  border: 1px solid var(--border) !important;
  border-radius: 3px;
  position: relative;
  transition: all 0.2s;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Checkbox dentro de tabelas - ainda menor */
table input[type="checkbox"] {
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
  min-height: 12px !important;
  max-width: 12px !important;
  max-height: 12px !important;
}
input[type="checkbox"]:checked {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 9px;
  font-weight: bold;
  line-height: 1;
}
input[type="checkbox"]:hover {
  border-color: var(--accent);
}

input[type="file"] {
  max-width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: 8px 16px;
  margin-right: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--accent-hover);
}

label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  width: auto;
  margin-top: 8px;
}

/* Checkbox after image preview */
div[style*="margin-bottom:8px"] + div + label:has(input[type="checkbox"]),
div > label:has(input[type="checkbox"]) {
  margin-top: 12px;
  display: flex;
  padding: 4px 0;
}

/* Ensure checkbox labels have proper spacing */
label:has(input[type="checkbox"]) span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Label with checkbox inside form-group */
.form-group > label:has(input[type="checkbox"]) {
  display: flex;
  width: 100%;
  margin-top: 8px;
}

/* Standalone checkbox labels (like "Remover logo") */
label:has(input[type="checkbox"]) + input[type="file"],
div + label:has(input[type="checkbox"]) {
  margin-top: 8px;
}

/* Detail grid for client view */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    padding: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Alert messages */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.alert-success {
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--danger);
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    overflow-y: auto;
    backdrop-filter: blur(2px);
}

/* Hover card for store */
.hover-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.hover-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(79,142,247,0.15) !important;
    border-color: var(--accent) !important;
}

/* Badge info */
.badge-info {
    background: rgba(79,142,247,0.15);
    color: var(--accent);
}

/* Actions cell */
.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 12px;
  white-space: nowrap;
}

.actions-cell form {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

.actions-cell .btn,
.actions-cell .btn-icon {
  margin: 0;
}

/* Column width utilities */
.col-check { width: 40px; min-width: 40px; text-align: center; vertical-align: middle; }
.col-check input[type="checkbox"] { margin: 0 auto; vertical-align: middle; }
.col-order { width: 60px; min-width: 60px; text-align: center; vertical-align: middle; }
.col-count { width: 60px; min-width: 60px; text-align: center; vertical-align: middle; }
.col-period { font-size: 0.8rem; white-space: nowrap; }
.col-service { min-width: 120px; }
.col-date { white-space: nowrap; font-size: 0.75rem; }
.col-actions { white-space: nowrap; width: 1%; }

/* Text center utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--accent); }
.fw-bold { font-weight: 700; }
.border-bottom { border-bottom: 1px solid var(--border); }
.pb-2 { padding-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-auto { margin-top: auto; }
.me-2 { margin-right: 8px; }
.ms-2 { margin-left: 8px; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.card-img-top { width: 100%; border-radius: var(--radius) var(--radius) 0 0; }

/* ============================================ */
/* Utility classes for responsive hiding */
/* ============================================ */

/* Dispositivos pequenos (<= 480px) */
@media (max-width: 480px) {
    .hide-sm { display: none !important; }
    .actions-cell { gap: 2px; }
}

/* Tablets e pequenos laptops (<= 768px) */
@media (max-width: 768px) {
    .hide-md { display: none !important; }
    .actions-cell { gap: 4px; }
}

/* Telas médias (<= 1024px) */
@media (max-width: 1024px) {
    .hide-lg { display: none !important; }
}

.card-body { 
  padding: 24px; 
  padding-bottom: 28px;
  display: flex;
  flex-direction: column;
}

.card-body > form,
.card-body > form > .form-grid {
  width: 100%;
}

.card-body > :last-child {
  margin-bottom: 0;
}

/* Form actions at bottom of card */
.card-body .form-actions {
  margin-top: 20px;
  padding-top: 8px;
}
.card-title { font-size: 1.05rem; }

/* General Flexbox Row (Bootstrap-like) */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -12px;
}
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }

/* Column widths */
.col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-10, .col-lg-8 {
    padding: 0 12px;
    width: 100%;
}
@media (min-width: 768px) {
    .col-md-4 { width: 33.333%; }
    .col-md-5 { width: 41.666%; }
    .col-md-6 { width: 50%; }
    .col-md-7 { width: 58.333%; }
    .col-md-8 { width: 66.666%; }
    .col-md-10 { width: 83.333%; }
}
@media (min-width: 992px) {
    .col-lg-8 { width: 66.666%; }
}

/* Row / Col grid for store */
.store-content .row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 0;
}

/* Checkout: 2 colunas lado a lado */
.store-content .row.checkout-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.store-content .row > [class*="col-"] {
    width: auto !important;
    padding: 0;
}

/* Checkout columns stack on mobile */
@media (max-width: 768px) {
    .store-content .row.checkout-grid {
        grid-template-columns: 1fr;
    }
}

.col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8 {
    min-width: 0;
}

/* Display */
.display-5 {
    font-size: 2rem;
    font-weight: 700;
}

.lead {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Section title */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin: 20px 0 12px;
}

.section-title:first-child {
    margin-top: 0;
}

/* Shadow utility */
.shadow-sm { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* Badge active/inactive */
.badge-ativa { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-inativa { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Responsive row for store */
/* Mobile general fixes */
@media (max-width: 768px) {
    .app { overflow-x: hidden; }
    .store-content .row { grid-template-columns: 1fr; }
    .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8 { grid-column: 1; }
    .display-5 { font-size: 1.5rem; }
}

/* Login card centralizado */
body.page-login .row { justify-content: center; }
body.page-login .card { width: 100%; }

/* ========== GOOGLE TRANSLATE / LANG FLAG BAR ========== */

#google_translate_element,
.goog-te-banner-frame,
.goog-te-banner-frame.skiptranslate,
.skiptranslate > iframe,
#goog-gt-tt,
.goog-te-balloon-frame { display: none !important; }
body { top: 0 !important; }
font, font span { font-size: inherit !important; font-family: inherit !important; line-height: inherit !important; vertical-align: baseline !important; }

#lang-flag-bar {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(26,29,39,0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
    overflow: hidden;
    max-height: 42px;
    transition: max-height 0.3s ease;
}
#lang-flag-bar:hover {
    max-height: 200px;
}
#lang-flag-bar button {
    background: none;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 3px;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s, border-color 0.15s;
    opacity: 0.7;
    display: none;
    order: 2;
}
#lang-flag-bar:hover button { display: block; }
#lang-flag-bar button img { display: block; width: 28px; height: 20px; object-fit: cover; border-radius: 3px; }
#lang-flag-bar button:hover { transform: scale(1.15); opacity: 1; }
#lang-flag-bar button.active { border-color: var(--accent); opacity: 1; display: block; order: 1; }

@media (max-width: 480px) {
    #lang-flag-bar {
        top: 60px;
        right: 8px;
        padding: 4px 8px;
    }
    #lang-flag-bar button img { width: 24px; height: 16px; }
}

/* Sidebar mobile — ensure footer buttons visible */
@media (max-width: 480px) {
    .sidebar-footer { padding: 8px; }
    .sidebar-footer .btn { font-size: 0.7rem; padding: 5px 6px; min-height: 28px; }
    .sidebar-nav .nav-link { padding: 10px 12px; font-size: 0.8rem; }
    th, td { padding: 10px 12px; font-size: 0.8rem; }
    .actions-cell { gap: 2px; }
    .btn-icon { padding: 6px; min-width: 28px; min-height: 28px; }
}
