:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e5e7eb;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #1e293b;
    --accent-hover: #0f172a;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 17px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.brand-text {
    color: var(--text);
}

.brand-section {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    padding-left: 10px;
    margin-left: 4px;
    border-left: 1px solid var(--border);
}

.admin-link {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.admin-link:hover {
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 48px 24px 64px;
    flex: 1;
}

.container-narrow {
    max-width: 760px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 0 0 32px;
    font-size: 16px;
}

/* Index — grid de tarjetas */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.app-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    padding: 28px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    min-height: 140px;
}

.app-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.app-card-name {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    word-break: break-word;
}

.app-card-url {
    color: var(--text-muted);
    font-size: 14px;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-card-url::after {
    content: "->";
    margin-left: auto;
    color: var(--text-muted);
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.app-card:hover .app-card-url::after {
    opacity: 1;
    transform: translateX(4px);
}

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 17px;
    margin: 0 0 18px;
}

/* Admin — formularios y tarjetas */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.count-badge {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 999px;
}

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

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.form-row input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-row input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
}

.form-error {
    color: var(--danger);
    font-size: 14px;
    margin: 0;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: #fecaca;
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

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

/* Lista de apps en admin */
.apps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.app-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.app-row-name {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-row-url {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.muted {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
    margin: 0;
    font-size: 14px;
}

@media (max-width: 600px) {
    .container {
        padding: 32px 16px 48px;
    }
    .page-title {
        font-size: 26px;
    }
    .apps-grid {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: 12px 16px;
    }
}
