:root {
    /* Layout */
    --sidebar-width: 250px;
    --sidebar-bg: #1a1f36;
    --sidebar-text: #a0aec0;
    --sidebar-active: #ffffff;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --topbar-height: 60px;

    /* Brand */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;
    --primary-border: #dbeafe;

    /* Gray scale */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic */
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --info: #0891b2;
    --info-bg: #ecfeff;
    --info-border: #a5f3fc;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.05);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Typography base ─────────────────────────────────────── */
body {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--gray-900);
}

.text-numeric,
.table td.text-end {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2d3561 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card .text-primary {
    color: var(--primary) !important;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

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

.sidebar-header {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo-icon {
    width: 34px;
    height: 34px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    color: #fff;
    letter-spacing: 2px;
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-logo-k {
    color: var(--primary);
}

.sidebar-section-label {
    list-style: none;
    padding: 1rem 1rem 0.3rem 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgba(160, 174, 192, 0.5);
    text-transform: uppercase;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    margin: 1px 0;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.sidebar .nav-link:hover:not(.disabled) {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-active);
}

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

.sidebar .nav-link.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sidebar-user {
    padding: 0.875rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logout {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sidebar-logout:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #f1f5f9;
    /* flex-grow-1 sem min-width:0 nao deixa o item encolher abaixo da
       largura natural do conteudo (ex.: tabela larga) - o resultado e a
       pagina inteira estourando a largura no tablet em vez de so a tabela
       rolar dentro do .table-responsive. Achado na auditoria de design
       visual de 10/08/2026 testando pedidos/novo.html em 768px. */
    min-width: 0;
}

.top-bar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-icon {
    width: 32px;
    height: 32px;
    background: #eff6ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.top-bar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
}

.topbar-avatar {
    width: 30px;
    height: 30px;
    background: #eff6ff;
    border: 2px solid #dbeafe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.content-area {
    min-height: calc(100vh - var(--topbar-height));
}

/* ── Dashboard V1.1 (C1) ─────────────────────────────────── */
.card-dashboard {
    border-radius: var(--radius-lg);
    transition: transform 0.2s;
}

.card-dashboard:hover {
    transform: translateY(-2px);
}

.icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-stat {
    transition: transform 0.15s, box-shadow 0.15s;
}

.card-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
}

.card-stat-alert {
    border-left: 3px solid var(--warning) !important;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-400);
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    font-variant-numeric: tabular-nums;
}

.stat-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-decoration: none;
    transition: color 0.15s, gap 0.15s;
}

.stat-link:hover {
    color: var(--primary);
    gap: 0.5rem;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.1rem 0.5rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s;
}

.quick-action i {
    font-size: 1.35rem;
    color: var(--gray-400);
    transition: color 0.15s;
}

.quick-action:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.quick-action:hover i {
    color: var(--primary);
}

.kbd-hint {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.7rem;
    color: var(--gray-500);
    font-family: var(--font-sans);
}

/* ── Status badges com dot (C3) ──────────────────────────── */
.badge.bg-opacity-10 {
    border-radius: 999px;
    padding: 0.3em 0.7em 0.3em 0.55em;
    font-weight: 600;
    font-size: 0.72rem;
}

.badge.bg-opacity-10::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 5px;
    vertical-align: 1px;
}

/* ── Formulários refinados (C4) ──────────────────────────── */
.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.3rem;
}

.form-control,
.form-select {
    border-color: var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--gray-800);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control::placeholder {
    color: var(--gray-300);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ── Botões (C2) ─────────────────────────────────────────── */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.865rem;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.pagination .page-link {
    color: var(--gray-600);
    border-color: var(--gray-200);
    font-size: 0.85rem;
}

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

/* ── Tables (A3) ─────────────────────────────────────────── */
.table {
    --bs-table-hover-bg: var(--gray-50);
    margin-bottom: 0;
}

.table thead th {
    background: var(--gray-50) !important;
    color: var(--gray-500);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

.table tbody td {
    padding: 0.7rem 1rem;
    font-size: 0.865rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background 0.1s;
}

.table td.fw-bold,
.table td .fw-bold {
    color: var(--gray-900);
}

/* General */
.card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.card.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--gray-100);
}

.card-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    border-bottom: 1px solid var(--gray-100);
    padding: 0.85rem 1.25rem;
}

/* Filter card — visually separate from content */
.card-filter {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: none !important;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.45;
}

.empty-state p {
    font-size: 0.875rem;
    margin: 0;
    color: #64748b;
}

/* ── Busca global Ctrl+K (B1) ────────────────────────────── */
.global-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.75rem;
    color: var(--gray-400);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-width: 200px;
    text-align: left;
}

.global-search-trigger span { flex-grow: 1; }

.global-search-trigger:hover {
    border-color: var(--gray-300);
    background: #fff;
}

.global-search-trigger kbd,
.global-search-input-wrap kbd {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.65rem;
    color: var(--gray-400);
    font-family: var(--font-sans);
}

.global-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 3000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}

.global-search-panel {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: searchPanelIn 0.15s ease-out;
}

@keyframes searchPanelIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.global-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-400);
}

.global-search-input-wrap input {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    color: var(--gray-800);
    background: transparent;
}

.global-search-results {
    max-height: 380px;
    overflow-y: auto;
}

.global-search-hint {
    padding: 1.5rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.82rem;
}

.global-search-group {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
}

.global-search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    text-decoration: none;
    color: var(--gray-700);
    transition: background 0.1s;
}

.global-search-item:hover,
.global-search-item.selected {
    background: var(--primary-light);
    color: var(--gray-900);
}

.global-search-item .gs-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.global-search-item:hover .gs-icon,
.global-search-item.selected .gs-icon {
    background: var(--primary);
    color: #fff;
}

.global-search-item .gs-title {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.global-search-item .gs-detail {
    font-size: 0.72rem;
    color: var(--gray-400);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Breadcrumbs (B2) ────────────────────────────────────── */
.top-bar .breadcrumb {
    margin: 0;
    font-size: 0.875rem;
    --bs-breadcrumb-divider-color: var(--gray-300);
}

.top-bar .breadcrumb-item a {
    color: var(--gray-500);
    text-decoration: none;
    font-weight: 500;
}

.top-bar .breadcrumb-item a:hover { color: var(--primary); }

.top-bar .breadcrumb-item.active {
    color: var(--gray-900);
    font-weight: 600;
}

/* ── Toasts (B3) ─────────────────────────────────────────── */
.kronos-toast {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: #fff;
    min-width: 320px;
    font-size: 0.85rem;
}

.kronos-toast .toast-icon { font-size: 1rem; }
.kronos-toast.toast-success { border-left: 3px solid var(--success); }
.kronos-toast.toast-success .toast-icon { color: var(--success); }
.kronos-toast.toast-danger { border-left: 3px solid var(--danger); }
.kronos-toast.toast-danger .toast-icon { color: var(--danger); }
.kronos-toast.toast-warning { border-left: 3px solid var(--warning); }
.kronos-toast.toast-warning .toast-icon { color: var(--warning); }
.kronos-toast.toast-info { border-left: 3px solid var(--info); }
.kronos-toast.toast-info .toast-icon { color: var(--info); }

/* ── Loading states (B4) ─────────────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn-loading .spinner-border {
    width: 0.9rem;
    height: 0.9rem;
    border-width: 2px;
    margin-right: 0.4rem;
}

.content-area {
    animation: pageIn 0.2s ease-out;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Autocomplete generico (cliente/produto em formularios) - mesmo destaque
   de selecao por teclado da busca global (.global-search-item.selected) */
.list-group-item[data-autocomplete-item].selected {
    background: var(--primary-light);
    color: var(--gray-900);
}

/* Table action icon buttons */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.btn-table-action:hover {
    background: #eff6ff;
    color: var(--primary);
}

.btn-table-action.danger:hover {
    background: #fef2f2;
    color: #ef4444;
}

.btn-table-action.success:hover {
    background: #f0fdf4;
    color: #22c55e;
}
