/* Portal MXW - Mibanco brand colors taken from logo-mibanco.svg */
:root {
    --mb-green: #009330;
    --mb-green-dark: #006e24;
    --mb-green-soft: #e6f4ea;
    --mb-yellow: #ffce00;
    --mb-yellow-soft: #fff6cc;
    --mb-text: #1f2a22;
    --mb-muted: #5f6b63;
    --mb-border: #dfe6e1;
    --mb-bg: #f5f7f5;
    --mb-white: #ffffff;
    --mb-grey: #9aa39d;
    --topbar-height: 60px;
}

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

html, body { height: 100%; }

body {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--mb-text);
    background: var(--mb-bg);
    line-height: 1.45;
}

[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--mb-white);
    border-bottom: 3px solid var(--mb-green);
    box-shadow: 0 2px 0 var(--mb-yellow);
    position: relative;
    z-index: 2;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-logo { height: 34px; width: auto; }
.brand-logo-whatsapp { height: 30px; }
.brand-divider { width: 1px; height: 30px; background: var(--mb-border); }
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--mb-green); }

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-link { color: var(--mb-green); font-weight: 600; text-decoration: none; }
.topbar-link:hover { text-decoration: underline; }
.topbar-user { color: var(--mb-muted); font-size: 0.9rem; }

/* ---------- buttons ---------- */
.btn {
    display: inline-block;
    border-radius: 8px;
    padding: 8px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 2px solid var(--mb-green);
}
.btn-primary { background: var(--mb-green); color: var(--mb-white); }
.btn-primary:hover { background: var(--mb-green-dark); border-color: var(--mb-green-dark); }

/* ---------- views ---------- */
.view { padding: 32px 24px; max-width: 1200px; margin: 0 auto; }
.view-center {
    min-height: calc(100vh - var(--topbar-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
}
h1 { font-size: 1.6rem; color: var(--mb-green-dark); }
.muted { color: var(--mb-muted); font-size: 0.9rem; }

.spinner {
    width: 44px;
    height: 44px;
    border: 5px solid var(--mb-green-soft);
    border-top-color: var(--mb-green);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home ---------- */
.home-title { margin-top: 24px; }
.home-subtitle { color: var(--mb-muted); margin: 4px 0 28px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 28px 24px 24px;
    background: var(--mb-white);
    border: 1px solid var(--mb-border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--mb-text);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 147, 48, 0.15); }
.card-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--mb-green) 70%, var(--mb-yellow) 70%);
}
.card-title { font-size: 1.15rem; font-weight: 700; color: var(--mb-green-dark); }
.card-text { color: var(--mb-muted); }
.card-note {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--mb-yellow-soft);
    color: var(--mb-text);
    font-size: 0.85rem;
}

/* Disabled tool: visible but not usable (the API also rejects the call). */
.card.is-disabled { cursor: not-allowed; background: #f1f3f2; border-style: dashed; }
.card.is-disabled:hover { transform: none; box-shadow: none; }
.card.is-disabled .card-accent { background: var(--mb-grey); }
.card.is-disabled .card-title { color: var(--mb-grey); }

/* ---------- dashboard ---------- */
body.is-dashboard .view-dashboard {
    max-width: none;
    padding: 0;
    height: calc(100vh - var(--topbar-height));
}
.dashboard-status { padding: 32px 24px; text-align: center; color: var(--mb-muted); }
.dashboard-frame { width: 100%; height: 100%; border: none; display: block; background: var(--mb-white); }

/* ---------- usage ---------- */
.usage-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin: 24px 0 12px; }
.summary-item {
    background: var(--mb-white);
    border: 1px solid var(--mb-border);
    border-left: 5px solid var(--mb-green);
    border-radius: 10px;
    padding: 14px 16px;
}
.summary-item.is-warning { border-left-color: var(--mb-yellow); }
.summary-value { font-size: 1.6rem; font-weight: 700; color: var(--mb-green-dark); }
.summary-label { color: var(--mb-muted); font-size: 0.85rem; }

.usage-status { color: var(--mb-muted); margin: 12px 0; }

/* The table grows one column per month: when it is wider than the view it scrolls
   horizontally inside its frame, and the user column stays fixed on the left. */
.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    background: var(--mb-white);
    border: 1px solid var(--mb-border);
    border-radius: 10px;
    margin-top: 20px;
}
.usage-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.92rem; }
.usage-table th {
    background: var(--mb-green);
    color: var(--mb-white);
    text-align: left;
    padding: 10px 12px;
    white-space: nowrap;
}
.usage-table td { padding: 9px 12px; border-top: 1px solid var(--mb-border); white-space: nowrap; background: var(--mb-white); }
.usage-table tbody tr:nth-child(even) td { background: #fafcfa; }
.usage-table th:first-child,
.usage-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 1px 0 0 var(--mb-border);
}
.usage-table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Must come after the even-row rule (same specificity). */
.usage-table tbody tr.is-monitor td { background: var(--mb-yellow-soft); font-weight: 700; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge-active { background: var(--mb-green-soft); color: var(--mb-green-dark); }
.badge-idle { background: var(--mb-yellow); color: var(--mb-text); }
.badge-never { background: #fde8d9; color: #8a3b00; }
.badge-removed { background: #e9ecea; color: var(--mb-muted); }
.badge-unmatched { background: #e9ecea; color: var(--mb-text); border: 1px dashed var(--mb-grey); }

.footnote { margin-top: 10px; }

@media (max-width: 640px) {
    .topbar { padding: 0 12px; }
    .topbar-user { display: none; }
    .brand { gap: 8px; }
    .brand-name { font-size: 0.95rem; }
    .view { padding: 20px 12px; }
}
