:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #fafafb;
    --border: #e6e7eb;
    --text: #14151a;
    --text-dim: #6b6d76;
    --accent: #6b1f2a;
    --accent-2: #8a2c39;
    --accent-soft: #f7e9eb;
    --success-bg: #eaf7ef;
    --success-text: #1e6b3f;
    --success-border: #b9e6c9;
    --danger: #b3261e;
    --shadow: 0 1px 2px rgba(20, 21, 26, 0.04), 0 8px 24px rgba(20, 21, 26, 0.06);
    --radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0f12;
        --surface: #17181d;
        --surface-2: #1c1d23;
        --border: #2a2b32;
        --text: #eceef2;
        --text-dim: #9a9ca6;
        --accent: #d98a94;
        --accent-2: #e6a5ad;
        --accent-soft: #2a1b1e;
        --success-bg: #0f2a1a;
        --success-text: #7fe0a6;
        --success-border: #1f4a30;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
}

.blob {
    position: fixed;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.28;
    z-index: -1;
    pointer-events: none;
    will-change: transform;
}

.blob-a { background: var(--accent); top: -180px; left: -180px; }
.blob-b { background: var(--accent-2); bottom: -220px; right: -180px; }

@media (prefers-color-scheme: dark) {
    .blob { opacity: 0.16; }
}

.page {
    max-width: 980px;
    margin: 0 auto;
    padding: 48px 24px 96px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    gap: 16px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.brand-text h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand-text p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-dim);
}

.main-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    transition: border-color .15s ease, transform .15s ease, background .15s ease, color .15s ease;
}

.nav-link:hover {
    border-color: var(--accent);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

.hero {
    margin-bottom: 32px;
}

.hero h2 {
    font-size: 26px;
    margin: 0 0 6px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.hero p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14.5px;
}

.alert {
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 28px;
    border: 1px solid var(--success-border);
    background: var(--success-bg);
    color: var(--success-text);
    font-weight: 500;
}

.alert.error {
    border-color: #e6b6b1;
    background: #fbeceb;
    color: var(--danger);
}

form { display: flex; flex-direction: column; gap: 24px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .3s ease, border-color .3s ease;
}

.card:hover {
    border-color: var(--accent);
    box-shadow: 0 16px 40px rgba(20, 21, 26, 0.14);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header .num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
}

.card-body {
    padding: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field.span-2 { grid-column: span 2; }
.field.span-full { grid-column: 1 / -1; }

label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.01em;
}

input, select, textarea {
    font-family: inherit;
    font-size: 14.5px;
    padding: 10px 13px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
    width: 100%;
}

textarea { resize: vertical; min-height: 72px; }

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.time-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.time-pair .sub-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
    display: block;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 4px 2px;
}

button.primary {
    appearance: none;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 14.5px;
    font-weight: 600;
    padding: 13px 28px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(107, 31, 42, 0.25);
    transition: transform .15s ease, box-shadow .15s ease;
}

button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(107, 31, 42, 0.32);
}

button.primary:active { transform: translateY(0); }

/* Listado */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.search-bar input {
    flex: 1;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13.5px;
    min-width: 1200px;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-weight: 650;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text);
}

tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.badge.aprobado { background: var(--success-bg); color: var(--success-text); }
.badge.denegado { background: #fbeceb; color: var(--danger); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 14px;
}

.row-actions a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

.row-actions a:hover { text-decoration: underline; }

.count-pill {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.clickable-row { cursor: pointer; }

/* Modal de detalle */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 12, 15, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 760px;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 26px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.modal-header h3 span { color: var(--text-dim); font-weight: 500; }

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-dim);
    padding: 2px 10px;
    border-radius: 8px;
}

.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
    padding: 22px 26px 6px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.modal-section h4 {
    margin: 0 0 12px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px 20px;
}

.modal-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.modal-footer {
    padding: 16px 26px 22px;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .page { padding: 28px 16px 72px; }
    .card-body { grid-template-columns: 1fr; }
    .field.span-2 { grid-column: auto; }
    .modal-body { padding: 18px 18px 4px; }
    .modal-header, .modal-footer { padding: 16px 18px; }
}
