:root {
    /* XHOST Base Colors */
    --color-green-500: #4FAA2C;
    --color-green-700: #3E8F21;
    --color-blue-900: #060840;
    --color-blue-info-500: #17A2B8;
    --color-gray-50:  #F8F9FA;
    --color-gray-100: #F1F3F5;
    --color-gray-200: #E9ECEF;
    --color-gray-300: #DEE2E6;
    --color-gray-400: #CED4DA;
    --color-gray-500: #ADB5BD;
    --color-gray-600: #868E96;
    --color-gray-700: #495057;
    --color-gray-800: #343A40;
    --color-gray-900: #212529;
    --color-red-500:  #DC3545;
    --color-yellow-500: #FFC107;
    --color-white: #FFFFFF;
    --color-expo: #4630EB;
    --color-dl: #10B981;

    /* Shadows & Radii */
    --elevation-1: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.18);
    --elevation-2: 0 4px 6px rgba(0,0,0,0.08);
    --elevation-3: 0 10px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Tokens */
    --font: 'Inter', system-ui, sans-serif;
    --bg-color: #EEF0F4;
    --sidebar-bg: var(--color-blue-900);
    --surface-color: var(--color-white);
    --primary-color: var(--color-green-500);
    --primary-hover: var(--color-green-700);
    --text-color: var(--color-gray-900);
    --text-muted: var(--color-gray-600);
    --border-color: var(--color-gray-200);

    --status-pending: var(--color-yellow-500);
    --status-processing: var(--color-blue-info-500);
    --status-completed: var(--color-green-500);
    --status-failed: var(--color-red-500);

    --sidebar-w: 220px;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 14px;
}

/* ============================================================
   APP SHELL (Sidebar + Main Column)
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 10;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-white);
    font-size: 1rem;
    font-weight: 700;
    padding: 0 0.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.nav-item:hover { background-color: rgba(255,255,255,0.08); color: rgba(255,255,255,0.95); }
.nav-item.active { background-color: rgba(255,255,255,0.12); color: var(--color-white); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* --- Main Column --- */
.main-col {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

/* --- Topbar --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--elevation-1);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-blue-900);
}

.topbar-title h1 {
    font-size: 1.125rem;
    font-weight: 700;
}

.topbar-title svg { width: 20px; height: 20px; color: var(--color-green-500); }

.stats {
    display: flex;
    gap: 1rem;
}

.stat-card {
    background: var(--color-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
}

.stat-card--processing .stat-value { color: var(--status-processing); }
.stat-card--completed .stat-value { color: var(--status-completed); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-blue-900);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
    font-weight: 600;
}

/* --- Content --- */
.content {
    padding: 2rem;
    flex: 1;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--elevation-1);
    overflow: hidden;
}

.table-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--color-gray-50);
}

.table-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-gray-700);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-title svg { width: 15px; height: 15px; }

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

.orders-table thead th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--color-gray-50);
    white-space: nowrap;
}

.orders-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s;
}

.orders-table tbody tr:last-child { border-bottom: none; }
.orders-table tbody tr:hover { background-color: var(--color-gray-50); }

.orders-table tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
}

/* Status indicator bar */
.orders-table tbody tr[data-status="PENDING"]   { border-left: 3px solid var(--status-pending); }
.orders-table tbody tr[data-status="PROCESSING"] { border-left: 3px solid var(--status-processing); }
.orders-table tbody tr[data-status="BUILDING_APK"],
.orders-table tbody tr[data-status="BUILDING_AAB"] { border-left: 3px solid var(--status-processing); }
.orders-table tbody tr[data-status="COMPLETED"],
.orders-table tbody tr[data-status="APK_READY"],
.orders-table tbody tr[data-status="AAB_READY"]  { border-left: 3px solid var(--status-completed); }
.orders-table tbody tr[data-status="FAILED"]     { border-left: 3px solid var(--status-failed); }

/* Col: Radio */
.col-radio .radio-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-blue-900);
}
.col-radio .radio-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Col: fecha */
.col-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.col-date svg { width: 12px; height: 12px; vertical-align: middle; margin-right: 4px; }

/* Col: acciones */
.col-actions {
    white-space: nowrap;
}

.action-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================================
   STATUS BADGE
   ============================================================ */
.status-badge {
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.status-badge svg { width: 11px; height: 11px; }

.badge-pending    { background: #FFF3CD; color: #856404; border: 1px solid #FFEEBA; }
.badge-processing { background: #D1ECF1; color: #0C5460; border: 1px solid #BEE5EB; }
.badge-completed  { background: #D4EDDA; color: #155724; border: 1px solid #C3E6CB; }
.badge-failed     { background: #F8D7DA; color: #721C24; border: 1px solid #F5C6CB; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.15s;
    text-decoration: none;
    color: var(--color-white);
    white-space: nowrap;
}

.btn svg { width: 13px; height: 13px; flex-shrink: 0; }

.btn-primary  { background-color: var(--primary-color); }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: var(--color-blue-900); }
.btn-secondary:hover { background-color: #030424; }
.btn-danger   { background-color: var(--color-red-500); }
.btn-danger:hover { background-color: #c82333; }
.btn-warning  { background-color: var(--color-yellow-500); color: var(--color-gray-900); }
.btn-warning:hover { background-color: #e0a800; }
.btn-expo     { background-color: var(--color-expo); }
.btn-expo:hover { background-color: #3520c9; }
.btn-dl       { background-color: var(--color-dl); }
.btn-dl:hover { background-color: #0ca26a; }

/* Login buttons need full width */
.btn-block { width: 100%; padding: 0.9rem; font-size: 0.95rem; }

/* Icon-only button */
.btn-icon {
    padding: 0.4rem 0.55rem;
}

/* ============================================================
   STATE: Loader, Empty
   ============================================================ */
.loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; margin-bottom: 1rem; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--color-gray-700); }
.empty-state p  { font-size: 0.875rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(6, 8, 64, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 850px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--elevation-3);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--color-gray-50);
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-blue-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title svg { width: 16px; height: 16px; }

.modal-close {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    transition: all 0.15s;
}
.modal-close svg { width: 16px; height: 16px; }
.modal-close:hover { border-color: var(--color-red-500); color: var(--color-red-500); }

.modal-body {
    padding: 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    position: relative;
}

.terminal {
    background-color: #0b0f19;
    color: #4FAA2C;
    font-family: 'Courier New', Courier, monospace;
    padding: 1.5rem;
    width: 100%;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 70vh;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--color-gray-100);
}

.login-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--elevation-2);
    text-align: center;
}

.login-logo { height: 56px; margin-bottom: 2rem; }
.login-card h2 { margin-bottom: 2rem; font-size: 1.4rem; color: var(--color-blue-900); }

.form-group { margin-bottom: 1.25rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.8rem; color: var(--color-gray-700); font-weight: 600; }
.form-group input {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}
.form-group input:focus { border-color: var(--color-green-500); box-shadow: 0 0 0 3px rgba(79, 170, 44, 0.15); }

.login-error { color: var(--color-red-500); margin-top: 0.75rem; font-size: 0.85rem; font-weight: 500; min-height: 1.2rem; }

/* ============================================================
   EDIT MODAL
   ============================================================ */
.modal-edit { max-width: 680px; }

.edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.edit-grid .form-group { margin-bottom: 0; }

.edit-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.edit-actions .btn { flex: 0 0 auto; padding: 0.55rem 1.25rem; font-size: 0.85rem; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--color-blue-900);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--elevation-3);
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 2000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}
.toast.success { background-color: var(--color-green-500); }
.toast.error   { background-color: var(--color-red-500); }

@keyframes toastIn  { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ============================================================
   MODAL PLAY STORE
   ============================================================ */
.modal-store {
    max-width: 1100px;
    width: 95%;
}

.store-modal-body {
    display: flex !important;
    flex-direction: row !important;
    padding: 0 !important;
    gap: 0;
    min-height: 500px;
    max-height: 80vh;
}

/* Columna izquierda: descripciones */
.store-col-desc {
    width: 380px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Columna derecha: assets */
.store-col-assets {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.store-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.store-section-title svg { width: 13px; height: 13px; }

.store-desc-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.store-desc-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-gray-700);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--color-gray-100);
    padding: 0.15rem 0.4rem;
    border-radius: 9999px;
}

.store-textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-family: var(--font);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--color-gray-50);
    resize: vertical;
    cursor: text;
    outline: none;
    transition: border-color 0.15s;
}
.store-textarea:focus { border-color: var(--color-green-500); }
.store-textarea--short { height: 70px; }
.store-textarea--long  { height: 220px; }

.btn-copy {
    align-self: flex-start;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}

/* Grid de imágenes */
.store-assets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    flex: 1;
}

.store-asset-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-gray-50);
    display: flex;
    flex-direction: column;
}

.store-asset-preview {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    background: var(--color-gray-200);
    cursor: pointer;
    transition: opacity 0.15s;
}
.store-asset-preview:hover { opacity: 0.88; }

/* Screenshot tiene proporción 9:16 — la mostramos comprimida */
.store-asset-preview--portrait {
    aspect-ratio: 9/16;
    max-height: 180px;
    object-fit: cover;
}

/* Ícono cuadrado */
.store-asset-preview--square {
    aspect-ratio: 1/1;
    max-height: 120px;
    object-fit: cover;
}

.store-asset-info {
    padding: 0.5rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.store-asset-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.store-actions-footer {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* ============================================================
   PULSE (compilando)
   ============================================================ */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.pulse { animation: pulse 2s infinite; }
