/* ============================================================================
   Controle de Ruptura — Extrato
   Reaproveita os tokens de :root definidos em styles.css.
   ========================================================================= */

.cr-hero {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; flex-wrap: wrap; margin-bottom: 20px;
}
.cr-hero-main h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); letter-spacing: -0.02em; }
.cr-hero-main p  { font-size: 13px; color: var(--gray-600); margin-top: 4px; max-width: 62ch; }
.cr-hero-actions { display: flex; align-items: center; gap: 12px; }

.cr-sync {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; color: var(--gray-500); white-space: nowrap;
}
.cr-sync-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 0 3px rgba(63, 184, 104, 0.15);
    animation: crPulse 2s ease-in-out infinite;
}
.cr-sync.is-erro { color: var(--error); }
.cr-sync.is-erro .cr-sync-dot {
    background: var(--error); box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.15); animation: none;
}
@keyframes crPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.cr-btn-export {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 15px; border: 1px solid var(--border-default); border-radius: var(--radius-md);
    background: var(--bg-card); color: var(--gray-800);
    font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
    transition: all 0.15s ease; box-shadow: var(--shadow-xs);
}
.cr-btn-export:hover { border-color: var(--primary-600); color: var(--primary-800); box-shadow: var(--shadow-sm); }

/* ── KPIs ── */
.cr-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.cr-kpi {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
    box-shadow: var(--shadow-xs); border-left: 3px solid var(--gray-300);
}
.cr-kpi.is-alerta { border-left-color: var(--error); }
.cr-kpi.is-ok     { border-left-color: var(--success); }
.cr-kpi-val { font-size: 24px; font-weight: 700; color: var(--gray-900); letter-spacing: -0.02em; line-height: 1.1; }
.cr-kpi-lbl { font-size: 11.5px; color: var(--gray-500); font-weight: 500; }

/* ── Toolbar ── */
.cr-card { padding: 0; overflow: visible; }
.cr-toolbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.cr-search {
    flex: 1 1 260px; max-width: 340px; padding: 9px 13px;
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    font-family: inherit; font-size: 13px; color: var(--gray-900); background: var(--bg-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-search:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(61, 109, 181, 0.12); }
.cr-toggle {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12.5px; color: var(--gray-700); cursor: pointer; user-select: none;
}
.cr-toggle input { width: 15px; height: 15px; accent-color: var(--primary-600); cursor: pointer; }

/* ── Tabela ── */
.cr-table-wrap { overflow-x: auto; }
.cr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cr-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--gray-50); color: var(--gray-600);
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border-default); white-space: nowrap;
}
.cr-table thead th.num { text-align: right; }
.cr-table thead th small { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: 0.75; }
.cr-table thead th.cr-th-acao { width: 320px; }
.cr-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.cr-table tbody td.num { text-align: right; }
.cr-table tbody tr:hover { background: var(--gray-50); }
.cr-table tbody tr.is-quitado { opacity: 0.62; }

.cr-cd-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 600; color: var(--gray-900);
    text-align: left; border-bottom: 1px dashed var(--gray-300); transition: color 0.15s ease;
}
.cr-cd-btn:hover { color: var(--primary-600); border-bottom-color: var(--primary-600); }
.cr-table td.num small {
    display: block; font-size: 10.5px; color: var(--gray-500); font-weight: 400; margin-top: 3px;
}
.cr-rede {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    background: var(--gray-100); color: var(--gray-700);
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.cr-giro {
    font-size: 14px; font-weight: 700; color: var(--primary-800);
    font-variant-numeric: tabular-nums;
}
.cr-estoque { font-size: 14px; font-weight: 600; color: var(--gray-800); font-variant-numeric: tabular-nums; }
.cr-estoque.is-zero { color: var(--error); }
.cr-saldo { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.cr-saldo.is-alerta { color: var(--error); }
.cr-saldo.is-ok     { color: var(--success); }
.cr-excedente { color: var(--warning) !important; font-weight: 600 !important; }
.cr-liberado { font-size: 14px; font-weight: 600; color: var(--gray-700); font-variant-numeric: tabular-nums; }

/* ── Acao (input + botoes) ── */
.cr-acao-row { display: flex; align-items: center; gap: 6px; }
.cr-input {
    width: 88px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600; text-align: right;
    color: var(--gray-900); background: var(--bg-card); font-variant-numeric: tabular-nums;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-input:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px rgba(61, 109, 181, 0.12); }
.cr-input:disabled { background: var(--gray-100); color: var(--gray-400); }
.cr-input::-webkit-outer-spin-button,
.cr-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cr-input[type=number] { -moz-appearance: textfield; }

.cr-btn-tudo, .cr-btn-liberar {
    padding: 8px 13px; border-radius: var(--radius-sm); font-family: inherit;
    font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.15s ease;
}
.cr-btn-tudo { border: 1px solid var(--border-default); background: var(--bg-card); color: var(--gray-600); }
.cr-btn-tudo:hover:not(:disabled) { border-color: var(--primary-600); color: var(--primary-800); }
.cr-btn-liberar { border: 1px solid var(--primary-800); background: var(--primary-800); color: #fff; }
.cr-btn-liberar:hover:not(:disabled) {
    background: var(--primary-950); border-color: var(--primary-950); box-shadow: var(--shadow-sm);
}
.cr-btn-tudo:disabled, .cr-btn-liberar:disabled { opacity: 0.45; cursor: not-allowed; }

.cr-hint { font-size: 10.5px; margin-top: 5px; min-height: 14px; line-height: 1.35; }
.cr-hint.is-ok    { color: var(--success); }
.cr-hint.is-aviso { color: var(--warning); }
.cr-hint.is-erro  { color: var(--error); }
.cr-fix {
    background: none; border: none; padding: 0 2px; cursor: pointer; font-family: inherit;
    font-size: 10.5px; font-weight: 700; color: inherit; text-decoration: underline;
}

.cr-empty { padding: 40px 20px; text-align: center; color: var(--gray-500); font-size: 13px; }
.cr-foot {
    padding: 12px 20px; border-top: 1px solid var(--border-light);
    font-size: 11px; color: var(--gray-500); background: var(--gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.cr-foot code {
    font-size: 10.5px; background: var(--gray-100); padding: 1px 5px;
    border-radius: 4px; color: var(--gray-700);
}

/* ── Gaveta de historico ── */
.cr-drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 25, 0.35); z-index: 998; }
.cr-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 999;
    background: var(--bg-card); box-shadow: var(--shadow-xl);
    display: flex; flex-direction: column; animation: crSlideIn 0.2s ease;
}
@keyframes crSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.cr-drawer-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 20px; border-bottom: 1px solid var(--border-light);
}
.cr-drawer-head h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.cr-drawer-head p  { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.cr-drawer-close {
    background: none; border: none; font-size: 26px; line-height: 1; color: var(--gray-400);
    cursor: pointer; padding: 0 4px; transition: color 0.15s ease;
}
.cr-drawer-close:hover { color: var(--gray-800); }
.cr-drawer-body { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }
.cr-drawer-loading { padding: 24px 0; text-align: center; color: var(--gray-500); font-size: 12.5px; }
.cr-evento-wrap { border-bottom: 1px solid var(--border-light); }
.cr-evento-wrap .cr-evento { border-bottom: none; }
.cr-evento-hint { font-size: 10.5px; line-height: 1.35; padding: 0 0 9px 0; }
.cr-evento-hint:empty { padding: 0; }
.cr-evento-hint.is-erro { color: var(--error); }
.cr-efix {
    background: none; border: none; padding: 0 2px; cursor: pointer; font-family: inherit;
    font-size: 10.5px; font-weight: 700; color: inherit; text-decoration: underline;
}
.cr-evento {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid var(--border-light);
}
.cr-evento-qtd {
    font-size: 15px; font-weight: 700; color: var(--success);
    font-variant-numeric: tabular-nums; min-width: 56px;
}
.cr-evento-qtd.is-estorno { color: var(--error); }
.cr-evento-data { flex: 1; font-size: 11.5px; color: var(--gray-500); }
.cr-evento-del {
    background: none; border: none; font-size: 18px; line-height: 1; color: var(--gray-300);
    cursor: pointer; padding: 0 4px; transition: color 0.15s ease;
}
.cr-evento-del:hover { color: var(--error); }

@media (max-width: 820px) {
    .cr-hero { flex-direction: column; }
    .cr-table thead th.cr-th-acao { width: auto; }
    .cr-acao-row { flex-wrap: wrap; }
}

/* Edicao inline de um evento no historico */
.cr-evento-input {
    width: 76px; padding: 6px 8px; border: 1px solid var(--border-default);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    font-weight: 700; text-align: right; color: var(--gray-900);
    background: var(--bg-card); font-variant-numeric: tabular-nums;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-evento-input:focus {
    outline: none; border-color: var(--primary-600);
    box-shadow: 0 0 0 3px rgba(61, 109, 181, 0.12);
}
.cr-evento-input::-webkit-outer-spin-button,
.cr-evento-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cr-evento-input[type=number] { -moz-appearance: textfield; }
.cr-evento-data em {
    display: block; font-style: normal; font-size: 10px; color: var(--warning); margin-top: 1px;
}
.cr-evento-save {
    padding: 5px 10px; border: 1px solid var(--primary-800); border-radius: var(--radius-sm);
    background: var(--primary-800); color: #fff; font-family: inherit;
    font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.cr-evento-save:hover { background: var(--primary-950); border-color: var(--primary-950); }
.cr-evento-save[hidden] { display: none; }
