/* =========================================================
   BILANCIO ROMA — DESIGN BRIDGE
   Layer ponte tra classi legacy e design-system rm-*
   ========================================================= */

/* Base */
html, body {
    background: var(--rm-bg);
    color: var(--rm-text);
    font-family: var(--rm-font-body);
}

body {
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.wrap,
.page,
.page-wrap,
.subject-new-wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 18px 16px 40px;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .wrap,
    .page,
    .page-wrap,
    .subject-new-wrap {
        padding: 28px 24px 56px;
    }
}

/* Hero / topbar */
.hero,
.rm-hero {
    position: relative;
    border-radius: var(--rm-radius-lg);
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--rm-garnet-800), var(--rm-garnet-900) 72%);
    border: 1px solid var(--rm-border-strong);
    box-shadow: var(--rm-shadow-md);
    overflow: hidden;
    margin-bottom: 18px;
}

.hero::after,
.rm-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -60px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(217,164,65,.22), transparent 70%);
    pointer-events: none;
}

.hero h1,
.topbar h1,
.rm-topbar h1,
.subject-new-topbar h1 {
    font-family: var(--rm-font-display);
    font-weight: 600;
    letter-spacing: .01em;
    font-size: clamp(24px, 5vw, 36px);
    line-height: 1.12;
    margin: 0 0 8px;
    color: #fff;
}

.subtitle,
.hero .subtitle,
.rm-subtitle,
.subject-new-subtitle,
.season,
.footer-note,
.summary {
    color: var(--rm-text-dim);
    line-height: 1.55;
    font-size: 14px;
}

.topbar,
.rm-topbar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

@media (min-width: 700px) {
    .topbar,
    .rm-topbar {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
}

/* Grid cards */
.grid,
.rm-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 640px) {
    .grid,
    .rm-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid,
    .rm-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

.card, .rm-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border-radius: var(--rm-radius-md);
    background: linear-gradient(135deg, var(--rm-garnet-800), var(--rm-garnet-900) 72%);
    border: 1px solid var(--rm-border);
    text-decoration: none;
    color: var(--rm-text);
    transition: border-color .16s ease, transform .16s ease;
}

.card:active,
.rm-tile:active {
    transform: scale(.98);
}

@media (hover: hover) {
    .card:hover, .rm-tile:hover {
        border-color: rgba(217, 164, 65, .45);
        background: var(--rm-garnet-800);
        transform: translateY(-2px);
    }
}

.card .tag,
.rm-tile__tag {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--rm-gold-300);
    background: rgba(217,164,65,.1);
    border: 1px solid rgba(217,164,65,.25);
    padding: 3px 8px;
    border-radius: 999px;
}

.card .icon,
.rm-tile__icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(217,164,65,.12);
    color: var(--rm-gold-400);
    flex-shrink: 0;
    font-size: 20px;
}

.card h2,
.rm-tile h2 {
    font-family: var(--rm-font-display);
    font-weight: 600;
    letter-spacing: .01em;
    font-size: 20px;
    margin: 0;
    color: #fff;
    padding-right: 70px;
}

.card p,
.rm-tile p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--rm-text-dim);
}

.card .go,
.rm-tile__go {
    margin-top: auto;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--rm-gold-400);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Panels / cards */
.panel,
.subject-new-panel,
.filters,
.rm-card,
.dashboard-auth-box,
.auth-card {
    background: var(--rm-surface);
    border: 1px solid var(--rm-border);
    border-radius: var(--rm-radius-md);
    padding: 16px;
    box-shadow: var(--rm-shadow-sm);
}

@media (min-width: 768px) {
    .panel,
    .subject-new-panel,
    .filters,
    .rm-card,
    .dashboard-auth-box,
    .auth-card {
        padding: 20px;
    }
}

/* Buttons */
.btn,
.auth-btn,
.subject-new-btn,
.dashboard-auth-btn,
.rm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--rm-radius-sm);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
}

.btn:active,
.auth-btn:active,
.subject-new-btn:active,
.dashboard-auth-btn:active,
.rm-btn:active {
    transform: scale(.97);
}

.btn,
.btn.primary,
.auth-btn,
.subject-new-btn--primary,
.dashboard-auth-btn--primary,
.rm-btn--primary {
    background: linear-gradient(135deg, var(--rm-gold-500), #c98a2b);
    color: #241705;
    font-family: 'Sarabun';
}

.btn.secondary,
.btn.ghost,
.subject-new-btn--secondary,
.dashboard-auth-btn--secondary,
.rm-btn--ghost {
    background: rgba(255,255,255,.04);
    border-color: var(--rm-border-strong);
    color: var(--rm-text);
}

@media (hover: hover) {
    .btn:hover,
    .auth-btn:hover,
    .subject-new-btn:hover,
    .dashboard-auth-btn:hover,
    .rm-btn:hover {
        filter: brightness(1.08);
    }
}

/* Fields / forms */
.field,
.rm-field,
.subject-new-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label,
.rm-field label,
.subject-new-field label {
    font-size: 12px;
    color: var(--rm-text-mute);
    font-weight: 600;
}

.field input,
.field select,
.field textarea,
.rm-field input,
.rm-field select,
.subject-new-field input,
.subject-new-field select,
.subject-new-field textarea {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--rm-border-strong);
    border-radius: var(--rm-radius-sm);
    padding: 9px 11px;
    font-size: 14px;
    background: var(--rm-bg-soft);
    color: var(--rm-text);
    box-sizing: border-box;
}

.field textarea,
.subject-new-field textarea {
    min-height: 110px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.rm-field input:focus,
.rm-field select:focus,
.subject-new-field input:focus,
.subject-new-field select:focus,
.subject-new-field textarea:focus {
    outline: 2px solid rgba(217,164,65,.45);
    outline-offset: 1px;
}

/* Filters */
.filters,
.rm-filter-bar {
    margin-bottom: 16px;
}

.filters form,
.rm-filter-bar form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 700px) {
    .filters form,
    .rm-filter-bar form {
        grid-template-columns: 2fr 1fr 1fr 1fr auto auto;
        align-items: end;
    }
}

/* Alerts */
.alert,
.subject-new-alert {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(193,67,67,.14);
    border-color: rgba(193,67,67,.28);
    color: #e6a2a2;
}

.alert-success {
    background: rgba(79,174,109,.14);
    border-color: rgba(79,174,109,.28);
    color: #8fd6a6;
}

/* Tables */
.table-wrap,
.rm-table-scroll {
    position: relative;
    border-radius: var(--rm-radius-md);
    border: 1px solid var(--rm-border);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--rm-surface);
}

.table-inner table,
.table-wrap table,
.rm-table-scroll table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table-inner th,
.table-inner td,
.table-wrap th,
.table-wrap td,
.rm-table-scroll th,
.rm-table-scroll td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--rm-border);
    white-space: nowrap;
    text-align: left;
}

.table-inner thead th,
.table-wrap thead th,
.rm-table-scroll thead th {
    position: sticky;
    top: 0;
    background: transparent;
    color: var(--rm-gold-300);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    z-index: 1;
}

.table-inner tbody tr:last-child td,
.table-wrap tbody tr:last-child td,
.rm-table-scroll tbody tr:last-child td {
    border-bottom: 0;
}

.table-inner tbody tr:hover,
.table-wrap tbody tr:hover,
.rm-table-scroll tbody tr:hover {
    background: rgba(255,255,255,.02);
}

.num {
    text-align: right !important;
    font-family: var(--rm-font-num);
    font-variant-numeric: tabular-nums;
}

/* Pills / states */
.status-badge,
.rm-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(79,174,109,.14);
    color: #8fd6a6;
}

.status-badge.off,
.rm-pill--off {
    background: rgba(193,67,67,.14);
    color: #e6a2a2;
    border-color: rgba(193,67,67,.28);
}

.status-badge.warn,
.rm-pill--warn {
    background: rgba(217,154,63,.14);
    color: var(--rm-gold-300);
    border-color: rgba(217,154,63,.3);
}

/* Empty / notes */
.empty,
.rm-empty {
    background: var(--rm-surface);
    border: 1px solid var(--rm-border);
    border-radius: var(--rm-radius-md);
    padding: 26px 18px;
    text-align: center;
    color: var(--rm-text-mute);
    font-size: 14px;
}

.footer-note,
.subject-new-note,
.auth-note {
    color: var(--rm-text-mute);
    font-size: 13.5px;
    line-height: 1.5;
}

/* Utility */
.flag-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}