:root {
    --bg-deep: #020617;
    --bg-elevated: #0f172a;
    --bg-card: #111827;
    --bg-input: #1e293b;
    --fg-primary: #f8fafc;
    --fg-secondary: #cbd5e1;
    --fg-muted: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.25);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.2);
    --accent-red: #ef4444;
    --accent-pink-glow: rgba(236,72,153,0.35);
    --border-color: #1e293b;
    --border-light: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.2);
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--fg-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(6,182,212,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(16,185,129,0.04) 0%, transparent 50%);
}

.app-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.app-header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #f9a8d4, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-pink-glow);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--fg-primary), var(--fg-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.header-link {
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.header-link:hover { color: var(--accent-cyan); }


/* Upload Section */
.upload-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 23px 24px 20px 24px;
    margin-bottom: 0;
    box-shadow: var(--shadow-card);
}

.upload-row-inner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.upload-row-inner input[type="file"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--fg-secondary);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.upload-row-inner input[type="file"]:hover {
    border-color: var(--accent-cyan);
}

.upload-row-inner input[type="file"]::-webkit-file-upload-button {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 12px;
    transition: box-shadow var(--transition);
}

.upload-row-inner input[type="file"]::-webkit-file-upload-button:hover {
    box-shadow: 0 2px 12px var(--accent-amber-glow);
}

.feedback-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-name {
    font-weight: 600;
    color: var(--accent-emerald);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.file-name i { font-size: 15px; }

.message-text {
    font-size: 14px;
    color: var(--fg-secondary);
    padding: 4px 0;
}

.message-text.success { color: var(--accent-emerald); }
.message-text.error { color: var(--accent-red); }
.message-text.warning { color: var(--accent-amber); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}


.btn-amber {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-amber-glow);
}
.btn-amber:hover { box-shadow: 0 4px 20px var(--accent-amber-glow); }

.btn-emerald {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-emerald-glow);
}
.btn-emerald:hover { box-shadow: 0 4px 20px var(--accent-emerald-glow); }

.btn-ghost {
    background: var(--bg-input);
    color: var(--fg-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--border-color); color: var(--fg-primary); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Data Card */
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: border-color var(--transition);
}
.data-card:hover { border-color: var(--border-light); }

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(6,182,212,0.08) 0%, var(--bg-elevated) 60%);
    border-bottom: 1px solid var(--border-color);
    border-top: 2px solid rgba(6,182,212,0.25);
}

.data-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--fg-primary);
}

.data-card-title i {
    color: var(--accent-cyan);
    font-size: 20px;
}

.data-card-count {
    background: rgba(6,182,212,0.12);
    color: var(--accent-cyan);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.data-card-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-size-select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--fg-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color-scheme: dark;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

.page-size-select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

/* Data Table */
.data-table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--fg-secondary);
    vertical-align: middle;
    border-bottom: 1px solid rgba(30,41,59,0.5);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(6,182,212,0.04); }
.data-table tbody tr:nth-child(even) td { background: rgba(15,23,42,0.3); }
.data-table tbody tr:nth-child(even):hover td { background: rgba(6,182,212,0.06); }

.cell-number {
    font-weight: 700;
    color: var(--accent-cyan);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}


.cell-center { text-align: center; }

.cell-left { text-align: left; }

.cell-right { text-align: right; }

.data-table th.cell-center { text-align: center; }
.data-table th.cell-left   { text-align: left; }
.data-table th.cell-right  { text-align: right; }
.propietarios-card .data-card-header {
    background: linear-gradient(135deg, rgba(16,185,129,0.08) 0%, var(--bg-elevated) 60%);
    border-top: 2px solid rgba(16,185,129,0.25);
}

.propietarios-card .data-card-title i { color: var(--accent-emerald); }
.propietarios-card .data-card-count {
    background: rgba(16,185,129,0.12);
    color: var(--accent-emerald);
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.page-info {
    font-size: 14px;
    color: var(--fg-secondary);
    font-weight: 600;
}

.pagination-bar .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-bar .btn:not(:disabled):hover {
    transform: none;
}

/* Empty state */
.empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--fg-muted);
}
.empty-state i { font-size: 36px; margin-bottom: 12px; color: var(--border-light); display: block; }
.empty-state p { font-size: 14px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: slideInRight 300ms ease, fadeOut 300ms ease 2.7s forwards;
    min-width: 280px;
}

.toast-success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }
.toast-info { background: #164e63; color: #67e8f9; border: 1px solid #06b6d4; }
.toast-warning { background: #78350f; color: #fcd34d; border: 1px solid #f59e0b; }

@keyframes slideInRight {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Upload Row — 2 columns */
.upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* Process Card */
.process-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: flex-start;
    padding: 23px 24px 20px 24px;
    position: relative;
}

/* Tips Button */
.tips-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.12);
    border: 1px solid rgba(236, 72, 153, 0.25);
    color: #ec4899;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

.tips-btn:hover {
    background: rgba(236, 72, 153, 0.25);
    border-color: #ec4899;
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
    transform: scale(1.08);
}

.tips-btn:active {
    transform: scale(0.95);
}

/* Tips Backdrop */
.tips-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 100;
}

.tips-backdrop.active { display: block; }

/* Tips Popover */
.tips-popover {
    display: none;
    position: absolute;
    top: 56px;
    right: 12px;
    min-width: 600px;
    width: 600px;
    max-width: calc(100vw - 48px);
    resize: horizontal;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 200;
    animation: tipsEnter 250ms ease;
}

.tips-popover.active { display: block; }

.tips-popover::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 14px;
    height: 14px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    border-left: 1px solid var(--border-light);
    transform: rotate(45deg);
}

.tips-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.tips-popover-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tips-popover-title i {
    color: #ec4899;
    font-size: 15px;
}

.tips-popover-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-input);
    color: var(--fg-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.tips-popover-close:hover {
    background: var(--accent-red);
    color: #fff;
}

.tips-popover-body {
    padding: 18px;
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

.tips-popover-body p {
    margin-bottom: 10px;
}

.tips-popover-body p:last-child {
    margin-bottom: 0;
}

.tips-placeholder {
    font-size: 12px;
    color: var(--fg-muted);
    line-height: 1.6;
    font-style: italic;
}

/* Markdown Tips */
.tips-markdown {
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
}

.tips-markdown h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-amber);
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.tips-markdown h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 14px 0 8px 0;
}

.tips-markdown strong {
    color: var(--accent-amber);
    font-weight: 700;
}

.tips-markdown em {
    color: var(--fg-primary);
    font-style: italic;
}

.tips-markdown code {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    background: var(--bg-deep);
    color: var(--accent-emerald);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Markdown Tables */
.tips-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}

.tips-table tr:first-child {
    background: var(--bg-elevated);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    color: var(--accent-amber);
}

.tips-table tr:first-child td {
    border-bottom: 2px solid var(--accent-amber);
    padding: 8px 12px;
}

.tips-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.tips-table tr:hover {
    background: rgba(6, 182, 212, 0.04);
}

.tips-table tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.3);
}

.tips-table tr:nth-child(even):hover {
    background: rgba(6, 182, 212, 0.06);
}

.tips-table td {
    padding: 8px 12px;
    vertical-align: top;
    color: var(--fg-secondary);
}

.tips-table td:first-child {
    font-weight: 700;
    color: var(--fg-primary);
    width: 40px;
    text-align: center;
}

.tips-table tr:not(:first-child) td:nth-child(2) {
    font-weight: 600;
    color: var(--fg-primary);
}

@keyframes tipsEnter {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.btn-wide {
    min-width: 180px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* Grids Row — 2 cards side by side */
.grids-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.grids-row .data-card {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .grids-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .app-wrapper { padding: 20px 16px 40px; }
    .app-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .app-header-right { flex-wrap: wrap; }
    .upload-row { grid-template-columns: 1fr; gap: 16px; }
    .upload-row-inner { flex-direction: column; align-items: stretch; }
    .upload-row-inner input[type="file"] { min-width: 100%; }
    .data-card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .data-card-controls { align-self: flex-end; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
    .process-card .btn { justify-content: center; width: 100%; }
}