:root {
    --app-bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #64748b;
    --border: #e5eaf1;
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --sidebar: #0f172a;
    --sidebar-soft: #172554;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, .12);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 85% 0%, rgba(79, 70, 229, .09), transparent 28rem),
        var(--app-bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

a { color: var(--primary); }
.min-w-0 { min-width: 0; }

.wrapper { min-height: 100vh; }

/* Sidebar */
#sidebar {
    width: 272px;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    color: #fff;
    background:
        radial-gradient(circle at 15% 10%, rgba(99, 102, 241, .35), transparent 18rem),
        linear-gradient(180deg, #111827, var(--sidebar));
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 14px 0 40px rgba(15, 23, 42, .13);
    transition: transform .28s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 15px;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    box-shadow: 0 10px 25px rgba(79,70,229,.3);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; }
.brand-mark i { font-size: 1.35rem; }
.brand-copy { min-width: 0; }
.brand-copy span { display: block; color: #a5b4fc; font-size: .68rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.brand-copy h5 { margin: 2px 0 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#sidebar ul.components {
    flex: 1;
    margin: 0;
    padding: 14px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.18) transparent;
}
#sidebar ul p {
    margin: 15px 10px 7px;
    color: #64748b;
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}
#sidebar ul li { margin-bottom: 4px; }
#sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    color: #cbd5e1;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: .2s ease;
}
#sidebar ul li a i { width: 22px; text-align: center; font-size: 1.05rem; }
#sidebar ul li a:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(2px); }
#sidebar ul li.active a {
    color: #fff;
    background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(79,70,229,.82));
    border-color: rgba(255,255,255,.14);
    box-shadow: 0 12px 24px rgba(30, 27, 75, .28);
}

.sidebar-user {
    margin: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    background: rgba(255,255,255,.05);
}
.user-avatar { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border-radius: 12px; background: rgba(129,140,248,.2); color: #c7d2fe; }
.sidebar-user small, .sidebar-user strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: #94a3b8; font-size: .68rem; }
.sidebar-user strong { font-size: .78rem; color: #fff; }
.logout-link { margin-left: auto; color: #fda4af; padding: 8px; border-radius: 10px; }
.logout-link:hover { color: #fff; background: rgba(244,63,94,.2); }

#sidebarCollapse {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1051;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background: var(--sidebar);
    border-radius: 13px;
    box-shadow: var(--shadow-lg);
}
.sidebar-backdrop { display: none; }

/* Main */
#content {
    width: calc(100% - 272px);
    min-height: 100vh;
    margin-left: 272px;
    padding: 0 30px 24px;
    transition: margin .28s ease, width .28s ease;
}

.app-topbar {
    min-height: 76px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(203,213,225,.65);
}
.app-topbar > div:first-child { display: flex; flex-direction: column; }
.topbar-kicker { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.app-topbar strong { font-size: 1rem; }

.page-heading h2 { letter-spacing: -.03em; }
.page-eyebrow, .section-kicker {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #475569;
    background: rgba(255,255,255,.72);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.card, .app-card {
    border: 1px solid rgba(226,232,240,.9);
    border-radius: var(--radius);
    background: rgba(255,255,255,.92);
    box-shadow: var(--shadow-sm);
}
.app-card-header, .card-header {
    padding: 19px 22px;
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.app-card-header h5 { font-weight: 800; letter-spacing: -.02em; }

.btn { border-radius: 10px; font-weight: 650; }
.btn-fancy { border: 0; background: linear-gradient(135deg, #6366f1, #4338ca); box-shadow: 0 10px 22px rgba(79,70,229,.22); }
.btn-fancy:hover { transform: translateY(-1px); background: linear-gradient(135deg, #4f46e5, #3730a3); }
.btn-light { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }

.form-label, label:not(.form-check-label) { color: #334155; font-size: .83rem; font-weight: 750; }
.form-control, .form-select {
    min-height: 44px;
    color: var(--text);
    border: 1px solid #dbe2ea;
    border-radius: 11px;
    background-color: #fff;
    box-shadow: none;
}
textarea.form-control { min-height: auto; }
.form-control:focus, .form-select:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.input-group-text { color: #64748b; background: #f8fafc; border-color: #dbe2ea; }
.input-group > .input-group-text:first-child { border-radius: 11px 0 0 11px; }
.input-group > .form-control:last-child { border-radius: 0 11px 11px 0; }
.form-text { color: #94a3b8; }

/* Metrics */
.metric-card {
    min-height: 132px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 21px;
    color: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 30px rgba(15,23,42,.13);
    transition: transform .2s ease, box-shadow .2s ease;
}
.metric-card:hover { transform: translateY(-4px); box-shadow: 0 22px 38px rgba(15,23,42,.18); }
.metric-card::after { content: ""; position: absolute; width: 120px; height: 120px; right: -35px; bottom: -45px; border-radius: 50%; background: rgba(255,255,255,.13); }
.metric-card small { display: block; margin-bottom: 8px; color: rgba(255,255,255,.78); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metric-card h2 { position: relative; z-index: 1; margin: 0; font-size: clamp(1.65rem, 2vw, 2.15rem); font-weight: 850; letter-spacing: -.04em; }
.metric-card > i { position: relative; z-index: 1; font-size: 2rem; opacity: .72; }
.metric-indigo { background: linear-gradient(135deg, #4338ca, #6366f1); }
.metric-blue { background: linear-gradient(135deg, #0369a1, #0ea5e9); }
.metric-violet { background: linear-gradient(135deg, #7e22ce, #a855f7); }
.metric-emerald { background: linear-gradient(135deg, #047857, #10b981); }
.metric-rose { background: linear-gradient(135deg, #be123c, #f43f5e); }

/* Tables */
.table { --bs-table-bg: transparent; }
.table thead th {
    padding: 14px 12px;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: .69rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody td { padding: 14px 12px; border-color: #edf1f6; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(79,70,229,.025); }

.badge { padding: .5em .72em; font-weight: 750; }
.badge-soft-primary { color: #4338ca; background: #eef2ff; border: 1px solid #c7d2fe; }
.badge-soft-success { color: #047857; background: #ecfdf5; border: 1px solid #a7f3d0; }
.badge-soft-secondary { color: #475569; background: #f1f5f9; border: 1px solid #cbd5e1; }
.badge-soft-danger { color: #be123c; background: #fff1f2; border: 1px solid #fecdd3; }

.service-avatar { width: 52px; height: 52px; display: grid; place-items: center; object-fit: cover; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; box-shadow: 0 6px 15px rgba(15,23,42,.08); }
.service-avatar-placeholder { color: #6366f1; background: #eef2ff; font-size: 1.15rem; }

.empty-state { text-align: center; color: var(--muted); }
.empty-state h5 { margin-top: 12px; color: var(--text); font-weight: 800; }
.empty-state p { margin: 5px 0 0; }
.empty-state-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto; color: var(--primary); background: #eef2ff; border-radius: 17px; font-size: 1.45rem; }

.event-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background .2s ease;
}
.event-list-item:last-child { border-bottom: 0; }
.event-list-item:hover { color: var(--text); background: #f8fafc; }
.event-date { width: 48px; height: 51px; flex: 0 0 48px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #4338ca; background: #eef2ff; border-radius: 13px; }
.event-date strong { font-size: 1.15rem; line-height: 1; }
.event-date span { margin-top: 3px; font-size: .58rem; font-weight: 850; letter-spacing: .08em; }
.event-list-item .flex-grow-1 strong, .event-list-item .flex-grow-1 small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-list-item .flex-grow-1 small { color: var(--muted); }
.event-time { color: var(--muted); font-size: .72rem; font-weight: 750; white-space: nowrap; }

/* Agenda */
.agenda-sticky-panel {
    position: sticky;
    top: 0;
    z-index: 1025;
    margin: -8px -10px 0;
    padding: 8px 10px 12px;
    background: linear-gradient(180deg, rgba(244,247,251,.98) 0%, rgba(244,247,251,.94) 86%, rgba(244,247,251,0) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.agenda-sticky-panel .app-card { box-shadow: 0 13px 30px rgba(15,23,42,.09); }
.agenda-calendar-scroll { scroll-margin-top: 245px; }
.calendar-wrapper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 18px; background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: var(--radius); }
.month-card { position: relative; overflow: visible; background: #fff; border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow-sm); }
.month-header { padding: 11px; color: #fff; background: linear-gradient(135deg, #1e293b, #334155); border-radius: 14px 14px 0 0; text-align: center; font-size: .76rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.days-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.day-name { padding: 7px 0; color: #64748b; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: .62rem; font-weight: 850; }
.day-cell { height: 55px; position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 4px; border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9; transition: .16s ease; }
.day-cell:hover { z-index: 20; transform: scale(1.04); background: #fff; border-radius: 5px; box-shadow: 0 12px 25px rgba(15,23,42,.15); }
.day-number { margin-bottom: 2px; color: #64748b; font-size: .68rem; font-weight: 800; pointer-events: none; }
.event-dots { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; padding: 0 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.day-full-color { color: #fff !important; cursor: pointer; }
.day-full-color .day-number { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tooltip-evento { visibility: hidden; opacity: 0; width: max-content; min-width: 210px; max-width: 280px; position: absolute; bottom: 110%; left: 50%; z-index: 9999; transform: translateX(-50%); padding: 12px; color: #fff; background: #111827; border-radius: 10px; box-shadow: 0 15px 35px rgba(15,23,42,.35); font-size: .78rem; text-align: left; transition: .18s ease; }
.tooltip-evento::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border: 6px solid transparent; border-top-color: #111827; }
.dot:hover .tooltip-evento, .day-full-color:hover .tooltip-evento { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(-4px); }


/* Compact data tables */
.table-compact thead th { padding: 9px 11px; font-size: .65rem; }
.table-compact tbody td { padding: 7px 11px; font-size: .80rem; }
.table-compact .btn-sm,
.table-compact .btn-action-mini { min-width: 29px; width: 29px; height: 29px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.table-compact .service-avatar { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 4px 10px rgba(15,23,42,.07); }
.table-compact .badge { padding: .38em .62em; font-size: .68rem; }

/* Agenda event visibility */
.agenda-summary { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.agenda-summary strong { font-size: 1.1rem; }
.agenda-day-button { width: 100%; height: 100%; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; }
.agenda-day-button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.agenda-event-bars { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 5px; }
.agenda-event-bar { display: block; width: 72%; height: 5px; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(15,23,42,.12); }
.agenda-event-more { color: #475569; font-size: .56rem; font-weight: 850; line-height: 1; }
.agenda-event-count { display: inline-grid; min-width: 22px; height: 22px; place-items: center; margin-top: 3px; padding: 0 6px; color: #fff; background: rgba(15,23,42,.25); border: 1px solid rgba(255,255,255,.35); border-radius: 999px; font-size: .66rem; font-weight: 850; }
.agenda-detail-table td, .agenda-detail-table th { white-space: nowrap; }
.agenda-empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* Icon-only payment format actions */
.swal-icon-actions { gap: 12px !important; }
.swal-icon-button,
.payment-format-button {
    width: 48px;
    height: 48px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 48px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    font-size: 1.25rem;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(15,23,42,.13);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.swal-icon-button:hover,
.payment-format-button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(15,23,42,.18); filter: brightness(1.04); }
.swal-icon-button:focus-visible,
.payment-format-button:focus-visible { outline: 3px solid rgba(99,102,241,.28); outline-offset: 3px; }
.swal-icon-pdf,
.payment-format-pdf { color: #fff; background: linear-gradient(135deg, #6366f1, #4338ca); }
.swal-icon-ticket,
.payment-format-ticket { color: #fff; background: linear-gradient(135deg, #10b981, #047857); }
.swal-icon-close,
.payment-format-close { color: #475569; background: #eef2f7; border: 1px solid #dce3ec; }
.payment-format-actions { display: flex; justify-content: center; align-items: center; gap: 12px; }

/* Footer */
.app-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 30px; padding: 22px 2px 4px; color: #94a3b8; border-top: 1px solid rgba(203,213,225,.7); font-size: .76rem; }
.app-footer a { text-decoration: none; font-weight: 800; }

/* Login */
body.login-page {
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 15%, rgba(99,102,241,.25), transparent 25rem),
        radial-gradient(circle at 85% 85%, rgba(14,165,233,.18), transparent 28rem),
        #0f172a;
}
.login-card { width: 100%; max-width: 430px; overflow: hidden; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 30px 80px rgba(0,0,0,.38); }
.login-header { padding: 38px 30px 30px; color: #fff; text-align: center; background: linear-gradient(135deg, #312e81, #4f46e5 60%, #0ea5e9); }
.login-header h4 { font-size: 1.35rem; font-weight: 850; }
.login-body { padding: 34px 32px; }
.btn-login { min-height: 48px; margin-top: 8px; border: 0; background: linear-gradient(135deg, #4f46e5, #3730a3); box-shadow: 0 12px 25px rgba(79,70,229,.28); }
.btn-login:hover { transform: translateY(-1px); background: linear-gradient(135deg, #4338ca, #312e81); }

@media (max-width: 1200px) {
    .calendar-wrapper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 992px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.active { transform: translateX(0); }
    #sidebarCollapse { display: grid; place-items: center; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1035; pointer-events: none; opacity: 0; background: rgba(15,23,42,.58); backdrop-filter: blur(2px); transition: opacity .25s ease; }
    .sidebar-backdrop.active { pointer-events: auto; opacity: 1; }
    body.sidebar-open { overflow: hidden; }
    #content { width: 100%; margin-left: 0; padding: 0 16px 20px; }
    .app-topbar { min-height: 72px; padding-left: 54px; margin-bottom: 20px; }
    .topbar-actions { display: none; }
    .calendar-wrapper { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .agenda-sticky-panel { margin-inline: -5px; padding-inline: 5px; }
    .agenda-sticky-panel .page-heading { margin-bottom: 10px !important; }
    .agenda-sticky-panel .app-card { margin-bottom: 12px !important; }
    .page-heading h2 { font-size: 1.55rem; }
    .page-heading .btn { width: 100%; }
    .app-card-header { padding: 16px; }
    .card-body.p-4, .card-body.p-lg-5 { padding: 20px !important; }
    .metric-card { min-height: 118px; padding: 17px; }
    .metric-card > i { font-size: 1.65rem; }
    .metric-card h2 { font-size: 1.55rem; }
    .app-footer { flex-direction: column; text-align: center; }
    .calendar-wrapper { padding: 10px; gap: 14px; }
    .day-cell { height: 58px; }
    .tooltip-evento { display: none; }

    .responsive-table thead { display: none; }
    .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
    .responsive-table tbody { padding: 9px; }
    .responsive-table tr { margin-bottom: 8px; padding: 7px 11px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 5px 15px rgba(15,23,42,.04); }
    .responsive-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0 !important; text-align: right !important; border: 0; white-space: normal; }
    .responsive-table td::before { content: attr(data-label); color: #64748b; font-size: .67rem; font-weight: 850; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
    .responsive-table td[data-label="Imagen"] { justify-content: center; }
    .responsive-table td[data-label="Imagen"]::before { display: none; }
    .responsive-table .btn-group { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 420px) {
    #content { padding-inline: 11px; }
    .app-topbar { padding-left: 50px; }
    .app-topbar strong { font-size: .9rem; }
    .login-body { padding: 28px 22px; }
}

@media print {
    .agenda-sticky-panel { position: static !important; margin: 0 !important; padding: 0 !important; background: none !important; backdrop-filter: none !important; }
    @page { size: landscape; margin: .5cm; }
    .no-print, header, footer, #sidebar, #sidebarCollapse, .sidebar-backdrop, .app-topbar, .btn { display: none !important; }
    body, .wrapper, #content { width: 100% !important; margin: 0 !important; padding: 0 !important; display: block !important; background: #fff !important; }
    .print-area { position: absolute; inset: 0 auto auto 0; width: 100%; }
    .calendar-wrapper { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 10px !important; padding: 0 !important; border: 0 !important; background: none !important; }
    .month-card { break-inside: avoid; box-shadow: none !important; border: 1px solid #999 !important; }
    .month-header { color: #000 !important; background: #ddd !important; border-bottom: 1px solid #000; }
    .day-cell { height: 40px !important; }
    .tooltip-evento { display: none !important; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* Contract quick-view modal */
.contract-view-modal .modal-dialog { max-width: min(1180px, calc(100vw - 28px)); }
.contract-view-modal .modal-content {
    overflow: hidden;
    border: 0;
    border-radius: 24px;
    background: #f8fafc;
    box-shadow: 0 34px 90px rgba(15, 23, 42, .30);
}
.contract-view-modal .modal-header {
    padding: 19px 23px;
    color: #fff;
    border: 0;
    background:
        radial-gradient(circle at 92% 0%, rgba(255,255,255,.16), transparent 22rem),
        linear-gradient(135deg, #111827, #312e81 58%, #4f46e5);
}
.contract-view-modal .modal-title { margin: 1px 0 0; font-size: 1.22rem; font-weight: 850; }
.contract-view-modal .btn-close { filter: invert(1) grayscale(1) brightness(4); opacity: .9; }
.contract-modal-kicker { display: block; color: #c7d2fe; font-size: .62rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.contract-view-modal .modal-body { padding: 20px; background: #f3f6fb; }
.contract-modal-loading { min-height: 340px; display: grid; place-items: center; align-content: center; gap: 13px; color: #64748b; font-weight: 750; }
.contract-modal-loading .spinner-border { width: 2.25rem; height: 2.25rem; }
.contract-modal-footer { padding: 13px 20px; border-top: 1px solid #dfe6ef; background: #fff; }
.contract-modal-main-actions, .contract-payment-actions { display: flex; align-items: center; justify-content: center; gap: 8px; }
.contract-icon-action {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    border: 0;
    border-radius: 11px;
    font-size: 1rem;
    text-decoration: none;
    box-shadow: 0 7px 16px rgba(15,23,42,.12);
    transition: transform .17s ease, box-shadow .17s ease, filter .17s ease;
}
.contract-icon-action:hover { transform: translateY(-2px); box-shadow: 0 11px 22px rgba(15,23,42,.17); filter: brightness(1.04); }
.contract-icon-action:focus-visible { outline: 3px solid rgba(99,102,241,.26); outline-offset: 2px; }
.contract-modal-main-actions .contract-icon-action { width: 44px; height: 44px; flex-basis: 44px; border-radius: 13px; font-size: 1.12rem; }
.contract-action-print, .payment-action-print { color: #fff; background: linear-gradient(135deg, #111827, #334155); }
.contract-action-pdf, .payment-action-pdf { color: #fff; background: linear-gradient(135deg, #ef4444, #b91c1c); }

.contract-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    color: #fff;
    border-radius: 19px;
    background:
        radial-gradient(circle at 85% 20%, rgba(255,255,255,.17), transparent 20rem),
        linear-gradient(135deg, #312e81, #4f46e5 62%, #2563eb);
    box-shadow: 0 16px 34px rgba(79,70,229,.20);
}
.contract-hero-copy { min-width: 0; }
.contract-hero-copy .badge { margin-right: 7px; padding: .45em .68em; font-size: .63rem; letter-spacing: .05em; text-transform: uppercase; }
.contract-hero-label { color: #c7d2fe; font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.contract-hero h3 { margin: 8px 0 4px; font-size: clamp(1.25rem, 2.2vw, 1.8rem); font-weight: 900; }
.contract-hero p { margin: 0; color: #e0e7ff; font-weight: 700; }
.contract-event-date { min-width: 210px; display: flex; align-items: center; gap: 12px; padding: 13px 15px; border: 1px solid rgba(255,255,255,.22); border-radius: 15px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.contract-event-date > i { font-size: 1.55rem; }
.contract-event-date span, .contract-detail-card span, .contract-money-card span, .contract-notes-grid article > span { display: block; color: #64748b; font-size: .64rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.contract-event-date span { color: #c7d2fe; }
.contract-event-date strong { display: block; font-size: 1.08rem; }

.contract-money-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.contract-money-card { padding: 15px 17px; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; box-shadow: 0 8px 20px rgba(15,23,42,.05); }
.contract-money-card strong { display: block; margin-top: 3px; color: #0f172a; font-size: 1.2rem; font-weight: 900; }
.contract-money-card.paid { border-color: #bbf7d0; background: #f0fdf4; }
.contract-money-card.paid strong { color: #047857; }
.contract-money-card.balance { border-color: #fecaca; background: #fff7f7; }
.contract-money-card.balance strong { color: #b91c1c; }

.contract-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 14px; }
.contract-detail-card { min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 14px 15px; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; }
.contract-detail-card > i { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 35px; color: #4f46e5; border-radius: 10px; background: #eef2ff; }
.contract-detail-card div { min-width: 0; }
.contract-detail-card strong { display: block; margin-top: 2px; color: #172033; font-size: .88rem; overflow-wrap: anywhere; }
.contract-detail-card small { display: block; margin-top: 2px; color: #64748b; font-size: .72rem; overflow-wrap: anywhere; }

.contract-notes-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 11px; }
.contract-notes-grid article { padding: 14px 15px; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; }
.contract-notes-grid article > div { margin-top: 6px; color: #475569; font-size: .8rem; line-height: 1.55; }

.contract-payments-section { margin-top: 18px; overflow: hidden; border: 1px solid #dfe6ef; border-radius: 18px; background: #fff; box-shadow: 0 10px 24px rgba(15,23,42,.05); }
.contract-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; border-bottom: 1px solid #e5eaf1; }
.contract-section-heading span:first-child { color: #6366f1; font-size: .62rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.contract-section-heading h4 { margin: 1px 0 0; color: #172033; font-size: 1rem; font-weight: 900; }
.contract-payment-count { padding: 6px 10px; color: #4338ca; border-radius: 999px; background: #eef2ff; font-size: .68rem; font-weight: 850; }
.contract-payments-table-wrap { max-height: 310px; }
.contract-payments-table { min-width: 860px; font-size: .76rem; }
.contract-payments-table thead { position: sticky; top: 0; z-index: 2; }
.contract-payments-table thead th { padding: 9px 11px; color: #64748b; border-bottom: 1px solid #dfe6ef; background: #f8fafc; font-size: .61rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.contract-payments-table tbody td { padding: 9px 11px; color: #334155; border-color: #edf1f5; }
.contract-payments-table tbody tr:hover { background: #fafbff; }
.payment-folio { color: #64748b; font-weight: 850; }
.payment-method { display: inline-flex; padding: 4px 7px; color: #334155; border-radius: 999px; background: #f1f5f9; font-size: .62rem; font-weight: 850; text-transform: uppercase; }
.payment-note { max-width: 230px; white-space: normal; }
.contract-payment-actions .contract-icon-action { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; font-size: .86rem; box-shadow: 0 5px 12px rgba(15,23,42,.11); }
.contract-payments-empty { min-height: 150px; display: grid; place-items: center; align-content: center; gap: 4px; color: #94a3b8; text-align: center; }
.contract-payments-empty i { font-size: 1.7rem; }
.contract-payments-empty strong { color: #64748b; }
.contract-payments-empty span { font-size: .74rem; }

@media (max-width: 767.98px) {
    .contract-view-modal .modal-dialog { max-width: none; margin: 8px; }
    .contract-view-modal .modal-content { border-radius: 18px; }
    .contract-view-modal .modal-header { padding: 16px 17px; }
    .contract-view-modal .modal-body { padding: 12px; }
    .contract-hero { align-items: stretch; flex-direction: column; padding: 17px; }
    .contract-event-date { min-width: 0; }
    .contract-money-grid { grid-template-columns: 1fr; gap: 8px; }
    .contract-detail-grid, .contract-notes-grid { grid-template-columns: 1fr; gap: 8px; }
    .contract-money-card, .contract-detail-card, .contract-notes-grid article { padding: 12px 13px; }
    .contract-modal-footer > .small { display: none; }
    .contract-modal-footer { justify-content: center; }
}
