/*
 * Stratum Retainers — backend module styles.
 *
 * Uses Contao's theme CSS variables (--text, --gray, --border, --red,
 * --table-even) so the screen adapts to light and dark schemes.
 */

/* Contao's .content wraps every backend module, so these are scoped with
   :has() to pad only the two retainer screens rather than the whole
   backend. Browsers without :has() simply skip the rule — no padding,
   nothing broken. */
.content:has(.stratum-retainers),
.content:has(.stratum-retainer-detail) {
    padding: 20px;
}

/* ── Period navigation ──────────────────────────────────────────── */
.rt-periodbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.rt-period-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    min-width: 10em;
    text-align: center;
}

.rt-period-nav,
.rt-period-today {
    padding: 3px 10px;
    border: 1px solid var(--form-border);
    border-radius: var(--border-radius, 3px);
    background: var(--form-button);
    color: var(--text);
    font-size: 0.8rem;
    text-decoration: none;
}

.rt-period-nav:hover,
.rt-period-today:hover {
    background: var(--form-button-hover);
}

.rt-period-today {
    margin-left: 6px;
}

/* ── Alerts / empty state ───────────────────────────────────────── */
.rt-alert {
    margin: 0 0 12px;
    padding: 7px 11px;
    border-left: 3px solid var(--red, #c1272d);
    background: color-mix(in srgb, var(--red, #c1272d) 8%, transparent);
    color: var(--red, #c1272d);
    font-size: 0.85rem;
    font-weight: 600;
}

.rt-empty {
    margin: 18px 0;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius-lg, 6px);
    color: var(--gray);
    font-size: 0.9rem;
}

/* ── Table ──────────────────────────────────────────────────────── */
.rt-table {
    width: 100%;
    border-collapse: collapse;
}

.rt-table th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray);
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
}

.rt-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text);
    vertical-align: middle;
}

.rt-col-client {
    font-weight: 600;
}

/* Drill-down into the month's detail. Underlined on hover only, so a
   column of client names doesn't read as a wall of links. */
.rt-client-link {
    color: var(--text);
    text-decoration: none;
}

.rt-client-link:hover {
    color: var(--blue);
    text-decoration: underline;
}

.rt-col-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 8em;
}

.rt-col-usage {
    width: 30%;
    white-space: nowrap;
}

.rt-row.is-over td {
    background: color-mix(in srgb, var(--red, #c1272d) 6%, transparent);
}

.rt-over {
    color: var(--red, #c1272d);
    font-weight: 700;
}

/* ── Usage bar ──────────────────────────────────────────────────── */
.rt-bar {
    display: inline-block;
    width: 60%;
    height: 8px;
    margin-right: 8px;
    border-radius: 4px;
    background: var(--table-even, #eef2f7);
    overflow: hidden;
    vertical-align: middle;
}

.rt-bar-fill {
    display: block;
    height: 100%;
    background: var(--teal, #0f766e);
}

.rt-bar-fill.is-gold { background: var(--gold, #b8860b); }
.rt-bar-fill.is-orange { background: var(--orange, #e67e22); }
.rt-bar-fill.is-over {
    background: var(--red, #c1272d);
}

/* Row tinting for the shared band scale (gold 75%, orange 85%, red over) */
.rt-row.is-gold td {
    background: color-mix(in srgb, var(--gold, #b8860b) 7%, transparent);
}
.rt-row.is-orange td {
    background: color-mix(in srgb, var(--orange, #e67e22) 8%, transparent);
}

.rt-pct {
    font-size: 0.78rem;
    color: var(--gray);
    font-variant-numeric: tabular-nums;
}

.rt-row-total td {
    background: var(--table-even, #f8f8f8);
    border-bottom: none;
}

.rt-note {
    margin-top: 14px;
    color: var(--gray);
    font-size: 0.78rem;
    line-height: 1.5;
}

/* ── Retainer detail (one client, one month) ────────────────────── */

.rd-headerbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.rd-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.rd-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 18px;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-left: 4px solid var(--green, #2e7d32);
    border-radius: var(--border-radius, 3px);
    background: var(--table-even, #eef2f7);
    font-size: 0.9rem;
    color: var(--text);
}

.rd-summary.is-gold { border-left-color: var(--gold, #b8860b); }
.rd-summary.is-orange { border-left-color: var(--orange); }
.rd-summary.is-over { border-left-color: var(--red); }

.rd-pct {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--gray);
}

.rd-over {
    color: var(--red);
    font-weight: 700;
}

.rd-empty {
    margin: 18px 0;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius-lg, 6px);
    color: var(--gray);
    font-size: 0.9rem;
}

.rd-grandtotal {
    display: flex;
    align-items: baseline;
    gap: 18px;
    justify-content: flex-end;
    padding: 10px 14px;
    margin-top: 12px;
    border-top: 2px solid var(--border);
    font-size: 0.95rem;
    color: var(--text);
}

.rd-note {
    margin-top: 14px;
    color: var(--gray);
    font-size: 0.8rem;
    line-height: 1.5;
}

.rd-note a {
    color: var(--blue);
}
