@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* Variables del componente */
.ac-scope {
    --ac-surface:      #ffffff;
    --ac-surface2:     #f3f4f6;
    --ac-border:       #e0e0e6;
    --ac-text:         #1f2933;
    --ac-muted:        #6b7280;
    --ac-critical:     #A70305;
    --ac-critical-bg:  #fff0f0;
    --ac-critical-dim: #f5c0c0;
    --ac-ok:           #16a34a;
    --ac-ok-bg:        #e8f5ee;
}

.ac-root {
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    color: var(--ac-text);
    min-height: calc(100vh - 60px);
    padding: 28px;
    max-width: 100vw;
    margin: 0 auto;
}

/* ── Summary bar ─────────────────────────────────────── */
.ac-summary {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
    animation: ac-fadeup .35s ease;
}
.ac-sum-block { display: flex; flex-direction: column; }
.ac-sum-label {
    font-size: 12px; color: var(--ac-muted);
    letter-spacing: .06em; text-transform: uppercase;
    margin-bottom: 2px;
}
.ac-sum-num {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 32px; font-weight: 500;
    color: var(--ac-critical);
    line-height: 1;
}
.ac-sum-divider { width: 1px; height: 40px; background: var(--ac-border); }
.ac-sum-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--ac-muted);
}
.ac-sum-status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--ac-ok);
    animation: ac-blink 3s ease-in-out infinite;
}

/* ── Section title ───────────────────────────────────── */
.ac-section-title {
    font-size: 11px; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}
.ac-section-title.crit { color: var(--ac-critical); }
.ac-section-title.ok   { color: var(--ac-ok); }
.ac-line-short { width: 16px; height: 1px; background: currentColor; flex-shrink: 0; }
.ac-line-long  { flex: 1; height: 1px; background: var(--ac-border); }

/* ── Critical card ───────────────────────────────────── */
.ac-grid-crit {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}
.ac-card-crit {
    position: relative;
    background: var(--ac-critical-bg);
    border: 1px solid var(--ac-critical-dim);
    border-radius: 12px;
    padding: 20px 24px;
    display: flex; flex-direction: column; gap: 12px;
    cursor: pointer; overflow: hidden;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
    animation: ac-fadeup .4s ease both;
}
.ac-card-crit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(167,3,5,.12), 0 8px 24px rgba(0,0,0,.08);
}
.ac-pulsedot {
    position: absolute; top: 18px; right: 18px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--ac-critical);
    animation: ac-pulse 2s ease-out infinite, ac-blink 2s ease-in-out infinite;
}
.ac-tag-crit {
    font-size: 11px; font-weight: 600;
    letter-spacing: .1em; color: var(--ac-critical);
    text-transform: uppercase; margin-bottom: 4px;
}
.ac-card-name {
    font-size: 13px; font-weight: 500;
    color: var(--ac-muted); line-height: 1.3;
}
.ac-bignum {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 52px; font-weight: 500;
    line-height: 1; color: var(--ac-text);
    animation: ac-countup .35s ease;
}
.ac-divs { display: flex; gap: 6px; flex-wrap: wrap; }
.ac-divpill {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px;
    background: #4a1414; color: #ffd9d9;
    border-radius: 4px;
    letter-spacing: .02em;
}
.ac-detail-btn {
    font-size: 12px; font-weight: 600;
    padding: 6px 14px;
    background: var(--ac-critical); color: #fff;
    border: none; border-radius: 6px;
    cursor: pointer; letter-spacing: .04em;
    transition: opacity .15s;
}
.ac-detail-btn:hover { opacity: .85; }
.ac-trend-btn {
    width: 30px; height: 30px;
    background: #fff; color: var(--ac-critical);
    border: 1px solid var(--ac-critical-dim);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.ac-trend-btn:hover { background: var(--ac-critical); color: #fff; }

/* ── OK card ─────────────────────────────────────────── */
.ac-grid-ok {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
.ac-card-ok {
    background: var(--ac-surface);
    border: 1px solid var(--ac-border);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex; align-items: center; gap: 14px;
    transition: border-color .15s, box-shadow .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    animation: ac-fadeup .4s ease both;
    cursor: pointer;
}
.ac-card-ok:hover { border-color: var(--ac-ok); }
.ac-ok-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--ac-ok-bg);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ac-ok-body { flex: 1; min-width: 0; }
.ac-ok-label {
    font-size: 13px; font-weight: 500; color: var(--ac-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-ok-sub { font-size: 11px; color: var(--ac-ok); margin-top: 2px; }
.ac-ok-num {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 20px; font-weight: 500;
    color: var(--ac-muted); flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════
   SfDialog — Detalle y Tendencias
   ════════════════════════════════════════════════════════ */
.ac-sf-dialog .e-dlg-header-content,
.ac-sf-dialog .e-dlg-content,
.ac-sf-dialog .e-footer-content {
    font-family: 'Space Grotesk', system-ui, sans-serif;
}
.ac-sf-dialog .e-dlg-header-content {
    padding: 18px 22px !important;
    border-bottom: 1px solid #ececec;
}
.ac-sf-dialog .e-dlg-content { padding: 18px 22px !important; }

/* Limitar altura del modal y permitir scroll interno */
.ac-sf-dialog.e-dialog,
.ac-sf-dialog .e-dialog {
    max-height: 80vh !important;
    display: flex !important;
    flex-direction: column !important;
}
.ac-sf-dialog .e-dlg-content {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
}

/* Header custom */
.ac-dlg-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    width: 100%; gap: 16px;
}
.ac-dlg-head-left { display: flex; gap: 14px; align-items: center; }
.ac-dlg-icon-box {
    width: 44px; height: 44px;
    background: #2a0808;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #ff6b6b;
    font-size: 22px;
    flex-shrink: 0;
}
.ac-icon-box-trend { background: #1a3a2a; color: #6ee7a7; }
.ac-dlg-tag {
    font-size: 11px; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
    color: #A70305;
}
.ac-dlg-title {
    font-size: 18px; font-weight: 700;
    color: #1f2933; line-height: 1.2;
    margin-top: 2px;
}
.ac-dlg-head-right { text-align: right; line-height: 1; }
.ac-dlg-bignum {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 32px; font-weight: 500;
    color: #A70305;
    line-height: 1;
}
.ac-dlg-bignum-sub {
    font-size: 11px; color: #6b7280;
    text-transform: lowercase; margin-top: 4px;
}

/* Tabla del modal de detalle */
.ac-dlg-table-wrap {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid #ececec;
    border-radius: 8px;
}
.ac-dlg-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
.ac-dlg-table thead th.num,
.ac-dlg-table tbody td.num { text-align: right; }
.ac-dlg-table tbody td.num b {
    font-family: 'DM Mono', ui-monospace, monospace;
    color: #A70305; font-weight: 600;
}

/* Pill de tipo de viaje */
.ac-trip-pill {
    display: inline-block;
    font-size: 10.5px; font-weight: 700;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}
.ac-trip-pill.trip-cs   { background: #e0eefb; color: #1d4ed8; }
.ac-trip-pill.trip-auto { background: #fef3c7; color: #92400e; }
.ac-trip-pill.trip-na   { background: #f3f4f6; color: #6b7280; }

.ac-dlg-table thead th {
    text-align: left;
    font-size: 11px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: #6b7280;
    padding: 8px 10px;
    border-bottom: 1px solid #ececec;
    background: #fafafa;
}
.ac-dlg-table tbody td {
    padding: 12px 10px;
    border-bottom: 1px solid #f3f3f3;
    color: #1f2933;
    vertical-align: middle;
}
.ac-dlg-table tbody tr:hover td { background: #fffafa; }
.ac-dlg-id {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 12px; font-weight: 600;
    color: #A70305;
}
.ac-dlg-time { color: #6b7280; font-size: 12px; }

.ac-empty {
    color: #6b7280; font-size: 13px;
    text-align: center; padding: 24px;
}

/* ── Modal de Tendencias ─────────────────────────────── */
.ac-trend-chart {
    background: #fafafa;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.ac-trend-stats {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.ac-trend-stats > div {
    background: #fafafa;
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
}
.ac-stat-label {
    font-size: 10px; font-weight: 700;
    color: #6b7280;
    letter-spacing: .08em; text-transform: uppercase;
    margin-bottom: 4px;
}
.ac-stat-val {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: 22px; font-weight: 500;
    color: #1f2933;
    line-height: 1;
}
.ac-stat-current { color: #A70305; }

.ac-trend-grid-label {
    font-size: 11px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: #6b7280; margin-bottom: 8px;
}
.ac-trend-grid-wrap {
    max-height: 280px; overflow-y: auto;
    border: 1px solid #ececec;
    border-radius: 8px;
}
.ac-trend-grid {
    width: 100%; border-collapse: collapse;
    font-size: 12px;
}
.ac-trend-grid thead th {
    position: sticky; top: 0;
    background: #fafafa;
    text-align: left;
    font-size: 10px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase;
    color: #6b7280;
    padding: 8px 12px;
    border-bottom: 1px solid #ececec;
    z-index: 1;
}
.ac-trend-grid thead th.num { text-align: right; }
.ac-trend-grid tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f3f3;
    color: #1f2933;
}
.ac-trend-grid tbody td.num {
    font-family: 'DM Mono', ui-monospace, monospace;
    text-align: right;
    color: #6b7280;
}
.ac-trend-grid tr.has-val td.num b { color: #A70305; font-weight: 600; }
.ac-trend-grid tbody tr:hover td   { background: #fffafa; }

/* ── Animations ──────────────────────────────────────── */
@keyframes ac-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(167,3,5,.5); }
    70%  { box-shadow: 0 0 0 12px rgba(167,3,5,0); }
    100% { box-shadow: 0 0 0 0 rgba(167,3,5,0); }
}
@keyframes ac-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: .35; }
}
@keyframes ac-fadeup {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes ac-countup {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
