:root {
    --ink: #17202a;
    --muted: #687481;
    --line: #dfe5e9;
    --line-strong: #cbd6dd;
    --soft: #f3f6f7;
    --surface: #fbfdfe;
    --white: #fff;
    --navy: #16324f;
    --teal: #087f8c;
    --teal-dark: #066873;
    --teal-soft: #e7f5f6;
    --green: #157347;
    --green-soft: #e8f6ef;
    --red: #b42318;
    --red-soft: #fff0ee;
    --amber: #946200;
    --amber-soft: #fff7df;
    --violet: #6941c6;
    --radius: 12px;
    --shadow: 0 8px 30px rgba(22, 50, 79, .08);
    --shadow-strong: 0 12px 34px rgba(22, 50, 79, .12);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: linear-gradient(180deg, #eef4f6 0, #f7f9fa 260px, var(--soft) 100%);
    color: var(--ink);
    font: 13px/1.45 Inter, Arial, sans-serif;
}
button, input, select { font: inherit; }
a { color: inherit; }

.topbar {
    height: 86px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line-strong);
    box-shadow: 0 5px 18px rgba(22, 50, 79, .06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.brand { display: flex; align-items: center; gap: 18px; text-decoration: none; }
.brand img { display: block; width: 236px; max-width: 52vw; height: auto; object-fit: contain; }
.brand span { border-left: 1px solid var(--line); padding-left: 18px; display: grid; }
.brand strong { font-size: 15px; letter-spacing: -.2px; }
.brand small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-weight: 600; }

.app-layout { display: block; min-height: calc(100vh - 86px); }

.content { padding: 24px; min-width: 0; }
.upload-card, .import-header, .progress-card, .table-card {
    background: var(--white);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-strong);
}
.upload-card { padding: 22px; display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr); gap: 26px; align-items: center; margin-bottom: 18px; background: linear-gradient(135deg, #fff 0%, #f8fcfc 100%); border-left: 4px solid rgba(8,127,140,.45); }
.upload-card h1, .import-header h2 { margin: 2px 0 6px; font-size: 22px; letter-spacing: -.6px; }
.upload-card p, .import-header p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--teal) !important; text-transform: uppercase; letter-spacing: .9px; font-size: 10px; font-weight: 700; }
.upload-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }
.drop-zone {
    min-height: 82px;
    border: 1.5px dashed #9ab6bb;
    background: #f8fcfc;
    border-radius: 10px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 34px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-content: center;
    cursor: pointer;
    transition: .15s ease;
}
.drop-zone:hover, .drop-zone.dragging, .drop-zone.has-file { border-color: var(--teal); background: var(--teal-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { grid-row: 1 / 3; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--teal-soft); color: var(--teal); font-size: 20px; font-weight: 700; }
.drop-zone strong { align-self: end; }
.drop-zone small { color: var(--muted); font-size: 10px; }

.btn { border: 0; border-radius: 8px; padding: 9px 14px; text-decoration: none; cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { color: var(--navy); background: #fff; border: 1px solid #b8c4ce; }
.btn-secondary:hover { background: #f6f8fa; }
.btn-quiet { color: var(--muted); background: transparent; border: 1px solid var(--line); padding: 7px 11px; }
.btn-wide { width: 100%; }

.alert { padding: 12px 14px; border-radius: 9px; margin: 0 0 16px; border: 1px solid; }
.alert-error { color: var(--red); background: var(--red-soft); border-color: #fac5bf; }
.alert-success { color: var(--green); background: var(--green-soft); border-color: #b7e2cc; }

.import-header { padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; gap: 18px; background: linear-gradient(135deg, #fff 0%, #f8fbfc 100%); border-left: 4px solid rgba(22,50,79,.28); }
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions form { margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.metrics article { position: relative; overflow: hidden; background: linear-gradient(180deg, #fff 0%, var(--surface) 100%); border: 1px solid var(--line-strong); border-radius: 10px; padding: 15px 17px; box-shadow: 0 6px 18px rgba(22,50,79,.07); }
.metrics article::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: #d9e5ea; }
.metrics span, .metrics small { display: block; color: var(--muted); }
.metrics strong { display: block; margin: 5px 0 2px; font-size: 25px; letter-spacing: -.8px; color: var(--navy); }
.metrics small { font-size: 10px; }
.metrics .metric-success strong { color: var(--green); }
.metrics .metric-error strong { color: var(--red); }
.metrics .metric-success::before { background: var(--green); }
.metrics .metric-error::before { background: var(--red); }

.progress-card { padding: 16px 18px; margin-bottom: 14px; background: linear-gradient(180deg, #fff 0%, #f9fbfc 100%); }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.progress-copy div { display: grid; gap: 2px; }
.progress-copy span, .process-message { color: var(--muted); font-size: 11px; }
.progress-copy b { color: var(--teal); }
.progress-track { height: 8px; background: #e8edf0; border-radius: 9px; overflow: hidden; margin-top: 11px; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #28aeb8); transition: width .25s ease; }
.progress-card.is-running .progress-track span { background-size: 30px 30px; animation: pulsebar 1s linear infinite; }
.process-message { margin: 8px 0 0; }
@keyframes pulsebar { 50% { filter: brightness(1.15); } }

.table-card { overflow: hidden; background: #fff; }
.table-toolbar { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-strong); background: linear-gradient(180deg, #fff 0%, #f9fbfc 100%); }
.table-toolbar h3 { margin: 0 0 2px; font-size: 14px; }
.table-toolbar p { margin: 0; color: var(--muted); font-size: 10px; }
.filter-form { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.filter-form select,
.filter-form input[type="search"] { border: 1px solid #aebdc7; border-radius: 7px; background: #fff; padding: 7px 30px 7px 10px; color: var(--ink); }
.filter-form input[type="search"] { width: 245px; max-width: 100%; padding-right: 10px; }
.filter-form select:focus,
.filter-form input[type="search"]:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,140,.12); }
.filter-button { padding: 7px 11px; color: #fff; background: var(--navy); }
.clear-filters { color: var(--teal); font-size: 10px; font-weight: 700; text-decoration: none; }
.table-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.state-tabs { display: flex; padding: 3px; border-radius: 8px; background: #e7edf1; border: 1px solid #d7e1e7; }
.state-tabs a { padding: 5px 9px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 10px; font-weight: 700; }
.state-tabs a.active { background: #fff; color: var(--teal); box-shadow: 0 1px 4px rgba(22,50,79,.12); }
.review-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 18px; background: #f3f7f9; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 11px; box-shadow: inset 0 1px 0 rgba(255,255,255,.85); }
.review-actions > div { display: flex; gap: 7px; }
.btn-send { color: #fff; background: var(--green); }
.btn-send:hover { background: #0f603a; }
.btn-discard { color: #fff; background: var(--red); }
.btn-discard:hover { background: #8f1c14; }
.btn-check-sf { color: #fff; background: var(--violet); }
.btn-check-sf:hover { background: #5736a8; }
.btn-retry { color: #fff; background: var(--amber); }
.btn-retry:hover { background: #765000; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 1480px; table-layout: fixed; }
th { background: #eaf0f3; color: #3f5363; text-align: left; padding: 9px 10px; text-transform: uppercase; font-size: 9px; letter-spacing: .5px; border-bottom: 1px solid var(--line-strong); }
td { padding: 10px; border-bottom: 1px solid #e6ecef; vertical-align: top; font-size: 11px; word-break: break-word; }
tbody tr:nth-child(even) { background: #fbfdfe; }
tbody tr:hover { background: #eef8f9; box-shadow: inset 3px 0 0 var(--teal); }
th:nth-child(1) { width: 34px; }
th:nth-child(2) { width: 48px; }
th:nth-child(3) { width: 180px; }
th:nth-child(4) { width: 92px; }
th:nth-child(5) { width: 170px; }
th:nth-child(6) { width: 135px; }
th:nth-child(7) { width: 126px; }
th:nth-child(8), th:nth-child(9) { width: 88px; }
th:nth-child(10) { width: 105px; }
th:nth-child(11) { width: 110px; }
th:nth-child(12) { width: 154px; }
th:nth-child(13) { width: 92px; }
th:nth-child(14) { width: 58px; }
.check-col { text-align: center; }
.check-col input { accent-color: var(--teal); cursor: pointer; }
td small, .primary-cell small { display: block; color: var(--muted); font-size: 9px; margin-top: 3px; }
.primary-cell { font-weight: 600; }
.mono { font-family: Consolas, 'Courier New', monospace; font-size: 10px; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 7px; font-size: 9px; font-weight: 700; border: 1px solid transparent; }
.badge-enviada { color: var(--green); background: var(--green-soft); border-color: #b7e2cc; }
.badge-enviada_alerta { color: var(--amber); background: var(--amber-soft); border-color: #efd58c; }
.badge-descartada { color: var(--red); background: var(--red-soft); border-color: #fac5bf; }
.badge-error, .badge-invalida { color: var(--red); background: var(--red-soft); border-color: #fac5bf; }
.badge-pendiente { color: var(--amber); background: var(--amber-soft); border-color: #efd58c; }
.badge-procesando { color: var(--teal); background: var(--teal-soft); border-color: #b6dde2; }
.badge-revisar { color: var(--violet); background: #f0ebff; border-color: #d6c8ff; }
.row-actions { width: 88px; min-width: 88px; vertical-align: middle; }
.action-menu > summary {
    list-style: none;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 5px 7px;
    color: var(--navy);
    background: #f5f8fa;
    font-size: 9px;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(22,50,79,.06);
}
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu > summary::after { content: ' ▾'; color: var(--muted); }
.action-menu[open] > summary { border-color: var(--teal); background: var(--teal-soft); }
.action-menu-panel { display: grid; gap: 4px; padding-top: 5px; }
.mini-action { width: 100%; border: 0; border-radius: 5px; padding: 4px 6px; color: #fff; cursor: pointer; font-size: 9px; font-weight: 700; }
.mini-action.send { background: var(--green); }
.mini-action.discard { background: var(--red); }
.mini-action.reactivate { background: var(--teal); }
.mini-action.check-sf { background: var(--violet); }
.mini-action.retry { background: var(--amber); }
.sf-check-cell { display: flex; flex-direction: column; align-items: stretch; gap: 5px; }
td.sf-check-cell { background: #f8fbfc; border-left: 1px solid #e1e9ed; border-right: 1px solid #e1e9ed; }
tbody tr:hover td.sf-check-cell { background: #e9f7f8; }
.sf-check-cell small { margin: 1px 0 0; }
.sf-not-checked, .sf-query-error {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 25px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
}
.sf-not-checked { color: #5f6f7d; background: #eef3f6; border: 1px solid #d3dee5; }
.sf-query-error { color: var(--red); background: var(--red-soft); border: 1px solid #fac5bf; }
.sf-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 5px 7px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    border: 1px solid transparent;
}
.sf-result-label { color: #4f5f6c; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; }
.sf-result-value { white-space: nowrap; }
.sf-result.yes { color: var(--green); background: #ecf8f1; border-color: #b7e2cc; }
.sf-result.no { color: var(--amber); background: #fff8e4; border-color: #efd58c; }
.sf-check-date { align-self: flex-end; color: #5f6f7d !important; font-size: 9px !important; font-weight: 700; }
.responsible-cell { display: flex; flex-direction: column; gap: 1px; }
.responsible-label { color: #4f5f6c; font-size: 9px; text-transform: uppercase; letter-spacing: .35px; }
.responsible-value { font-weight: 700; }
details { position: relative; }
summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.row-detail { position: absolute; right: 0; top: 24px; z-index: 8; width: 330px; padding: 12px; display: grid; grid-template-columns: 84px 1fr; gap: 6px 9px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.row-detail b { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.error-text { color: var(--red); }
.empty-row { text-align: center; color: var(--muted); padding: 28px; }
.pagination { display: flex; gap: 5px; padding: 12px 16px; justify-content: center; }
.pagination a { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; display: grid; place-items: center; }
.pagination a.active { color: #fff; background: var(--teal); border-color: var(--teal); }

.log-metrics { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
.log-filter-card { margin-bottom: 14px; }
.log-filter-form { justify-content: flex-start; }
.log-filter-form > span { color: var(--navy); margin-right: 4px; }
.log-filter-form small { color: var(--muted); font-size: 10px; }
.log-card { margin-top: 14px; }
.log-table { min-width: 1460px; }
.log-table th:nth-child(1) { width: 132px; }
.log-table th:nth-child(2) { width: 96px; }
.log-table th:nth-child(3) { width: 180px; }
.log-table th:nth-child(4) { width: 240px; }
.log-table th:nth-child(5) { width: 130px; }
.log-table th:nth-child(6), .log-table th:nth-child(7) { width: 150px; }
.log-table th:nth-child(8) { width: 360px; }
.event-log-table { min-width: 1320px; }
.event-log-table th:nth-child(1) { width: 132px; }
.event-log-table th:nth-child(2) { width: 130px; }
.event-log-table th:nth-child(3) { width: 95px; }
.event-log-table th:nth-child(4) { width: 96px; }
.event-log-table th:nth-child(5) { width: 260px; }
.event-log-table th:nth-child(6) { width: 135px; }
.event-log-table th:nth-child(7) { width: 470px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: #102a43; }
.login-shell { width: min(920px, 100%); min-height: 540px; background: #fff; display: grid; grid-template-columns: .9fr 1.1fr; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.login-panel { padding: 52px 46px; align-self: center; }
.brand-mark img { display: block; width: 236px; max-width: 100%; height: auto; object-fit: contain; }
.login-panel h1 { font-size: 28px; letter-spacing: -1px; margin: 22px 0 4px; }
.login-copy { color: var(--muted); margin: 0 0 24px; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 6px; color: #46525d; font-weight: 600; font-size: 11px; }
.login-form input { width: 100%; border: 1px solid #bdc7ce; border-radius: 8px; padding: 11px 12px; color: var(--ink); }
.login-form input:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,140,.13); }
.login-aside { padding: 58px; color: #fff; background: linear-gradient(145deg, #087f8c 0%, #16324f 80%); display: flex; flex-direction: column; justify-content: space-between; }
.aside-kicker { font-size: 10px; letter-spacing: 1.4px; opacity: .7; font-weight: 700; }
.login-aside h2 { font-size: 34px; line-height: 1.1; letter-spacing: -1.4px; margin: 28px 0 16px; }
.login-aside p { color: #d5eef0; max-width: 390px; }
.aside-note { font-size: 11px; opacity: .7; }

@media (max-width: 900px) {
    .upload-card { grid-template-columns: 1fr; }
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .login-shell { grid-template-columns: 1fr; }
    .login-aside { display: none; }
}
@media (max-width: 600px) {
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
    .brand span { display: none; }
    .topbar-user > span { display: none; }
    .upload-form { grid-template-columns: 1fr; }
    .import-header { align-items: flex-start; flex-direction: column; }
    .table-tools, .review-actions { align-items: stretch; flex-direction: column; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .login-page { padding: 14px; }
    .login-panel { padding: 38px 26px; }
}
